Browse Source

Merge pull request #1646 from hestiacp/fix/2021-03-incorrect-handling-dns

Fixed multiple small issues
Raphael Schneeberger 5 years ago
parent
commit
c6d2006655
4 changed files with 16 additions and 206 deletions
  1. 7 2
      bin/v-add-dns-record
  2. 1 3
      bin/v-add-sys-webmail
  3. 1 1
      bin/v-delete-sys-webmail
  4. 7 200
      test/test.bats

+ 7 - 2
bin/v-add-dns-record

@@ -18,10 +18,10 @@
 # Argument definition
 user=$1
 domain=$(idn -t --quiet -a "$2" )
-record=$(idn -t --quiet -a "$3" )
+record=$(idn -t --quiet -u "$3" )
 record=$(echo "$record" | tr '[:upper:]' '[:lower:]')
 rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
-dvalue=$(idn -t --quiet -a "$5" )
+dvalue=$(idn -t --quiet -u "$5" )
 priority=$6
 id=$7
 restart=$8
@@ -49,6 +49,11 @@ if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
     fi
 fi
 
+if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
+    dvalue=$(idn -t --quiet -a "$dvalue" )
+    record=$(idn -t --quiet -a "$record" )
+fi
+
 # Cleanup quotes on dvalue
 # - [CAA] records will be left unchanged
 # - [SRV] will be  stripped of double quotes even when  containg spaces

+ 1 - 3
bin/v-add-sys-webmail

@@ -14,7 +14,7 @@
 
 # Argument definition
 user=$1
-domain=$2
+domain=$(idn -t --quiet -a "$2")
 webmail=$3
 restart="$4"
 quiet=$5
@@ -30,8 +30,6 @@ if [[ "$domain" =~ .*\.$ ]]; then
     domain=$(echo "$domain" |sed -e "s/\.$//")
 fi
 
-domain_idn=$(idn -t --quiet -a "$domain")
-
 # Includes
 source $HESTIA/func/main.sh
 source $HESTIA/func/domain.sh

+ 1 - 1
bin/v-delete-sys-webmail

@@ -14,7 +14,7 @@
 
 # Argument definition
 user=$1
-domain=$2
+domain=$(idn -t --quiet -a "$2")
 restart="$3"
 quiet=$4
 

+ 7 - 200
test/test.bats

@@ -333,7 +333,7 @@ function validate_database(){
 
     run v-add-cron-job $user 1 1 1 1 1 echo 1
     assert_failure $E_EXISTS
-    assert_output --partial 'JOB=1 is already exists'
+    assert_output --partial 'JOB=1 already exists'
 }
 
 @test "Cron: Second cron job" {
@@ -510,6 +510,12 @@ function validate_database(){
     refute_output
 }
 
+@test "WEB: Delete web domain wildcard alias" {
+    run v-delete-web-domain-alias $user $domain "*.$domain"
+    assert_success
+    refute_output
+}
+
 @test "WEB: Add web domain stats" {
     run v-add-web-domain-stats $user $domain awstats
     assert_success
@@ -838,205 +844,6 @@ function validate_database(){
     refute_output
 }
 
-#----------------------------------------------------------#
-#                      MULTIPHP                            #
-#----------------------------------------------------------#
-
-@test "Multiphp: Default php Backend version" {
-    def_phpver=$(multiphp_default_version)
-    multi_domain="multiphp.${domain}"
-
-    run v-add-web-domain $user $multi_domain 198.18.0.125
-    assert_success
-    refute_output
-
-    echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-
-}
-
-@test "Multiphp: Change backend version - PHP v5.6" {
-    test_phpver='5.6'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v7.0" {
-    test_phpver='7.0'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v7.1" {
-    test_phpver='7.1'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v7.2" {
-    test_phpver='7.2'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v7.3" {
-    test_phpver='7.3'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v7.4" {
-    test_phpver='7.4'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-}
-
-@test "Multiphp: Change backend version - PHP v8.0" {
-    test_phpver='8.0'
-    multi_domain="multiphp.${domain}"
-
-    if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
-        skip "PHP ${test_phpver} not installed"
-    fi
-
-    run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
-    assert_success
-    refute_output
-
-    # Changing web backend will create a php-fpm pool config in the corresponding php folder
-    assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
-
-    # A single php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '1'
-
-    echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
-    validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
-    rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
-}
-
-@test "Multiphp: Cleanup" {
-    multi_domain="multiphp.${domain}"
-
-    run v-delete-web-domain $user $multi_domain 'yes'
-    assert_success
-    refute_output
-
-    # No php-fpm pool config file must be present
-    num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
-    assert_equal "$num_fpm_config_files" '0'
-}
-
-
 #----------------------------------------------------------#
 #                         DNS                              #
 #----------------------------------------------------------#