Skip to content

Commit 1c7831c

Browse files
committed
Update bats to include multiple tests
- Add mail domain webmail client (Roundcube) - Mail: Add SSL to mail domain - Change webmail client to Roundcube (When installed) - MAIL: Disable webmail client - MAIL: Rebuild mail domain
1 parent 3e7fb13 commit 1c7831c

File tree

1 file changed

+66
-28
lines changed

1 file changed

+66
-28
lines changed

test/test.bats

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function setup() {
2323
echo 'userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
2424
echo 'HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
2525
echo 'domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
26+
echo 'domainuk=test-5285.hestiacp.com.uk' >> /tmp/hestia-test-env.sh
2627
echo 'rootdomain=testhestiacp.com' >> /tmp/hestia-test-env.sh
2728
echo 'subdomain=cdn.testhestiacp.com' >> /tmp/hestia-test-env.sh
2829
echo 'database=test-5285_database' >> /tmp/hestia-test-env.sh
@@ -121,26 +122,38 @@ function validate_webmail_domain() {
121122
if [ ! -z "$webpath" ]; then
122123
assert_file_exist /var/lib/roundcube/$webpath
123124
fi
124-
125-
# Test HTTP
126-
run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:80:${domain_ip}" "http://webmail.${domain}/${webpath}"
127-
assert_success
128-
assert_output --partial "$webproof"
129-
130-
# Test HTTP
131-
run curl --location --silent --show-error --insecure --resolve "mail.${domain}:80:${domain_ip}" "http://mail.${domain}/${webpath}"
132-
assert_success
133-
assert_output --partial "$webproof"
125+
126+
if [ "$SSL" = "no" ]; then
127+
# Test HTTP
128+
run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:80:${domain_ip}" "http://webmail.${domain}/${webpath}"
129+
assert_success
130+
assert_output --partial "$webproof"
131+
132+
# Test HTTP
133+
run curl --location --silent --show-error --insecure --resolve "mail.${domain}:80:${domain_ip}" "http://mail.${domain}/${webpath}"
134+
assert_success
135+
assert_output --partial "$webproof"
136+
fi
134137

135138
# Test HTTPS
136139
if [ "$SSL" = "yes" ]; then
137-
run v-list-mail-domain-ssl $user $domain
140+
# Test HTTP with 301 redirect for some reasons due to 301 redirect it fails
141+
run curl --silent --show-error --insecure --resolve "webmail.${domain}:80:${domain_ip}" "http://webmail.${domain}/${webpath}"
138142
assert_success
143+
assert_output --partial "301 Moved Permanently"
139144

145+
# Test HTTP with 301 redirect for some reasons due to 301 redirect it fails
146+
run curl --silent --show-error --insecure --resolve "mail.${domain}:80:${domain_ip}" "http://mail.${domain}/${webpath}"
147+
assert_success
148+
assert_output --partial "301 Moved Permanently"
149+
150+
run v-list-mail-domain-ssl $user $domain
151+
assert_success
152+
140153
run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:443:${domain_ip}" "https://webmail.${domain}/${webpath}"
141154
assert_success
142155
assert_output --partial "$webproof"
143-
156+
144157
run curl --location --silent --show-error --insecure --resolve "mail.${domain}:443:${domain_ip}" "https://mail.${domain}/${webpath}"
145158
assert_success
146159
assert_output --partial "$webproof"
@@ -183,17 +196,6 @@ function validate_database(){
183196
rm -f "$tmpfile"
184197
}
185198

186-
#----------------------------------------------------------#
187-
# MAIN #
188-
#----------------------------------------------------------#
189-
190-
@test "Add new userXXX" {
191-
skip
192-
run v-add-user $user $user $user@hestiacp.com default "Super Test"
193-
assert_success
194-
refute_output
195-
}
196-
197199
#----------------------------------------------------------#
198200
# IP #
199201
#----------------------------------------------------------#
@@ -918,20 +920,52 @@ function validate_database(){
918920
run v-add-mail-domain $user $domain
919921
assert_success
920922
refute_output
923+
924+
validate_mail_domain $user $domain
921925
}
922926

923927
@test "MAIL: Add mail domain webmail client" {
924-
skip
925-
run v-add-mail-domain-webmail $user $domain "rouncube"
928+
run v-add-mail-domain-webmail $user $domain "roundcube" "yes"
926929
assert_success
927930
refute_output
928-
validate_mail_domain $user $domain
929931

930932
# echo -e "<?php\necho 'Server: ' . \$_SERVER['SERVER_SOFTWARE'];" > /var/lib/roundcube/check_server.php
931933
validate_webmail_domain $user $domain 'Welcome to Roundcube Webmail'
932934
# rm /var/lib/roundcube/check_server.php
933935
}
934936

937+
@test "Mail: Add SSL to mail domain" {
938+
cp -f $HESTIA/ssl/certificate.crt /tmp/$domain.crt
939+
cp -f $HESTIA/ssl/certificate.key /tmp/$domain.key
940+
941+
run v-add-mail-domain-ssl $user $domain /tmp
942+
assert_success
943+
refute_output
944+
945+
validate_webmail_domain $user $domain 'Welcome to Roundcube Webmail'
946+
}
947+
948+
@test "MAIL: Add mail domain webmail client (Rainloop)" {
949+
if [ -z "$(echo $WEBMAIL_SYSTEM | grep -w "rainloop")" ]; then
950+
skip "Webmail client Rainloop not installed"
951+
fi
952+
run v-add-mail-domain-webmail $user $domain "rainloop" "yes"
953+
assert_success
954+
refute_output
955+
validate_mail_domain $user $domain
956+
957+
validate_webmail_domain $user $domain 'RainLoop Webmail'
958+
}
959+
960+
@test "MAIL: Disable webmail client" {
961+
run v-add-mail-domain-webmail $user $domain "disabled" "yes"
962+
assert_success
963+
refute_output
964+
validate_mail_domain $user $domain
965+
966+
validate_webmail_domain $user $domain 'Success!'
967+
}
968+
935969
@test "MAIL: Add domain (duplicate)" {
936970
run v-add-mail-domain $user $domain
937971
assert_failure $E_EXISTS
@@ -959,6 +993,12 @@ function validate_database(){
959993
assert_failure $E_NOTEXIST
960994
}
961995

996+
@test "MAIL: Rebuild mail domain" {
997+
run v-rebuild-mail-domains $user
998+
assert_success
999+
refute_output
1000+
}
1001+
9621002
#----------------------------------------------------------#
9631003
# Limit possibilities adding different owner domain #
9641004
#----------------------------------------------------------#
@@ -1066,8 +1106,6 @@ function validate_database(){
10661106
refute_output
10671107
}
10681108

1069-
1070-
10711109
#----------------------------------------------------------#
10721110
# DB #
10731111
#----------------------------------------------------------#

0 commit comments

Comments
 (0)