@@ -13,11 +13,14 @@ function setup() {
1313 # echo "# Setup_file" > &3
1414 if [ $BATS_TEST_NUMBER = 1 ]; then
1515 echo ' user=test-5285' > /tmp/hestia-test-env.sh
16+ echo ' user2=test-5286' >> /tmp/hestia-test-env.sh
1617 echo ' userbk=testbk-5285' >> /tmp/hestia-test-env.sh
1718 echo ' userpass1=test-5285' >> /tmp/hestia-test-env.sh
1819 echo ' userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
1920 echo ' HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
2021 echo ' domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
22+ echo ' rootdomain=testhestiacp.com' >> /tmp/hestia-test-env.sh
23+ echo ' subdomain=cdn.testhestiacp.com' >> /tmp/hestia-test-env.sh
2124 echo ' database=test-5285_database' >> /tmp/hestia-test-env.sh
2225 echo ' dbuser=test-5285_dbuser' >> /tmp/hestia-test-env.sh
2326 fi
@@ -552,8 +555,7 @@ function validate_database(){
552555 assert_success
553556 refute_output
554557}
555-
556-
558+
557559# ----------------------------------------------------------#
558560# MULTIPHP #
559561# ----------------------------------------------------------#
@@ -941,6 +943,114 @@ function validate_database(){
941943 assert_failure $E_NOTEXIST
942944}
943945
946+ # ----------------------------------------------------------#
947+ # Limit possibilities adding different owner domain #
948+ # ----------------------------------------------------------#
949+
950+ @test " Allow Users: User can't add user.user2.com " {
951+ # Case: admin company.ltd
952+ # users should not be allowed to add user.company.ltd
953+ run v-add-user $user2 $user2 $user @hestiacp.com default " Super Test"
954+ assert_success
955+ refute_output
956+
957+ run v-add-web-domain $user2 $rootdomain
958+ assert_success
959+ refute_output
960+
961+ run v-add-web-domain $user $subdomain
962+ assert_failure $E_EXISTS
963+ }
964+
965+ @test " Allow Users: User can't add user.user2.com as alias" {
966+ run v-add-web-domain-alias $user $domain $subdomain
967+ assert_failure $E_EXISTS
968+ }
969+
970+ @test " Allow Users: User can't add user.user2.com as mail domain" {
971+ run v-add-mail-domain $user $subdomain
972+ assert_failure $E_EXISTS
973+ }
974+
975+ @test " Allow Users: User can't add user.user2.com as dns domain" {
976+ run v-add-dns-domain $user $subdomain 198.18.0.125
977+ assert_failure $E_EXISTS
978+ }
979+
980+ @test " Allow Users: Set Allow users" {
981+ # Allow user to yes allows
982+ # Case: admin company.ltd
983+ # users are allowed to add user.company.ltd
984+ run v-add-web-domain-allow-users $user2 $rootdomain
985+ assert_success
986+ refute_output
987+ }
988+
989+ @test " Allow Users: User can add user.user2.com" {
990+ run v-add-web-domain $user $subdomain
991+ assert_success
992+ refute_output
993+ }
994+
995+ @test " Allow Users: User can add user.user2.com as alias" {
996+ run v-delete-web-domain $user $subdomain
997+ assert_success
998+ refute_output
999+
1000+ run v-add-web-domain-alias $user $domain $subdomain
1001+ assert_success
1002+ refute_output
1003+ }
1004+
1005+ @test " Allow Users: User can add user.user2.com as mail domain" {
1006+ run v-add-mail-domain $user $subdomain
1007+ assert_success
1008+ refute_output
1009+ }
1010+
1011+ @test " Allow Users: User can add user.user2.com as dns domain" {
1012+ run v-add-dns-domain $user $subdomain 198.18.0.125
1013+ assert_success
1014+ refute_output
1015+ }
1016+
1017+ @test " Allow Users: Cleanup tests" {
1018+ run v-delete-dns-domain $user $subdomain
1019+ assert_success
1020+ refute_output
1021+
1022+ run v-delete-mail-domain $user $subdomain
1023+ assert_success
1024+ refute_output
1025+ }
1026+
1027+
1028+ @test " Allow Users: Set Allow users no" {
1029+ run v-delete-web-domain-alias $user $domain $subdomain
1030+ assert_success
1031+ refute_output
1032+
1033+ run v-delete-web-domain-allow-users $user2 $rootdomain
1034+ assert_success
1035+ refute_output
1036+ }
1037+
1038+ @test " Allow Users: User can't add user.user2.com again" {
1039+ run v-add-web-domain $user $subdomain
1040+ assert_failure $E_EXISTS
1041+ }
1042+
1043+ @test " Allow Users: user2 can add user.user2.com again" {
1044+ run v-add-web-domain $user2 $subdomain
1045+ assert_success
1046+ refute_output
1047+
1048+ run v-delete-user $user2
1049+ assert_success
1050+ refute_output
1051+ }
1052+
1053+
9441054
9451055# ----------------------------------------------------------#
9461056# DB #
0 commit comments