Răsfoiți Sursa

Merge pull request #1461 from hestiacp/staging/fixes

Staging/fixes
Raphael Schneeberger 5 ani în urmă
părinte
comite
f5077e9c69

+ 3 - 3
bin/v-change-web-domain-backend-tpl

@@ -52,12 +52,12 @@ check_hestia_demo_mode
 #                       Action                             #
 #----------------------------------------------------------#
 
-# Deleting current backend
-delete_web_backend
-
 # Prepare new backend configuration
 prepare_web_backend
 
+# Deleting current backend
+delete_web_backend
+
 # Allocating backend port
 backend_port=9000
 ports=$(grep -v '^;' $pool/* 2>/dev/null |grep listen |grep -o :[0-9].*)

+ 1 - 1
src/deb/nginx/control

@@ -1,7 +1,7 @@
 Source: hestia-nginx
 Package: hestia-nginx
 Priority: optional
-Version: 1.19.4
+Version: 1.19.5
 Section: admin
 Maintainer: HestiaCP <[email protected]>
 Homepage: https://www.hestiacp.com

+ 1 - 1
src/deb/php/control

@@ -1,7 +1,7 @@
 Source: hestia-php
 Package: hestia-php
 Priority: optional
-Version: 7.4.12
+Version: 7.4.13
 Section: admin
 Maintainer: HestaCP <[email protected]>
 Homepage: https://www.hestiacp.com

+ 1 - 1
src/hst_autocompile.sh

@@ -90,7 +90,7 @@ fi
 
 BUILD_ARCH='amd64'
 HESTIA_V="${BUILD_VER}_${BUILD_ARCH}"
-OPENSSL_V='1.1.1g'
+OPENSSL_V='1.1.1i'
 PCRE_V='8.44'
 ZLIB_V='1.2.11'
 

+ 288 - 1
test/test.bats

@@ -47,7 +47,12 @@ function validate_web_domain() {
     domain_ip=$(get_real_ip "$domain_ip")
 
     if [ ! -z $webpath ]; then
-        assert_file_exist $HOMEDIR/$user/web/$domain/public_html/$webpath
+        domain_docroot=$(get_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT')
+        if [ -n "$domain_docroot" ] && [ -d "$domain_docroot" ]; then
+            assert_file_exist "${domain_docroot}/${webpath}"
+        else
+            assert_file_exist "${HOMEDIR}/${user}/web/${domain}/public_html/${webpath}"
+        fi
     fi
 
     # Test HTTP
@@ -506,6 +511,288 @@ function validate_webmail_domain() {
 }
 
 
+#----------------------------------------------------------#
+#                      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'
+}
+
+
+#----------------------------------------------------------#
+#                     CUSTOM DOCROOT                       #
+#----------------------------------------------------------#
+
+@test "Docroot: Self Subfolder" {
+    docroot1_domain="docroot1.${domain}"
+
+    run v-add-web-domain $user $docroot1_domain 198.18.0.125
+    assert_success
+    refute_output
+
+    run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/"
+    assert_success
+    refute_output
+
+    run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot1_domain" "/public"
+    assert_success
+    refute_output
+
+    echo -e '<?php\necho "self-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
+    validate_web_domain $user $docroot1_domain "self-sub-${docroot1_domain}" 'php-test.php'
+    rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
+}
+
+@test "Docroot: Other domain subfolder" {
+    docroot1_domain="docroot1.${domain}"
+    docroot2_domain="docroot2.${domain}"
+
+    run v-add-web-domain $user $docroot2_domain 198.18.0.125
+    assert_success
+    refute_output
+
+    run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/"
+    assert_success
+    refute_output
+
+    run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain" "/public"
+    assert_success
+    refute_output
+
+    echo -e '<?php\necho "doc2-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
+    validate_web_domain $user $docroot1_domain "doc2-sub-${docroot1_domain}" 'php-test.php'
+    rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
+}
+
+@test "Docroot: Other domain root folder" {
+    docroot1_domain="docroot1.${domain}"
+    docroot2_domain="docroot2.${domain}"
+
+    run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain"
+    assert_success
+    refute_output
+
+    echo -e '<?php\necho "doc2-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
+    validate_web_domain $user $docroot1_domain "doc2-root-${docroot1_domain}" 'php-test.php'
+    rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
+}
+
+@test "Docroot: Reset" {
+    docroot1_domain="docroot1.${domain}"
+
+    run v-change-web-domain-docroot $user "$docroot1_domain" "default"
+    assert_success
+    refute_output
+
+    echo -e '<?php\necho "doc1-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
+    validate_web_domain $user $docroot1_domain "doc1-root-${docroot1_domain}" 'php-test.php'
+    rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
+}
+
+@test "Docroot: Cleanup" {
+    docroot1_domain="docroot1.${domain}"
+    docroot2_domain="docroot2.${domain}"
+
+    run v-delete-web-domain $user $docroot1_domain
+    assert_success
+    refute_output
+
+    run v-delete-web-domain $user $docroot2_domain
+    assert_success
+    refute_output
+}
+
 #----------------------------------------------------------#
 #                         DNS                              #
 #----------------------------------------------------------#