Skip to content

Commit fb12888

Browse files
committed
Add basic tests for IDN
1 parent f406d06 commit fb12888

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/test.bats

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ function validate_web_domain() {
6969
fi
7070

7171
# Test HTTP
72-
run curl --location --silent --show-error --insecure --resolve "${domain}:80:${domain_ip}" "http://${domain}/${webpath}"
72+
# Curl hates UTF domains so convert them to ascci.
73+
domain_idn=$(idn -a $domain)
74+
run curl --location --silent --show-error --insecure --resolve "${domain_idn}:80:${domain_ip}" "http://${domain_idn}/${webpath}"
7375
assert_success
7476
assert_output --partial "$webproof"
7577

@@ -78,7 +80,7 @@ function validate_web_domain() {
7880
run v-list-web-domain-ssl $user $domain
7981
assert_success
8082

81-
run curl --location --silent --show-error --insecure --resolve "${domain}:443:${domain_ip}" "https://${domain}/${webpath}"
83+
run curl --location --silent --show-error --insecure --resolve "${domain_idn}:443:${domain_ip}" "https://${domain_idn}/${webpath}"
8284
assert_success
8385
assert_output --partial "$webproof"
8486
fi
@@ -648,7 +650,35 @@ function validate_database(){
648650
assert_success
649651
refute_output
650652
}
653+
654+
#----------------------------------------------------------#
655+
# ID #
656+
#----------------------------------------------------------#
657+
658+
@test "WEB: Add IDN domain UTF" {
659+
run v-add-web-domain $user idn-tést.eu 198.18.0.125
660+
assert_success
661+
refute_output
662+
663+
echo -e "<?php\necho 'Hestia Test:'.(4*3);" > $HOMEDIR/$user/web/idn-tést.eu/public_html/php-test.php
664+
validate_web_domain $user idn-tést.eu 'Hestia Test:12' 'php-test.php'
665+
rm $HOMEDIR/$user/web/idn-tést.eu/public_html/php-test.php
666+
}
667+
668+
@test "WEB: Add IDN domain ASCII" {
669+
# Expected to fail due to utf exists
670+
run v-add-web-domain $user $( idn -a idn-tést.eu) 198.18.0.125
671+
assert_failure $E_EXISTS
672+
673+
}
674+
675+
@test "WEB: Delete IDN domain" {
676+
run v-delete-web-domain $user idn-tést.eu
677+
assert_success
678+
refute_output
679+
}
651680

681+
652682
#----------------------------------------------------------#
653683
# MULTIPHP #
654684
#----------------------------------------------------------#

0 commit comments

Comments
 (0)