Skip to content

Commit 66d9ce4

Browse files
committed
Config test Nginx + Apache2
1 parent aa2fd58 commit 66d9ce4

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

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-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)