Skip to content

Commit f5077e9

Browse files
authored
Merge pull request hestiacp#1461 from hestiacp/staging/fixes
Staging/fixes
2 parents db51b86 + 971b344 commit f5077e9

File tree

5 files changed

+294
-7
lines changed

5 files changed

+294
-7
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ check_hestia_demo_mode
5252
# Action #
5353
#----------------------------------------------------------#
5454

55-
# Deleting current backend
56-
delete_web_backend
57-
5855
# Prepare new backend configuration
5956
prepare_web_backend
6057

58+
# Deleting current backend
59+
delete_web_backend
60+
6161
# Allocating backend port
6262
backend_port=9000
6363
ports=$(grep -v '^;' $pool/* 2>/dev/null |grep listen |grep -o :[0-9].*)

src/deb/nginx/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Source: hestia-nginx
22
Package: hestia-nginx
33
Priority: optional
4-
Version: 1.19.4
4+
Version: 1.19.5
55
Section: admin
66
Maintainer: HestiaCP <info@hestiacp.com>
77
Homepage: https://www.hestiacp.com

src/deb/php/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Source: hestia-php
22
Package: hestia-php
33
Priority: optional
4-
Version: 7.4.12
4+
Version: 7.4.13
55
Section: admin
66
Maintainer: HestaCP <info@hestiacp.com>
77
Homepage: https://www.hestiacp.com

src/hst_autocompile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fi
9090

9191
BUILD_ARCH='amd64'
9292
HESTIA_V="${BUILD_VER}_${BUILD_ARCH}"
93-
OPENSSL_V='1.1.1g'
93+
OPENSSL_V='1.1.1i'
9494
PCRE_V='8.44'
9595
ZLIB_V='1.2.11'
9696

test/test.bats

Lines changed: 288 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ function validate_web_domain() {
4747
domain_ip=$(get_real_ip "$domain_ip")
4848

4949
if [ ! -z $webpath ]; then
50-
assert_file_exist $HOMEDIR/$user/web/$domain/public_html/$webpath
50+
domain_docroot=$(get_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT')
51+
if [ -n "$domain_docroot" ] && [ -d "$domain_docroot" ]; then
52+
assert_file_exist "${domain_docroot}/${webpath}"
53+
else
54+
assert_file_exist "${HOMEDIR}/${user}/web/${domain}/public_html/${webpath}"
55+
fi
5156
fi
5257

5358
# Test HTTP
@@ -506,6 +511,288 @@ function validate_webmail_domain() {
506511
}
507512

508513

514+
#----------------------------------------------------------#
515+
# MULTIPHP #
516+
#----------------------------------------------------------#
517+
518+
@test "Multiphp: Default php Backend version" {
519+
def_phpver=$(multiphp_default_version)
520+
multi_domain="multiphp.${domain}"
521+
522+
run v-add-web-domain $user $multi_domain 198.18.0.125
523+
assert_success
524+
refute_output
525+
526+
echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
527+
validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
528+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
529+
530+
}
531+
532+
@test "Multiphp: Change backend version - PHP v5.6" {
533+
test_phpver='5.6'
534+
multi_domain="multiphp.${domain}"
535+
536+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
537+
skip "PHP ${test_phpver} not installed"
538+
fi
539+
540+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
541+
assert_success
542+
refute_output
543+
544+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
545+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
546+
547+
# A single php-fpm pool config file must be present
548+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
549+
assert_equal "$num_fpm_config_files" '1'
550+
551+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
552+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
553+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
554+
}
555+
556+
@test "Multiphp: Change backend version - PHP v7.0" {
557+
test_phpver='7.0'
558+
multi_domain="multiphp.${domain}"
559+
560+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
561+
skip "PHP ${test_phpver} not installed"
562+
fi
563+
564+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
565+
assert_success
566+
refute_output
567+
568+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
569+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
570+
571+
# A single php-fpm pool config file must be present
572+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
573+
assert_equal "$num_fpm_config_files" '1'
574+
575+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
576+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
577+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
578+
}
579+
580+
@test "Multiphp: Change backend version - PHP v7.1" {
581+
test_phpver='7.1'
582+
multi_domain="multiphp.${domain}"
583+
584+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
585+
skip "PHP ${test_phpver} not installed"
586+
fi
587+
588+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
589+
assert_success
590+
refute_output
591+
592+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
593+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
594+
595+
# A single php-fpm pool config file must be present
596+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
597+
assert_equal "$num_fpm_config_files" '1'
598+
599+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
600+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
601+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
602+
}
603+
604+
@test "Multiphp: Change backend version - PHP v7.2" {
605+
test_phpver='7.2'
606+
multi_domain="multiphp.${domain}"
607+
608+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
609+
skip "PHP ${test_phpver} not installed"
610+
fi
611+
612+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
613+
assert_success
614+
refute_output
615+
616+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
617+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
618+
619+
# A single php-fpm pool config file must be present
620+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
621+
assert_equal "$num_fpm_config_files" '1'
622+
623+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
624+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
625+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
626+
}
627+
628+
@test "Multiphp: Change backend version - PHP v7.3" {
629+
test_phpver='7.3'
630+
multi_domain="multiphp.${domain}"
631+
632+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
633+
skip "PHP ${test_phpver} not installed"
634+
fi
635+
636+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
637+
assert_success
638+
refute_output
639+
640+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
641+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
642+
643+
# A single php-fpm pool config file must be present
644+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
645+
assert_equal "$num_fpm_config_files" '1'
646+
647+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
648+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
649+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
650+
}
651+
652+
@test "Multiphp: Change backend version - PHP v7.4" {
653+
test_phpver='7.4'
654+
multi_domain="multiphp.${domain}"
655+
656+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
657+
skip "PHP ${test_phpver} not installed"
658+
fi
659+
660+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
661+
assert_success
662+
refute_output
663+
664+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
665+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
666+
667+
# A single php-fpm pool config file must be present
668+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
669+
assert_equal "$num_fpm_config_files" '1'
670+
671+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
672+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
673+
rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
674+
}
675+
676+
@test "Multiphp: Change backend version - PHP v8.0" {
677+
test_phpver='8.0'
678+
multi_domain="multiphp.${domain}"
679+
680+
if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
681+
skip "PHP ${test_phpver} not installed"
682+
fi
683+
684+
run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
685+
assert_success
686+
refute_output
687+
688+
# Changing web backend will create a php-fpm pool config in the corresponding php folder
689+
assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
690+
691+
# A single php-fpm pool config file must be present
692+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
693+
assert_equal "$num_fpm_config_files" '1'
694+
695+
echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
696+
validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
697+
rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
698+
}
699+
700+
@test "Multiphp: Cleanup" {
701+
multi_domain="multiphp.${domain}"
702+
703+
run v-delete-web-domain $user $multi_domain 'yes'
704+
assert_success
705+
refute_output
706+
707+
# No php-fpm pool config file must be present
708+
num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
709+
assert_equal "$num_fpm_config_files" '0'
710+
}
711+
712+
713+
#----------------------------------------------------------#
714+
# CUSTOM DOCROOT #
715+
#----------------------------------------------------------#
716+
717+
@test "Docroot: Self Subfolder" {
718+
docroot1_domain="docroot1.${domain}"
719+
720+
run v-add-web-domain $user $docroot1_domain 198.18.0.125
721+
assert_success
722+
refute_output
723+
724+
run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/"
725+
assert_success
726+
refute_output
727+
728+
run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot1_domain" "/public"
729+
assert_success
730+
refute_output
731+
732+
echo -e '<?php\necho "self-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
733+
validate_web_domain $user $docroot1_domain "self-sub-${docroot1_domain}" 'php-test.php'
734+
rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
735+
}
736+
737+
@test "Docroot: Other domain subfolder" {
738+
docroot1_domain="docroot1.${domain}"
739+
docroot2_domain="docroot2.${domain}"
740+
741+
run v-add-web-domain $user $docroot2_domain 198.18.0.125
742+
assert_success
743+
refute_output
744+
745+
run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/"
746+
assert_success
747+
refute_output
748+
749+
run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain" "/public"
750+
assert_success
751+
refute_output
752+
753+
echo -e '<?php\necho "doc2-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
754+
validate_web_domain $user $docroot1_domain "doc2-sub-${docroot1_domain}" 'php-test.php'
755+
rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
756+
}
757+
758+
@test "Docroot: Other domain root folder" {
759+
docroot1_domain="docroot1.${domain}"
760+
docroot2_domain="docroot2.${domain}"
761+
762+
run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain"
763+
assert_success
764+
refute_output
765+
766+
echo -e '<?php\necho "doc2-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
767+
validate_web_domain $user $docroot1_domain "doc2-root-${docroot1_domain}" 'php-test.php'
768+
rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
769+
}
770+
771+
@test "Docroot: Reset" {
772+
docroot1_domain="docroot1.${domain}"
773+
774+
run v-change-web-domain-docroot $user "$docroot1_domain" "default"
775+
assert_success
776+
refute_output
777+
778+
echo -e '<?php\necho "doc1-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
779+
validate_web_domain $user $docroot1_domain "doc1-root-${docroot1_domain}" 'php-test.php'
780+
rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
781+
}
782+
783+
@test "Docroot: Cleanup" {
784+
docroot1_domain="docroot1.${domain}"
785+
docroot2_domain="docroot2.${domain}"
786+
787+
run v-delete-web-domain $user $docroot1_domain
788+
assert_success
789+
refute_output
790+
791+
run v-delete-web-domain $user $docroot2_domain
792+
assert_success
793+
refute_output
794+
}
795+
509796
#----------------------------------------------------------#
510797
# DNS #
511798
#----------------------------------------------------------#

0 commit comments

Comments
 (0)