Skip to content

Commit 91d93ba

Browse files
committed
Testing: add mail/webmail test
1 parent 44feea1 commit 91d93ba

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

test/test.bats

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ function validate_web_domain() {
5656
assert_file_exist $HOMEDIR/$user/web/$domain/public_html/$webpath
5757
fi
5858

59-
refute [ -z "$webproof" ]
60-
6159
# Test HTTP
6260
run curl --location --silent --show-error --insecure --resolve "${domain}:80:${domain_ip}" "http://${domain}/${webpath}"
6361
assert_success
@@ -74,6 +72,73 @@ function validate_web_domain() {
7472
fi
7573
}
7674

75+
function validate_mail_domain() {
76+
local user=$1
77+
local domain=$2
78+
79+
refute [ -z "$user" ]
80+
refute [ -z "$domain" ]
81+
82+
run v-list-mail-domain $user $domain
83+
assert_success
84+
85+
assert_dir_exist $HOMEDIR/$user/mail/$domain
86+
assert_dir_exist $HOMEDIR/$user/conf/mail/$domain
87+
88+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/aliases
89+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/antispam
90+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/antivirus
91+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/fwd_only
92+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/ip
93+
assert_file_exist $HOMEDIR/$user/conf/mail/$domain/passwd
94+
}
95+
96+
function validate_webmail_domain() {
97+
local user=$1
98+
local domain=$2
99+
local webproof=$3
100+
local webpath=${4}
101+
102+
refute [ -z "$user" ]
103+
refute [ -z "$domain" ]
104+
refute [ -z "$webproof" ]
105+
106+
source $HESTIA/func/ip.sh
107+
108+
USER_DATA=$HESTIA/data/users/$user
109+
local domain_ip=$(get_object_value 'web' 'DOMAIN' "$domain" '$IP')
110+
SSL=$(get_object_value 'mail' 'DOMAIN' "$domain" '$SSL')
111+
domain_ip=$(get_real_ip "$domain_ip")
112+
113+
if [ ! -z "$webpath" ]; then
114+
assert_file_exist /var/lib/roundcube/$webpath
115+
fi
116+
117+
# Test HTTP
118+
run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:80:${domain_ip}" "http://webmail.${domain}/${webpath}"
119+
assert_success
120+
assert_output --partial "$webproof"
121+
122+
# Test HTTP
123+
run curl --location --silent --show-error --insecure --resolve "mail.${domain}:80:${domain_ip}" "http://mail.${domain}/${webpath}"
124+
assert_success
125+
assert_output --partial "$webproof"
126+
127+
# Test HTTPS
128+
if [ "$SSL" = "yes" ]; then
129+
run v-list-mail-domain-ssl $user $domain
130+
assert_success
131+
132+
run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:443:${domain_ip}" "https://webmail.${domain}/${webpath}"
133+
assert_success
134+
assert_output --partial "$webproof"
135+
136+
run curl --location --silent --show-error --insecure --resolve "mail.${domain}:443:${domain_ip}" "https://mail.${domain}/${webpath}"
137+
assert_success
138+
assert_output --partial "$webproof"
139+
fi
140+
}
141+
77142
#----------------------------------------------------------#
78143
# MAIN #
79144
#----------------------------------------------------------#
@@ -511,6 +576,12 @@ function validate_web_domain() {
511576
run v-add-mail-domain $user $domain
512577
assert_success
513578
refute_output
579+
580+
validate_mail_domain $user $domain
581+
582+
# echo -e "<?php\necho 'Server: ' . \$_SERVER['SERVER_SOFTWARE'];" > /var/lib/roundcube/check_server.php
583+
validate_webmail_domain $user $domain 'Welcome to Roundcube Webmail'
584+
# rm /var/lib/roundcube/check_server.php
514585
}
515586

516587
@test "MAIL: Add domain (duplicate)" {

0 commit comments

Comments
 (0)