فهرست منبع

Merge pull request #2042 from hestiacp/feature/config-tests-drone

Apply Nginx config tests with Drone
Jaap Marcus 4 سال پیش
والد
کامیت
e83d0136f6
3فایلهای تغییر یافته به همراه95 افزوده شده و 3 حذف شده
  1. 13 3
      .drone.yml
  2. 1 0
      CHANGELOG.md
  3. 81 0
      test/config-tests.bats

+ 13 - 3
.drone.yml

@@ -26,10 +26,15 @@ steps:
 - name: Build Hestia package and install
   commands:
   - ./src/hst_autocompile.sh --hestia --install '~localsrc'
-- name: Run Bats
+- name: Run system / user tests
   commands:
   - bats ./test/test.bats
+- name: Run restore tests
+  commands:
   - bats ./test/restore.bats
+- name: Run config tests 
+  commands:
+  - bats ./test/config-tests.bats
 - name: Run Check PHP
   commands: 
   - ./test/check_php.sh
@@ -65,10 +70,15 @@ steps:
 - name: Build Hestia package install
   commands:
   - ./src/hst_autocompile.sh --hestia --install '~localsrc'
-- name: Run Bats
+- name: Run system / user tests
   commands:
   - bats ./test/test.bats
+- name: Run restore tests
+  commands:
   - bats ./test/restore.bats
+- name: Run config tests 
+  commands:
+  - bats ./test/config-tests.bats
 - name: Run Check PHP
   commands: 
   - ./test/check_php.sh
@@ -78,4 +88,4 @@ trigger:
 
 ---
 kind: signature
-hmac: f3763c63fcebe50a2ad24dc3fb2ab3191cba15750e4dd80be82cea87466d96bc
+hmac: bca7f80ac6198662bc658235d7345485213847f1c00f027e1439775e02776bc7

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
 ### Features
 
 - Added v-delete-firewall-ban ip all #2031
+- Include config tests for nginx/apache2 templates
 
 ### Bugfixes
 

+ 81 - 0
test/config-tests.bats

@@ -0,0 +1,81 @@
+#!/usr/bin/env bats
+
+if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then
+    . /etc/profile.d/hestia.sh
+fi
+
+load 'test_helper/bats-support/load'
+load 'test_helper/bats-assert/load'
+load 'test_helper/bats-file/load'
+
+function random() {
+head /dev/urandom | tr -dc 0-9 | head -c$1
+}
+
+function setup() {
+    # echo "# Setup_file" > &3
+    if [ $BATS_TEST_NUMBER = 1 ]; then
+        echo 'user=test-5285' > /tmp/hestia-test-env.sh
+        echo 'user2=test-5286' >> /tmp/hestia-test-env.sh
+        echo 'userbk=testbk-5285' >> /tmp/hestia-test-env.sh
+        echo 'userpass1=test-5285' >> /tmp/hestia-test-env.sh
+        echo 'userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
+        echo 'HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
+        echo 'domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
+        echo 'domainuk=test-5285.hestiacp.com.uk' >> /tmp/hestia-test-env.sh
+        echo 'rootdomain=testhestiacp.com' >> /tmp/hestia-test-env.sh
+        echo 'subdomain=cdn.testhestiacp.com' >> /tmp/hestia-test-env.sh
+        echo 'database=test-5285_database' >> /tmp/hestia-test-env.sh
+        echo 'dbuser=test-5285_dbuser' >> /tmp/hestia-test-env.sh
+    fi
+    
+    source /tmp/hestia-test-env.sh
+    source $HESTIA/func/main.sh
+    source $HESTIA/conf/hestia.conf
+    source $HESTIA/func/ip.sh
+}
+
+@test "Setup" {
+    run v-add-user $user $user $user@hestiacp.com default "Super Test"
+    assert_success
+    refute_output
+    
+    run run v-add-web-domain $user 'testhestiacp.com'
+    assert_success
+    refute_output
+    
+    ssl=$(v-generate-ssl-cert "testhestiacp.com" "info@testhestiacp.com" US CA "Orange County" HestiaCP IT "mail.$domain" | tail -n1 | awk '{print $2}')
+    mv $ssl/testhestiacp.com.crt /tmp/testhestiacp.com.crt
+    mv $ssl/testhestiacp.com.key /tmp/testhestiacp.com.key
+    
+    # Use self signed certificates during last test
+    run v-add-web-domain-ssl $user testhestiacp.com /tmp
+    assert_success
+    refute_output
+}
+
+@test "Web Config test" {
+    for template in $(v-list-web-templates plain); do
+        run v-change-web-domain-tpl $user testhestiacp.com $template
+        assert_success
+        refute_output
+    done
+}
+
+@test "Proxy Config test" {
+    if [ "$PROXY_SYSTEM" = "nginx" ]; then
+        for template in $(v-list-web-templates plain); do
+            run v-change-web-domain-proxy-tpl $user testhestiacp.com $template
+            assert_success
+            refute_output
+        done
+    else
+        skip "Proxy not installed"
+    fi
+}
+
+@test "Clean up" {
+    run v-delete-user $user
+    assert_success
+    refute_output
+}