Skip to content

Commit e83d013

Browse files
authored
Merge pull request hestiacp#2042 from hestiacp/feature/config-tests-drone
Apply Nginx config tests with Drone
2 parents 1280c82 + 4160572 commit e83d013

File tree

3 files changed

+95
-3
lines changed

3 files changed

+95
-3
lines changed

.drone.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ steps:
2626
- name: Build Hestia package and install
2727
commands:
2828
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
29-
- name: Run Bats
29+
- name: Run system / user tests
3030
commands:
3131
- bats ./test/test.bats
32+
- name: Run restore tests
33+
commands:
3234
- bats ./test/restore.bats
35+
- name: Run config tests
36+
commands:
37+
- bats ./test/config-tests.bats
3338
- name: Run Check PHP
3439
commands:
3540
- ./test/check_php.sh
@@ -65,10 +70,15 @@ steps:
6570
- name: Build Hestia package install
6671
commands:
6772
- ./src/hst_autocompile.sh --hestia --install '~localsrc'
68-
- name: Run Bats
73+
- name: Run system / user tests
6974
commands:
7075
- bats ./test/test.bats
76+
- name: Run restore tests
77+
commands:
7178
- bats ./test/restore.bats
79+
- name: Run config tests
80+
commands:
81+
- bats ./test/config-tests.bats
7282
- name: Run Check PHP
7383
commands:
7484
- ./test/check_php.sh
@@ -78,4 +88,4 @@ trigger:
7888

7989
---
8090
kind: signature
81-
hmac: f3763c63fcebe50a2ad24dc3fb2ab3191cba15750e4dd80be82cea87466d96bc
91+
hmac: bca7f80ac6198662bc658235d7345485213847f1c00f027e1439775e02776bc7

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66
### Features
77

88
- Added v-delete-firewall-ban ip all #2031
9+
- Include config tests for nginx/apache2 templates
910

1011
### Bugfixes
1112

test/config-tests.bats

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bats
2+
3+
if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then
4+
. /etc/profile.d/hestia.sh
5+
fi
6+
7+
load 'test_helper/bats-support/load'
8+
load 'test_helper/bats-assert/load'
9+
load 'test_helper/bats-file/load'
10+
11+
function random() {
12+
head /dev/urandom | tr -dc 0-9 | head -c$1
13+
}
14+
15+
function setup() {
16+
# echo "# Setup_file" > &3
17+
if [ $BATS_TEST_NUMBER = 1 ]; then
18+
echo 'user=test-5285' > /tmp/hestia-test-env.sh
19+
echo 'user2=test-5286' >> /tmp/hestia-test-env.sh
20+
echo 'userbk=testbk-5285' >> /tmp/hestia-test-env.sh
21+
echo 'userpass1=test-5285' >> /tmp/hestia-test-env.sh
22+
echo 'userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
23+
echo 'HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
24+
echo 'domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
25+
echo 'domainuk=test-5285.hestiacp.com.uk' >> /tmp/hestia-test-env.sh
26+
echo 'rootdomain=testhestiacp.com' >> /tmp/hestia-test-env.sh
27+
echo 'subdomain=cdn.testhestiacp.com' >> /tmp/hestia-test-env.sh
28+
echo 'database=test-5285_database' >> /tmp/hestia-test-env.sh
29+
echo 'dbuser=test-5285_dbuser' >> /tmp/hestia-test-env.sh
30+
fi
31+
32+
source /tmp/hestia-test-env.sh
33+
source $HESTIA/func/main.sh
34+
source $HESTIA/conf/hestia.conf
35+
source $HESTIA/func/ip.sh
36+
}
37+
38+
@test "Setup" {
39+
run v-add-user $user $user $user@hestiacp.com default "Super Test"
40+
assert_success
41+
refute_output
42+
43+
run run v-add-web-domain $user 'testhestiacp.com'
44+
assert_success
45+
refute_output
46+
47+
ssl=$(v-generate-ssl-cert "testhestiacp.com" "info@testhestiacp.com" US CA "Orange County" HestiaCP IT "mail.$domain" | tail -n1 | awk '{print $2}')
48+
mv $ssl/testhestiacp.com.crt /tmp/testhestiacp.com.crt
49+
mv $ssl/testhestiacp.com.key /tmp/testhestiacp.com.key
50+
51+
# Use self signed certificates during last test
52+
run v-add-web-domain-ssl $user testhestiacp.com /tmp
53+
assert_success
54+
refute_output
55+
}
56+
57+
@test "Web Config test" {
58+
for template in $(v-list-web-templates plain); do
59+
run v-change-web-domain-tpl $user testhestiacp.com $template
60+
assert_success
61+
refute_output
62+
done
63+
}
64+
65+
@test "Proxy Config test" {
66+
if [ "$PROXY_SYSTEM" = "nginx" ]; then
67+
for template in $(v-list-web-templates plain); do
68+
run v-change-web-domain-proxy-tpl $user testhestiacp.com $template
69+
assert_success
70+
refute_output
71+
done
72+
else
73+
skip "Proxy not installed"
74+
fi
75+
}
76+
77+
@test "Clean up" {
78+
run v-delete-user $user
79+
assert_success
80+
refute_output
81+
}

0 commit comments

Comments
 (0)