test.bats 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810
  1. #!/usr/bin/env bats
  2. load 'test_helper/bats-support/load'
  3. load 'test_helper/bats-assert/load'
  4. load 'test_helper/bats-file/load'
  5. function random() {
  6. head /dev/urandom | tr -dc 0-9 | head -c$1
  7. }
  8. function setup() {
  9. # echo "# Setup_file" > &3
  10. if [ $BATS_TEST_NUMBER = 1 ]; then
  11. echo 'user=test-5285' > /tmp/hestia-test-env.sh
  12. echo 'user2=test-5286' >> /tmp/hestia-test-env.sh
  13. echo 'userbk=testbk-5285' >> /tmp/hestia-test-env.sh
  14. echo 'userpass1=test-5285' >> /tmp/hestia-test-env.sh
  15. echo 'userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
  16. echo 'HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
  17. echo 'domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
  18. echo 'rootdomain=testhestiacp.com' >> /tmp/hestia-test-env.sh
  19. echo 'subdomain=cdn.testhestiacp.com' >> /tmp/hestia-test-env.sh
  20. echo 'database=test-5285_database' >> /tmp/hestia-test-env.sh
  21. echo 'dbuser=test-5285_dbuser' >> /tmp/hestia-test-env.sh
  22. fi
  23. source /tmp/hestia-test-env.sh
  24. source $HESTIA/func/main.sh
  25. source $HESTIA/conf/hestia.conf
  26. source $HESTIA/func/ip.sh
  27. }
  28. function validate_web_domain() {
  29. local user=$1
  30. local domain=$2
  31. local webproof=$3
  32. local webpath=${4}
  33. refute [ -z "$user" ]
  34. refute [ -z "$domain" ]
  35. refute [ -z "$webproof" ]
  36. source $HESTIA/func/ip.sh
  37. run v-list-web-domain $user $domain
  38. assert_success
  39. USER_DATA=$HESTIA/data/users/$user
  40. local domain_ip=$(get_object_value 'web' 'DOMAIN' "$domain" '$IP')
  41. SSL=$(get_object_value 'web' 'DOMAIN' "$domain" '$SSL')
  42. domain_ip=$(get_real_ip "$domain_ip")
  43. if [ ! -z $webpath ]; then
  44. domain_docroot=$(get_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT')
  45. if [ -n "$domain_docroot" ] && [ -d "$domain_docroot" ]; then
  46. assert_file_exist "${domain_docroot}/${webpath}"
  47. else
  48. assert_file_exist "${HOMEDIR}/${user}/web/${domain}/public_html/${webpath}"
  49. fi
  50. fi
  51. # Test HTTP
  52. run curl --location --silent --show-error --insecure --resolve "${domain}:80:${domain_ip}" "http://${domain}/${webpath}"
  53. assert_success
  54. assert_output --partial "$webproof"
  55. # Test HTTPS
  56. if [ "$SSL" = "yes" ]; then
  57. run v-list-web-domain-ssl $user $domain
  58. assert_success
  59. run curl --location --silent --show-error --insecure --resolve "${domain}:443:${domain_ip}" "https://${domain}/${webpath}"
  60. assert_success
  61. assert_output --partial "$webproof"
  62. fi
  63. }
  64. function validate_mail_domain() {
  65. local user=$1
  66. local domain=$2
  67. refute [ -z "$user" ]
  68. refute [ -z "$domain" ]
  69. run v-list-mail-domain $user $domain
  70. assert_success
  71. assert_dir_exist $HOMEDIR/$user/mail/$domain
  72. assert_dir_exist $HOMEDIR/$user/conf/mail/$domain
  73. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/aliases
  74. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/antispam
  75. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/antivirus
  76. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/fwd_only
  77. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/ip
  78. assert_file_exist $HOMEDIR/$user/conf/mail/$domain/passwd
  79. }
  80. function validate_webmail_domain() {
  81. local user=$1
  82. local domain=$2
  83. local webproof=$3
  84. local webpath=${4}
  85. refute [ -z "$user" ]
  86. refute [ -z "$domain" ]
  87. refute [ -z "$webproof" ]
  88. source $HESTIA/func/ip.sh
  89. USER_DATA=$HESTIA/data/users/$user
  90. local domain_ip=$(get_object_value 'web' 'DOMAIN' "$domain" '$IP')
  91. SSL=$(get_object_value 'mail' 'DOMAIN' "$domain" '$SSL')
  92. domain_ip=$(get_real_ip "$domain_ip")
  93. if [ ! -z "$webpath" ]; then
  94. assert_file_exist /var/lib/roundcube/$webpath
  95. fi
  96. # Test HTTP
  97. run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:80:${domain_ip}" "http://webmail.${domain}/${webpath}"
  98. assert_success
  99. assert_output --partial "$webproof"
  100. # Test HTTP
  101. run curl --location --silent --show-error --insecure --resolve "mail.${domain}:80:${domain_ip}" "http://mail.${domain}/${webpath}"
  102. assert_success
  103. assert_output --partial "$webproof"
  104. # Test HTTPS
  105. if [ "$SSL" = "yes" ]; then
  106. run v-list-mail-domain-ssl $user $domain
  107. assert_success
  108. run curl --location --silent --show-error --insecure --resolve "webmail.${domain}:443:${domain_ip}" "https://webmail.${domain}/${webpath}"
  109. assert_success
  110. assert_output --partial "$webproof"
  111. run curl --location --silent --show-error --insecure --resolve "mail.${domain}:443:${domain_ip}" "https://mail.${domain}/${webpath}"
  112. assert_success
  113. assert_output --partial "$webproof"
  114. fi
  115. }
  116. function validate_database(){
  117. local database=$1
  118. local dbuser=$2
  119. local password=$3
  120. host_str=$(grep "HOST='localhost'" $HESTIA/conf/mysql.conf)
  121. parse_object_kv_list "$host_str"
  122. if [ -z $PORT ]; then PORT=3306; fi
  123. refute [ -z "$HOST" ]
  124. refute [ -z "$PORT" ]
  125. refute [ -z "$database" ]
  126. refute [ -z "$dbuser" ]
  127. refute [ -z "$password" ]
  128. # Create an connection to verify correct username / password has been set correctly
  129. tmpfile=$(mktemp /tmp/mysql.XXXXXX)
  130. echo "[client]">$tmpfile
  131. echo "host='$HOST'" >> $tmpfile
  132. echo "user='$dbuser'" >> $tmpfile
  133. echo "password='$password'" >> $tmpfile
  134. echo "port='$PORT'" >> $tmpfile
  135. chmod 600 $tmpfile
  136. sql_tmp=$(mktemp /tmp/query.XXXXXX)
  137. echo "show databases;" > $sql_tmp
  138. run mysql --defaults-file=$tmpfile < "$sql_tmp"
  139. assert_success
  140. assert_output --partial "$database"
  141. rm -f "$sql_tmp"
  142. rm -f "$tmpfile"
  143. }
  144. #----------------------------------------------------------#
  145. # MAIN #
  146. #----------------------------------------------------------#
  147. @test "Add new userXXX" {
  148. skip
  149. run v-add-user $user $user [email protected] default "Super Test"
  150. assert_success
  151. refute_output
  152. }
  153. #----------------------------------------------------------#
  154. # IP #
  155. #----------------------------------------------------------#
  156. @test "Check reverse Dns validation" {
  157. # 1. PTR record for a IP should return a hostname(reverse) which in turn must resolve to the same IP addr(forward). (Full circle)
  158. # `-> not implemented in `is_ip_rdns_valid` yet and also not tested here
  159. # 2. Reject rPTR records that match generic dynamic IP pool patterns
  160. local ip="54.200.1.22"
  161. local rdns="ec2-54-200-1-22.us-west-2.compute.amazonaws.com"
  162. run is_ip_rdns_valid "$ip"
  163. assert_failure
  164. refute_output
  165. local rdns="ec2.54.200.1.22.us-west-2.compute.amazonaws.com"
  166. run is_ip_rdns_valid "$ip"
  167. assert_failure
  168. refute_output
  169. local rdns="ec2-22-1-200-54.us-west-2.compute.amazonaws.com"
  170. run is_ip_rdns_valid "$ip"
  171. assert_failure
  172. refute_output
  173. local rdns="ec2.22.1.200.54.us-west-2.compute.amazonaws.com"
  174. run is_ip_rdns_valid "$ip"
  175. assert_failure
  176. refute_output
  177. local rdns="ec2-200-54-1-22.us-west-2.compute.amazonaws.com"
  178. run is_ip_rdns_valid "$ip"
  179. assert_failure
  180. refute_output
  181. local rdns="panel-22.mydomain.tld"
  182. run is_ip_rdns_valid "$ip"
  183. assert_success
  184. assert_output "$rdns"
  185. local rdns="mail.mydomain.tld"
  186. run is_ip_rdns_valid "$ip"
  187. assert_success
  188. assert_output "$rdns"
  189. local rdns="mydomain.tld"
  190. run is_ip_rdns_valid "$ip"
  191. assert_success
  192. assert_output "$rdns"
  193. }
  194. #----------------------------------------------------------#
  195. # User #
  196. #----------------------------------------------------------#
  197. @test "Add new user" {
  198. run v-add-user $user $user [email protected] default "Super Test"
  199. assert_success
  200. refute_output
  201. }
  202. @test "Change user password" {
  203. run v-change-user-password "$user" t3st-p4ssw0rd
  204. assert_success
  205. refute_output
  206. }
  207. @test "Change user email" {
  208. run v-change-user-contact "$user" [email protected]
  209. assert_success
  210. refute_output
  211. }
  212. @test "Change user contact invalid email " {
  213. run v-change-user-contact "$user" testerhestiacp.com
  214. assert_failure $E_INVALID
  215. assert_output --partial 'Error: invalid email format'
  216. }
  217. @test "Change user name" {
  218. run v-change-user-name "$user" "New name"
  219. assert_success
  220. refute_output
  221. }
  222. @test "Change user shell" {
  223. run v-change-user-shell $user bash
  224. assert_success
  225. refute_output
  226. }
  227. @test "Change user invalid shell" {
  228. run v-change-user-shell $user bashinvalid
  229. assert_failure $E_INVALID
  230. assert_output --partial 'shell bashinvalid is not valid'
  231. }
  232. @test "Change user default ns" {
  233. run v-change-user-ns $user ns0.com ns1.com ns2.com ns3.com
  234. assert_success
  235. refute_output
  236. run v-list-user-ns "$user" plain
  237. assert_success
  238. assert_output --partial 'ns0.com'
  239. }
  240. #----------------------------------------------------------#
  241. # Cron #
  242. #----------------------------------------------------------#
  243. @test "Cron: Add cron job" {
  244. run v-add-cron-job $user 1 1 1 1 1 echo
  245. assert_success
  246. refute_output
  247. }
  248. @test "Cron: Suspend cron job" {
  249. run v-suspend-cron-job $user 1
  250. assert_success
  251. refute_output
  252. }
  253. @test "Cron: Unsuspend cron job" {
  254. run v-unsuspend-cron-job $user 1
  255. assert_success
  256. refute_output
  257. }
  258. @test "Cron: Delete cron job" {
  259. run v-delete-cron-job $user 1
  260. assert_success
  261. refute_output
  262. }
  263. @test "Cron: Add cron job (duplicate)" {
  264. run v-add-cron-job $user 1 1 1 1 1 echo 1
  265. assert_success
  266. refute_output
  267. run v-add-cron-job $user 1 1 1 1 1 echo 1
  268. assert_failure $E_EXISTS
  269. assert_output --partial 'JOB=1 is already exists'
  270. }
  271. @test "Cron: Second cron job" {
  272. run v-add-cron-job $user 2 2 2 2 2 echo 2
  273. assert_success
  274. refute_output
  275. }
  276. @test "Cron: Two cron jobs must be listed" {
  277. run v-list-cron-jobs $user csv
  278. assert_success
  279. assert_line --partial '1,1,1,1,1,"echo",no'
  280. assert_line --partial '2,2,2,2,2,"echo",no'
  281. }
  282. @test "Cron: rebuild" {
  283. run v-rebuild-cron-jobs $user
  284. assert_success
  285. refute_output
  286. }
  287. #----------------------------------------------------------#
  288. # IP #
  289. #----------------------------------------------------------#
  290. @test "Ip: Add new ip on first interface" {
  291. interface=$(v-list-sys-interfaces plain | head -n 1)
  292. run ip link show dev $interface
  293. assert_success
  294. local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
  295. local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
  296. # Save initial state
  297. echo "interface=${interface}" >> /tmp/hestia-test-env.sh
  298. [ -f "$a2_rpaf" ] && file_hash1=$(cat $a2_rpaf |md5sum |cut -d" " -f1) && echo "a2_rpaf_hash='${file_hash1}'" >> /tmp/hestia-test-env.sh
  299. [ -f "$a2_remoteip" ] && file_hash2=$(cat $a2_remoteip |md5sum |cut -d" " -f1) && echo "a2_remoteip_hash='${file_hash2}'" >> /tmp/hestia-test-env.sh
  300. local ip="198.18.0.12"
  301. run v-add-sys-ip $ip 255.255.255.255 $interface $user
  302. assert_success
  303. refute_output
  304. assert_file_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
  305. assert_file_exist $HESTIA/data/ips/$ip
  306. assert_file_contains $HESTIA/data/ips/$ip "OWNER='$user'"
  307. assert_file_contains $HESTIA/data/ips/$ip "INTERFACE='$interface'"
  308. if [ -n "$PROXY_SYSTEM" ]; then
  309. assert_file_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
  310. [ -f "$a2_rpaf" ] && assert_file_contains "$a2_rpaf" "RPAFproxy_ips.*$ip\b"
  311. [ -f "$a2_remoteip" ] && assert_file_contains "$a2_remoteip" "RemoteIPInternalProxy $ip\$"
  312. fi
  313. }
  314. @test "Ip: Add ip (duplicate)" {
  315. run v-add-sys-ip 198.18.0.12 255.255.255.255 $interface $user
  316. assert_failure $E_EXISTS
  317. }
  318. @test "Ip: Add extra ip" {
  319. local ip="198.18.0.121"
  320. run v-add-sys-ip $ip 255.255.255.255 $interface $user
  321. assert_success
  322. refute_output
  323. assert_file_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
  324. assert_file_exist $HESTIA/data/ips/$ip
  325. assert_file_contains $HESTIA/data/ips/$ip "OWNER='$user'"
  326. assert_file_contains $HESTIA/data/ips/$ip "INTERFACE='$interface'"
  327. if [ -n "$PROXY_SYSTEM" ]; then
  328. assert_file_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
  329. local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
  330. [ -f "$a2_rpaf" ] && assert_file_contains "$a2_rpaf" "RPAFproxy_ips.*$ip\b"
  331. local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
  332. [ -f "$a2_remoteip" ] && assert_file_contains "$a2_remoteip" "RemoteIPInternalProxy $ip\$"
  333. fi
  334. }
  335. @test "Ip: Delete ips" {
  336. local ip="198.18.0.12"
  337. run v-delete-sys-ip $ip
  338. assert_success
  339. refute_output
  340. assert_file_not_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
  341. assert_file_not_exist $HESTIA/data/ips/$ip
  342. ip="198.18.0.121"
  343. run v-delete-sys-ip $ip
  344. assert_success
  345. refute_output
  346. assert_file_not_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
  347. assert_file_not_exist $HESTIA/data/ips/$ip
  348. if [ -n "$PROXY_SYSTEM" ]; then
  349. assert_file_not_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
  350. fi
  351. # remoteip and rpaf config hashes must match the initial one
  352. if [ ! -z "$a2_rpaf_hash" ]; then
  353. local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
  354. file_hash=$(cat $a2_rpaf |md5sum |cut -d" " -f1)
  355. assert_equal "$file_hash" "$a2_rpaf_hash"
  356. fi
  357. if [ ! -z "$a2_remoteip_hash" ]; then
  358. local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
  359. file_hash=$(cat $a2_remoteip |md5sum |cut -d" " -f1)
  360. assert_equal "$file_hash" "$a2_remoteip_hash"
  361. fi
  362. }
  363. @test "Ip: Add IP for rest of the test" {
  364. local ip="198.18.0.125"
  365. run v-add-sys-ip $ip 255.255.255.255 $interface $user
  366. assert_success
  367. refute_output
  368. assert_file_exist /etc/$WEB_SYSTEM/conf.d/$ip.conf
  369. assert_file_exist $HESTIA/data/ips/$ip
  370. assert_file_contains $HESTIA/data/ips/$ip "OWNER='$user'"
  371. assert_file_contains $HESTIA/data/ips/$ip "INTERFACE='$interface'"
  372. if [ -n "$PROXY_SYSTEM" ]; then
  373. assert_file_exist /etc/$PROXY_SYSTEM/conf.d/$ip.conf
  374. local a2_rpaf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
  375. [ -f "$a2_rpaf" ] && assert_file_contains "$a2_rpaf" "RPAFproxy_ips.*$ip\b"
  376. local a2_remoteip="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
  377. [ -f "$a2_remoteip" ] && assert_file_contains "$a2_remoteip" "RemoteIPInternalProxy $ip\$"
  378. fi
  379. }
  380. #----------------------------------------------------------#
  381. # WEB #
  382. #----------------------------------------------------------#
  383. @test "WEB: Add web domain" {
  384. run v-add-web-domain $user $domain 198.18.0.125
  385. assert_success
  386. refute_output
  387. echo -e "<?php\necho 'Hestia Test:'.(4*3);" > $HOMEDIR/$user/web/$domain/public_html/php-test.php
  388. validate_web_domain $user $domain 'Hestia Test:12' 'php-test.php'
  389. rm $HOMEDIR/$user/web/$domain/public_html/php-test.php
  390. }
  391. @test "WEB: Add web domain (duplicate)" {
  392. run v-add-web-domain $user $domain 198.18.0.125
  393. assert_failure $E_EXISTS
  394. }
  395. @test "WEB: Add web domain alias" {
  396. run v-add-web-domain-alias $user $domain v3.$domain
  397. assert_success
  398. refute_output
  399. }
  400. @test "WEB: Add web domain alias (duplicate)" {
  401. run v-add-web-domain-alias $user $domain v3.$domain
  402. assert_failure $E_EXISTS
  403. }
  404. @test "WEB: Add web domain wildcard alias" {
  405. run v-add-web-domain-alias $user $domain "*.$domain"
  406. assert_success
  407. refute_output
  408. }
  409. @test "WEB: Add web domain stats" {
  410. run v-add-web-domain-stats $user $domain awstats
  411. assert_success
  412. refute_output
  413. }
  414. @test "WEB: Add web domain stats user" {
  415. skip
  416. run v-add-web-domain-stats-user $user $domain test m3g4p4ssw0rd
  417. assert_success
  418. refute_output
  419. }
  420. @test "WEB: Suspend web domain" {
  421. run v-suspend-web-domain $user $domain
  422. assert_success
  423. refute_output
  424. validate_web_domain $user $domain 'This site is currently suspended'
  425. }
  426. @test "WEB: Unsuspend web domain" {
  427. run v-unsuspend-web-domain $user $domain
  428. assert_success
  429. refute_output
  430. echo -e "<?php\necho 'Hestia Test:'.(4*3);" > $HOMEDIR/$user/web/$domain/public_html/php-test.php
  431. validate_web_domain $user $domain 'Hestia Test:12' 'php-test.php'
  432. rm $HOMEDIR/$user/web/$domain/public_html/php-test.php
  433. }
  434. @test "WEB: Add ssl" {
  435. cp -f $HESTIA/ssl/certificate.crt /tmp/$domain.crt
  436. cp -f $HESTIA/ssl/certificate.key /tmp/$domain.key
  437. run v-add-web-domain-ssl $user $domain /tmp
  438. assert_success
  439. refute_output
  440. }
  441. @test "WEB: Rebuild web domain" {
  442. run v-rebuild-web-domains $user
  443. assert_success
  444. refute_output
  445. }
  446. #----------------------------------------------------------#
  447. # MULTIPHP #
  448. #----------------------------------------------------------#
  449. @test "Multiphp: Default php Backend version" {
  450. def_phpver=$(multiphp_default_version)
  451. multi_domain="multiphp.${domain}"
  452. run v-add-web-domain $user $multi_domain 198.18.0.125
  453. assert_success
  454. refute_output
  455. echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  456. validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
  457. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  458. }
  459. @test "Multiphp: Change backend version - PHP v5.6" {
  460. test_phpver='5.6'
  461. multi_domain="multiphp.${domain}"
  462. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  463. skip "PHP ${test_phpver} not installed"
  464. fi
  465. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
  466. assert_success
  467. refute_output
  468. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  469. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  470. # A single php-fpm pool config file must be present
  471. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  472. assert_equal "$num_fpm_config_files" '1'
  473. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  474. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  475. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  476. }
  477. @test "Multiphp: Change backend version - PHP v7.0" {
  478. test_phpver='7.0'
  479. multi_domain="multiphp.${domain}"
  480. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  481. skip "PHP ${test_phpver} not installed"
  482. fi
  483. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
  484. assert_success
  485. refute_output
  486. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  487. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  488. # A single php-fpm pool config file must be present
  489. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  490. assert_equal "$num_fpm_config_files" '1'
  491. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  492. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  493. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  494. }
  495. @test "Multiphp: Change backend version - PHP v7.1" {
  496. test_phpver='7.1'
  497. multi_domain="multiphp.${domain}"
  498. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  499. skip "PHP ${test_phpver} not installed"
  500. fi
  501. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
  502. assert_success
  503. refute_output
  504. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  505. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  506. # A single php-fpm pool config file must be present
  507. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  508. assert_equal "$num_fpm_config_files" '1'
  509. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  510. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  511. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  512. }
  513. @test "Multiphp: Change backend version - PHP v7.2" {
  514. test_phpver='7.2'
  515. multi_domain="multiphp.${domain}"
  516. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  517. skip "PHP ${test_phpver} not installed"
  518. fi
  519. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
  520. assert_success
  521. refute_output
  522. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  523. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  524. # A single php-fpm pool config file must be present
  525. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  526. assert_equal "$num_fpm_config_files" '1'
  527. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  528. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  529. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  530. }
  531. @test "Multiphp: Change backend version - PHP v7.3" {
  532. test_phpver='7.3'
  533. multi_domain="multiphp.${domain}"
  534. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  535. skip "PHP ${test_phpver} not installed"
  536. fi
  537. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
  538. assert_success
  539. refute_output
  540. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  541. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  542. # A single php-fpm pool config file must be present
  543. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  544. assert_equal "$num_fpm_config_files" '1'
  545. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  546. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  547. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  548. }
  549. @test "Multiphp: Change backend version - PHP v7.4" {
  550. test_phpver='7.4'
  551. multi_domain="multiphp.${domain}"
  552. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  553. skip "PHP ${test_phpver} not installed"
  554. fi
  555. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
  556. assert_success
  557. refute_output
  558. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  559. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  560. # A single php-fpm pool config file must be present
  561. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  562. assert_equal "$num_fpm_config_files" '1'
  563. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  564. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  565. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  566. }
  567. @test "Multiphp: Change backend version - PHP v8.0" {
  568. test_phpver='8.0'
  569. multi_domain="multiphp.${domain}"
  570. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  571. skip "PHP ${test_phpver} not installed"
  572. fi
  573. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
  574. assert_success
  575. refute_output
  576. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  577. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  578. # A single php-fpm pool config file must be present
  579. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  580. assert_equal "$num_fpm_config_files" '1'
  581. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  582. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  583. rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
  584. }
  585. @test "Multiphp: Cleanup" {
  586. multi_domain="multiphp.${domain}"
  587. run v-delete-web-domain $user $multi_domain 'yes'
  588. assert_success
  589. refute_output
  590. # No php-fpm pool config file must be present
  591. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  592. assert_equal "$num_fpm_config_files" '0'
  593. }
  594. #----------------------------------------------------------#
  595. # CUSTOM DOCROOT #
  596. #----------------------------------------------------------#
  597. @test "Docroot: Self Subfolder" {
  598. docroot1_domain="docroot1.${domain}"
  599. run v-add-web-domain $user $docroot1_domain 198.18.0.125
  600. assert_success
  601. refute_output
  602. run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/"
  603. assert_success
  604. refute_output
  605. run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot1_domain" "/public"
  606. assert_success
  607. refute_output
  608. echo -e '<?php\necho "self-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
  609. validate_web_domain $user $docroot1_domain "self-sub-${docroot1_domain}" 'php-test.php'
  610. rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/public/php-test.php"
  611. }
  612. @test "Docroot: Other domain subfolder" {
  613. docroot1_domain="docroot1.${domain}"
  614. docroot2_domain="docroot2.${domain}"
  615. run v-add-web-domain $user $docroot2_domain 198.18.0.125
  616. assert_success
  617. refute_output
  618. run v-add-fs-directory $user "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/"
  619. assert_success
  620. refute_output
  621. run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain" "/public"
  622. assert_success
  623. refute_output
  624. echo -e '<?php\necho "doc2-sub-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
  625. validate_web_domain $user $docroot1_domain "doc2-sub-${docroot1_domain}" 'php-test.php'
  626. rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/public/php-test.php"
  627. }
  628. @test "Docroot: Other domain root folder" {
  629. docroot1_domain="docroot1.${domain}"
  630. docroot2_domain="docroot2.${domain}"
  631. run v-change-web-domain-docroot $user "$docroot1_domain" "$docroot2_domain"
  632. assert_success
  633. refute_output
  634. echo -e '<?php\necho "doc2-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
  635. validate_web_domain $user $docroot1_domain "doc2-root-${docroot1_domain}" 'php-test.php'
  636. rm "$HOMEDIR/$user/web/$docroot2_domain/public_html/php-test.php"
  637. }
  638. @test "Docroot: Reset" {
  639. docroot1_domain="docroot1.${domain}"
  640. run v-change-web-domain-docroot $user "$docroot1_domain" "default"
  641. assert_success
  642. refute_output
  643. echo -e '<?php\necho "doc1-root-".$_SERVER["HTTP_HOST"];' > "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
  644. validate_web_domain $user $docroot1_domain "doc1-root-${docroot1_domain}" 'php-test.php'
  645. rm "$HOMEDIR/$user/web/$docroot1_domain/public_html/php-test.php"
  646. }
  647. @test "Docroot: Cleanup" {
  648. docroot1_domain="docroot1.${domain}"
  649. docroot2_domain="docroot2.${domain}"
  650. run v-delete-web-domain $user $docroot1_domain
  651. assert_success
  652. refute_output
  653. run v-delete-web-domain $user $docroot2_domain
  654. assert_success
  655. refute_output
  656. }
  657. #----------------------------------------------------------#
  658. # MULTIPHP #
  659. #----------------------------------------------------------#
  660. @test "Multiphp: Default php Backend version" {
  661. def_phpver=$(multiphp_default_version)
  662. multi_domain="multiphp.${domain}"
  663. run v-add-web-domain $user $multi_domain 198.18.0.125
  664. assert_success
  665. refute_output
  666. echo -e "<?php\necho PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  667. validate_web_domain $user $multi_domain "$def_phpver" 'php-test.php'
  668. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  669. }
  670. @test "Multiphp: Change backend version - PHP v5.6" {
  671. test_phpver='5.6'
  672. multi_domain="multiphp.${domain}"
  673. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  674. skip "PHP ${test_phpver} not installed"
  675. fi
  676. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-5_6' 'yes'
  677. assert_success
  678. refute_output
  679. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  680. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  681. # A single php-fpm pool config file must be present
  682. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  683. assert_equal "$num_fpm_config_files" '1'
  684. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  685. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  686. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  687. }
  688. @test "Multiphp: Change backend version - PHP v7.0" {
  689. test_phpver='7.0'
  690. multi_domain="multiphp.${domain}"
  691. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  692. skip "PHP ${test_phpver} not installed"
  693. fi
  694. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_0' 'yes'
  695. assert_success
  696. refute_output
  697. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  698. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  699. # A single php-fpm pool config file must be present
  700. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  701. assert_equal "$num_fpm_config_files" '1'
  702. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  703. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  704. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  705. }
  706. @test "Multiphp: Change backend version - PHP v7.1" {
  707. test_phpver='7.1'
  708. multi_domain="multiphp.${domain}"
  709. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  710. skip "PHP ${test_phpver} not installed"
  711. fi
  712. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_1' 'yes'
  713. assert_success
  714. refute_output
  715. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  716. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  717. # A single php-fpm pool config file must be present
  718. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  719. assert_equal "$num_fpm_config_files" '1'
  720. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  721. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  722. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  723. }
  724. @test "Multiphp: Change backend version - PHP v7.2" {
  725. test_phpver='7.2'
  726. multi_domain="multiphp.${domain}"
  727. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  728. skip "PHP ${test_phpver} not installed"
  729. fi
  730. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_2' 'yes'
  731. assert_success
  732. refute_output
  733. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  734. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  735. # A single php-fpm pool config file must be present
  736. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  737. assert_equal "$num_fpm_config_files" '1'
  738. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  739. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  740. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  741. }
  742. @test "Multiphp: Change backend version - PHP v7.3" {
  743. test_phpver='7.3'
  744. multi_domain="multiphp.${domain}"
  745. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  746. skip "PHP ${test_phpver} not installed"
  747. fi
  748. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_3' 'yes'
  749. assert_success
  750. refute_output
  751. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  752. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  753. # A single php-fpm pool config file must be present
  754. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  755. assert_equal "$num_fpm_config_files" '1'
  756. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  757. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  758. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  759. }
  760. @test "Multiphp: Change backend version - PHP v7.4" {
  761. test_phpver='7.4'
  762. multi_domain="multiphp.${domain}"
  763. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  764. skip "PHP ${test_phpver} not installed"
  765. fi
  766. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-7_4' 'yes'
  767. assert_success
  768. refute_output
  769. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  770. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  771. # A single php-fpm pool config file must be present
  772. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  773. assert_equal "$num_fpm_config_files" '1'
  774. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  775. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  776. rm "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  777. }
  778. @test "Multiphp: Change backend version - PHP v8.0" {
  779. test_phpver='8.0'
  780. multi_domain="multiphp.${domain}"
  781. if [ ! -d "/etc/php/${test_phpver}/fpm/pool.d/" ]; then
  782. skip "PHP ${test_phpver} not installed"
  783. fi
  784. run v-change-web-domain-backend-tpl $user $multi_domain 'PHP-8_0' 'yes'
  785. assert_success
  786. refute_output
  787. # Changing web backend will create a php-fpm pool config in the corresponding php folder
  788. assert_file_exist "/etc/php/${test_phpver}/fpm/pool.d/${multi_domain}.conf"
  789. # A single php-fpm pool config file must be present
  790. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  791. assert_equal "$num_fpm_config_files" '1'
  792. echo -e "<?php\necho 'hestia-multiphptest:'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;" > "$HOMEDIR/$user/web/$multi_domain/public_html/php-test.php"
  793. validate_web_domain $user $multi_domain "hestia-multiphptest:$test_phpver" 'php-test.php'
  794. rm $HOMEDIR/$user/web/$multi_domain/public_html/php-test.php
  795. }
  796. @test "Multiphp: Cleanup" {
  797. multi_domain="multiphp.${domain}"
  798. run v-delete-web-domain $user $multi_domain 'yes'
  799. assert_success
  800. refute_output
  801. # No php-fpm pool config file must be present
  802. num_fpm_config_files="$(find -L /etc/php/ -name "${multi_domain}.conf" | wc -l)"
  803. assert_equal "$num_fpm_config_files" '0'
  804. }
  805. #----------------------------------------------------------#
  806. # DNS #
  807. #----------------------------------------------------------#
  808. @test "DNS: Add domain" {
  809. run v-add-dns-domain $user $domain 198.18.0.125
  810. assert_success
  811. refute_output
  812. }
  813. @test "DNS: Add domain (duplicate)" {
  814. run v-add-dns-domain $user $domain 198.18.0.125
  815. assert_failure $E_EXISTS
  816. }
  817. @test "DNS: Add domain record" {
  818. run v-add-dns-record $user $domain test A 198.18.0.125 20
  819. assert_success
  820. refute_output
  821. }
  822. @test "DNS: Delete domain record" {
  823. run v-delete-dns-record $user $domain 20
  824. assert_success
  825. refute_output
  826. }
  827. @test "DNS: Delete missing domain record" {
  828. run v-delete-dns-record $user $domain 20
  829. assert_failure $E_NOTEXIST
  830. }
  831. @test "DNS: Change domain expire date" {
  832. run v-change-dns-domain-exp $user $domain 2020-01-01
  833. assert_success
  834. refute_output
  835. }
  836. @test "DNS: Change domain ip" {
  837. run v-change-dns-domain-ip $user $domain 127.0.0.1
  838. assert_success
  839. refute_output
  840. }
  841. @test "DNS: Suspend domain" {
  842. run v-suspend-dns-domain $user $domain
  843. assert_success
  844. refute_output
  845. }
  846. @test "DNS: Unsuspend domain" {
  847. run v-unsuspend-dns-domain $user $domain
  848. assert_success
  849. refute_output
  850. }
  851. @test "DNS: Rebuild" {
  852. run v-rebuild-dns-domains $user
  853. assert_success
  854. refute_output
  855. }
  856. #----------------------------------------------------------#
  857. # MAIL #
  858. #----------------------------------------------------------#
  859. @test "MAIL: Add domain" {
  860. run v-add-mail-domain $user $domain
  861. assert_success
  862. refute_output
  863. validate_mail_domain $user $domain
  864. # echo -e "<?php\necho 'Server: ' . \$_SERVER['SERVER_SOFTWARE'];" > /var/lib/roundcube/check_server.php
  865. validate_webmail_domain $user $domain 'Welcome to Roundcube Webmail'
  866. # rm /var/lib/roundcube/check_server.php
  867. }
  868. @test "MAIL: Add domain (duplicate)" {
  869. run v-add-mail-domain $user $domain
  870. assert_failure $E_EXISTS
  871. }
  872. @test "MAIL: Add account" {
  873. run v-add-mail-account $user $domain test t3st-p4ssw0rd
  874. assert_success
  875. refute_output
  876. }
  877. @test "MAIL: Add account (duplicate)" {
  878. run v-add-mail-account $user $domain test t3st-p4ssw0rd
  879. assert_failure $E_EXISTS
  880. }
  881. @test "MAIL: Delete account" {
  882. run v-delete-mail-account $user $domain test
  883. assert_success
  884. refute_output
  885. }
  886. @test "MAIL: Delete missing account" {
  887. run v-delete-mail-account $user $domain test
  888. assert_failure $E_NOTEXIST
  889. }
  890. #----------------------------------------------------------#
  891. # Limit possibilities adding different owner domain #
  892. #----------------------------------------------------------#
  893. @test "Allow Users: User can't add user.user2.com " {
  894. # Case: admin company.ltd
  895. # users should not be allowed to add user.company.ltd
  896. run v-add-user $user2 $user2 [email protected] default "Super Test"
  897. assert_success
  898. refute_output
  899. run v-add-web-domain $user2 $rootdomain
  900. assert_success
  901. refute_output
  902. run v-add-web-domain $user $subdomain
  903. assert_failure $E_EXISTS
  904. }
  905. @test "Allow Users: User can't add user.user2.com as alias" {
  906. run v-add-web-domain-alias $user $domain $subdomain
  907. assert_failure $E_EXISTS
  908. }
  909. @test "Allow Users: User can't add user.user2.com as mail domain" {
  910. run v-add-mail-domain $user $subdomain
  911. assert_failure $E_EXISTS
  912. }
  913. @test "Allow Users: User can't add user.user2.com as dns domain" {
  914. run v-add-dns-domain $user $subdomain 198.18.0.125
  915. assert_failure $E_EXISTS
  916. }
  917. @test "Allow Users: Set Allow users" {
  918. # Allow user to yes allows
  919. # Case: admin company.ltd
  920. # users are allowed to add user.company.ltd
  921. run v-add-web-domain-allow-users $user2 $rootdomain
  922. assert_success
  923. refute_output
  924. }
  925. @test "Allow Users: User can add user.user2.com" {
  926. run v-add-web-domain $user $subdomain
  927. assert_success
  928. refute_output
  929. }
  930. @test "Allow Users: User can add user.user2.com as alias" {
  931. run v-delete-web-domain $user $subdomain
  932. assert_success
  933. refute_output
  934. run v-add-web-domain-alias $user $domain $subdomain
  935. assert_success
  936. refute_output
  937. }
  938. @test "Allow Users: User can add user.user2.com as mail domain" {
  939. run v-add-mail-domain $user $subdomain
  940. assert_success
  941. refute_output
  942. }
  943. @test "Allow Users: User can add user.user2.com as dns domain" {
  944. run v-add-dns-domain $user $subdomain 198.18.0.125
  945. assert_success
  946. refute_output
  947. }
  948. @test "Allow Users: Cleanup tests" {
  949. run v-delete-dns-domain $user $subdomain
  950. assert_success
  951. refute_output
  952. run v-delete-mail-domain $user $subdomain
  953. assert_success
  954. refute_output
  955. }
  956. @test "Allow Users: Set Allow users no" {
  957. run v-delete-web-domain-alias $user $domain $subdomain
  958. assert_success
  959. refute_output
  960. run v-delete-web-domain-allow-users $user2 $rootdomain
  961. assert_success
  962. refute_output
  963. }
  964. @test "Allow Users: User can't add user.user2.com again" {
  965. run v-add-web-domain $user $subdomain
  966. assert_failure $E_EXISTS
  967. }
  968. @test "Allow Users: user2 can add user.user2.com again" {
  969. run v-add-web-domain $user2 $subdomain
  970. assert_success
  971. refute_output
  972. run v-delete-user $user2
  973. assert_success
  974. refute_output
  975. }
  976. #----------------------------------------------------------#
  977. # DB #
  978. #----------------------------------------------------------#
  979. @test "DB: Add database (mysql)" {
  980. run v-add-database $user database dbuser 1234 mysql
  981. assert_success
  982. refute_output
  983. # validate_database database_name database_user password
  984. validate_database $database $dbuser 1234
  985. }
  986. @test "DB: Add Database (mysql) (Duplicate)" {
  987. run v-add-database $user database dbuser 1234 mysql
  988. assert_failure $E_EXISTS
  989. }
  990. @test "DB: Rebuild Database (mysql)" {
  991. run v-rebuild-database $user $database
  992. assert_success
  993. refute_output
  994. }
  995. @test "DB: Change database user password (mysql)" {
  996. run v-change-database-password $user $database 123456
  997. assert_success
  998. refute_output
  999. validate_database $database $dbuser 123456
  1000. }
  1001. @test "DB: Change database user (mysql)" {
  1002. run v-change-database-user $user $database database
  1003. assert_success
  1004. refute_output
  1005. validate_database $database $database 123456
  1006. }
  1007. @test "DB: Suspend database" {
  1008. run v-suspend-database $user $database
  1009. assert_success
  1010. refute_output
  1011. }
  1012. @test "DB: Unsuspend database" {
  1013. run v-unsuspend-database $user $database
  1014. assert_success
  1015. refute_output
  1016. }
  1017. @test "DB: Delete database" {
  1018. run v-delete-database $user $database
  1019. assert_success
  1020. refute_output
  1021. }
  1022. @test "DB: Delete missing database" {
  1023. run v-delete-database $user $database
  1024. assert_failure $E_NOTEXIST
  1025. }
  1026. #----------------------------------------------------------#
  1027. # Backup / Restore #
  1028. #----------------------------------------------------------#
  1029. #Test backup
  1030. # Hestia v1.1.1 archive contains:
  1031. # user: hestia111
  1032. # web:
  1033. # - test.hestia.com (+SSL self-signed)
  1034. # dns:
  1035. # - test.hestia.com
  1036. # mail:
  1037. # - test.hestia.com
  1038. # mail acc:
  1039. # - [email protected]
  1040. # db:
  1041. # - hestia111_db
  1042. # cron:
  1043. # - 1: /bin/true
  1044. # Hestia 1.3.1 archive contains (As zstd format)
  1045. # user: hestia131
  1046. # web:
  1047. # - test.hestia.com (+SSL self-signed)
  1048. # dns:
  1049. # - test.hestia.com
  1050. # mail:
  1051. # - test.hestia.com
  1052. # mail acc:
  1053. # - [email protected]
  1054. # db:
  1055. # - hestia131_db
  1056. # cron:
  1057. # - 1: /bin/true
  1058. # Vesta 0.9.8-23 archive contains:
  1059. # user: vesta09823
  1060. # web:
  1061. # - vesta09823.tld (+SSL self-signed)
  1062. # dns:
  1063. # - vesta09823.tld
  1064. # mail:
  1065. # - vesta09823.tld
  1066. # mail acc:
  1067. # - [email protected]
  1068. # db:
  1069. # - vesta09823_db
  1070. # cron:
  1071. # - 1: /bin/true
  1072. #
  1073. # Testing Hestia backups
  1074. @test "Restore[1]: Hestia archive for a non-existing user" {
  1075. if [ -d "$HOMEDIR/$userbk" ]; then
  1076. run v-delete-user $userbk
  1077. assert_success
  1078. refute_output
  1079. fi
  1080. mkdir -p /backup
  1081. local archive_name="hestia111.2020-03-26"
  1082. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1083. assert_success
  1084. run v-restore-user $userbk "${archive_name}.tar"
  1085. assert_success
  1086. rm "/backup/${archive_name}.tar"
  1087. }
  1088. @test "Restore[1]: From Hestia [WEB]" {
  1089. local domain="test.hestia.com"
  1090. validate_web_domain $userbk $domain 'Hello Hestia'
  1091. }
  1092. @test "Restore[1]: From Hestia [DNS]" {
  1093. local domain="test.hestia.com"
  1094. run v-list-dns-domain $userbk $domain
  1095. assert_success
  1096. run nslookup $domain 127.0.0.1
  1097. assert_success
  1098. }
  1099. @test "Restore[1]: From Hestia [MAIL]" {
  1100. local domain="test.hestia.com"
  1101. run v-list-mail-domain $userbk $domain
  1102. assert_success
  1103. }
  1104. @test "Restore[1]: From Hestia [MAIL-Account]" {
  1105. local domain="test.hestia.com"
  1106. run v-list-mail-account $userbk $domain testaccount
  1107. assert_success
  1108. }
  1109. @test "Restore[1]: From Hestia [DB]" {
  1110. run v-list-database $userbk "${userbk}_db"
  1111. assert_success
  1112. }
  1113. @test "Restore[1]: From Hestia [CRON]" {
  1114. run v-list-cron-job $userbk 1
  1115. assert_success
  1116. }
  1117. @test "Restore[1]: From Hestia Cleanup" {
  1118. run v-delete-user $userbk
  1119. assert_success
  1120. refute_output
  1121. }
  1122. @test "Restore[2]: Hestia archive over a existing user" {
  1123. if [ -d "$HOMEDIR/$userbk" ]; then
  1124. run v-delete-user $userbk
  1125. assert_success
  1126. refute_output
  1127. fi
  1128. if [ ! -d "$HOMEDIR/$userbk" ]; then
  1129. run v-add-user $userbk $userbk [email protected]
  1130. assert_success
  1131. fi
  1132. mkdir -p /backup
  1133. local archive_name="hestia111.2020-03-26"
  1134. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1135. assert_success
  1136. run v-restore-user $userbk "${archive_name}.tar"
  1137. assert_success
  1138. rm "/backup/${archive_name}.tar"
  1139. }
  1140. @test "Restore[2]: From Hestia [WEB]" {
  1141. local domain="test.hestia.com"
  1142. validate_web_domain $userbk "${domain}" 'Hello Hestia'
  1143. }
  1144. @test "Restore[2]: From Hestia [DNS]" {
  1145. local domain="test.hestia.com"
  1146. run v-list-dns-domain $userbk $domain
  1147. assert_success
  1148. run nslookup $domain 127.0.0.1
  1149. assert_success
  1150. }
  1151. @test "Restore[2]: From Hestia [MAIL]" {
  1152. local domain="test.hestia.com"
  1153. run v-list-mail-domain $userbk $domain
  1154. assert_success
  1155. }
  1156. @test "Restore[2]: From Hestia [MAIL-Account]" {
  1157. local domain="test.hestia.com"
  1158. run v-list-mail-account $userbk $domain testaccount
  1159. assert_success
  1160. }
  1161. @test "Restore[2]: From Hestia [DB]" {
  1162. run v-list-database $userbk "${userbk}_db"
  1163. assert_success
  1164. }
  1165. @test "Restore[2]: From Hestia [CRON]" {
  1166. run v-list-cron-job $userbk 1
  1167. assert_success
  1168. }
  1169. @test "Restore[2]: From Hestia Cleanup" {
  1170. run v-delete-user $userbk
  1171. assert_success
  1172. refute_output
  1173. }
  1174. @test "Restore[3]: Hestia (zstd) archive for a non-existing user" {
  1175. if [ -d "$HOMEDIR/$userbk" ]; then
  1176. run v-delete-user $userbk
  1177. assert_success
  1178. refute_output
  1179. fi
  1180. mkdir -p /backup
  1181. local archive_name="hestia131.2020-12-12"
  1182. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1183. assert_success
  1184. run v-restore-user $userbk "${archive_name}.tar"
  1185. assert_success
  1186. rm "/backup/${archive_name}.tar"
  1187. }
  1188. @test "Restore[3]: From Hestia [WEB]" {
  1189. local domain="test.hestia.com"
  1190. validate_web_domain $userbk $domain 'Hello Hestia'
  1191. }
  1192. @test "Restore[3]: From Hestia [DNS]" {
  1193. local domain="test.hestia.com"
  1194. run v-list-dns-domain $userbk $domain
  1195. assert_success
  1196. run nslookup $domain 127.0.0.1
  1197. assert_success
  1198. }
  1199. @test "Restore[3]: From Hestia [MAIL]" {
  1200. local domain="test.hestia.com"
  1201. run v-list-mail-domain $userbk $domain
  1202. assert_success
  1203. }
  1204. @test "Restore[3]: From Hestia [MAIL-Account]" {
  1205. local domain="test.hestia.com"
  1206. run v-list-mail-account $userbk $domain testaccount
  1207. assert_success
  1208. }
  1209. @test "Restore[3]: From Hestia [DB]" {
  1210. run v-list-database $userbk "${userbk}_db"
  1211. assert_success
  1212. }
  1213. @test "Restore[3]: From Hestia [CRON]" {
  1214. run v-list-cron-job $userbk 1
  1215. assert_success
  1216. }
  1217. @test "Restore[3]: From Hestia Cleanup" {
  1218. run v-delete-user $userbk
  1219. assert_success
  1220. refute_output
  1221. }
  1222. @test "Restore[4]: Hestia (zstd) archive for a existing user" {
  1223. if [ -d "$HOMEDIR/$userbk" ]; then
  1224. run v-delete-user $userbk
  1225. assert_success
  1226. refute_output
  1227. fi
  1228. if [ ! -d "$HOMEDIR/$userbk" ]; then
  1229. run v-add-user $userbk $userbk [email protected]
  1230. assert_success
  1231. fi
  1232. mkdir -p /backup
  1233. local archive_name="hestia131.2020-12-12"
  1234. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1235. assert_success
  1236. run v-restore-user $userbk "${archive_name}.tar"
  1237. assert_success
  1238. rm "/backup/${archive_name}.tar"
  1239. }
  1240. @test "Restore[4]: From Hestia [WEB]" {
  1241. local domain="test.hestia.com"
  1242. validate_web_domain $userbk $domain 'Hello Hestia'
  1243. }
  1244. @test "Restore[4]: From Hestia [DNS]" {
  1245. local domain="test.hestia.com"
  1246. run v-list-dns-domain $userbk $domain
  1247. assert_success
  1248. run nslookup $domain 127.0.0.1
  1249. assert_success
  1250. }
  1251. @test "Restore[4]: From Hestia [MAIL]" {
  1252. local domain="test.hestia.com"
  1253. run v-list-mail-domain $userbk $domain
  1254. assert_success
  1255. }
  1256. @test "Restore[4]: From Hestia [MAIL-Account]" {
  1257. local domain="test.hestia.com"
  1258. run v-list-mail-account $userbk $domain testaccount
  1259. assert_success
  1260. }
  1261. @test "Restore[4]: From Hestia [DB]" {
  1262. run v-list-database $userbk "${userbk}_db"
  1263. assert_success
  1264. }
  1265. @test "Restore[4]: From Hestia [CRON]" {
  1266. run v-list-cron-job $userbk 1
  1267. assert_success
  1268. }
  1269. @test "Restore[4]: From Hestia Cleanup" {
  1270. run v-delete-user $userbk
  1271. assert_success
  1272. refute_output
  1273. }
  1274. # Testing Vesta Backups
  1275. @test "Restore[1]: Vesta archive for a non-existing user" {
  1276. if [ -d "$HOMEDIR/$userbk" ]; then
  1277. run v-delete-user $userbk
  1278. assert_success
  1279. refute_output
  1280. fi
  1281. mkdir -p /backup
  1282. local archive_name="vesta09823.2018-10-18"
  1283. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1284. assert_success
  1285. run v-restore-user $userbk "${archive_name}.tar"
  1286. assert_success
  1287. rm "/backup/${archive_name}.tar"
  1288. }
  1289. @test "Restore[1]: From Vesta [WEB]" {
  1290. local domain="vesta09823.tld"
  1291. validate_web_domain $userbk $domain 'Hello Vesta'
  1292. }
  1293. @test "Restore[1]: From Vesta [DNS]" {
  1294. local domain="vesta09823.tld"
  1295. run v-list-dns-domain $userbk $domain
  1296. assert_success
  1297. run nslookup $domain 127.0.0.1
  1298. assert_success
  1299. }
  1300. @test "Restore[1]: From Vesta [MAIL]" {
  1301. local domain="vesta09823.tld"
  1302. run v-list-mail-domain $userbk $domain
  1303. assert_success
  1304. }
  1305. @test "Restore[1]: From Vesta [MAIL-Account]" {
  1306. local domain="vesta09823.tld"
  1307. run v-list-mail-account $userbk $domain testaccount
  1308. assert_success
  1309. }
  1310. @test "Restore[1]: From Vesta [DB]" {
  1311. run v-list-database $userbk "${userbk}_db"
  1312. assert_success
  1313. }
  1314. @test "Restore[1]: From Vesta [CRON]" {
  1315. run v-list-cron-job $userbk 1
  1316. assert_success
  1317. }
  1318. @test "Restore[1]: From Vesta Cleanup" {
  1319. run v-delete-user $userbk
  1320. assert_success
  1321. refute_output
  1322. }
  1323. @test "Restore[2]: Vesta archive over a existing user" {
  1324. if [ -d "$HOMEDIR/$userbk" ]; then
  1325. run v-delete-user $userbk
  1326. assert_success
  1327. refute_output
  1328. fi
  1329. if [ ! -d "$HOMEDIR/$userbk" ]; then
  1330. run v-add-user $userbk $userbk [email protected]
  1331. assert_success
  1332. fi
  1333. mkdir -p /backup
  1334. local archive_name="vesta09823.2018-10-18"
  1335. run wget --quiet --tries=3 --timeout=15 --read-timeout=15 --waitretry=3 --no-dns-cache "https://hestiacp.com/testing/data/${archive_name}.tar" -O "/backup/${archive_name}.tar"
  1336. assert_success
  1337. run v-restore-user $userbk "${archive_name}.tar"
  1338. assert_success
  1339. rm "/backup/${archive_name}.tar"
  1340. }
  1341. @test "Restore[2]: From Vesta [WEB]" {
  1342. local domain="vesta09823.tld"
  1343. validate_web_domain $userbk "${domain}" 'Hello Vesta'
  1344. }
  1345. @test "Restore[2]: From Vesta [DNS]" {
  1346. local domain="vesta09823.tld"
  1347. run v-list-dns-domain $userbk $domain
  1348. assert_success
  1349. run nslookup $domain 127.0.0.1
  1350. assert_success
  1351. }
  1352. @test "Restore[2]: From Vesta [MAIL]" {
  1353. local domain="vesta09823.tld"
  1354. run v-list-mail-domain $userbk $domain
  1355. assert_success
  1356. }
  1357. @test "Restore[2]: From Vesta [MAIL-Account]" {
  1358. local domain="vesta09823.tld"
  1359. run v-list-mail-account $userbk $domain testaccount
  1360. assert_success
  1361. }
  1362. @test "Restore[2]: From Vesta [DB]" {
  1363. run v-list-database $userbk "${userbk}_db"
  1364. assert_success
  1365. }
  1366. @test "Restore[2]: From Vesta [CRON]" {
  1367. run v-list-cron-job $userbk 1
  1368. assert_success
  1369. }
  1370. @test "Restore[2]: From Vesta Cleanup" {
  1371. run v-delete-user $userbk
  1372. assert_success
  1373. refute_output
  1374. }
  1375. #----------------------------------------------------------#
  1376. # CLEANUP #
  1377. #----------------------------------------------------------#
  1378. @test "Mail: Delete domain" {
  1379. # skip
  1380. run v-delete-mail-domain $user $domain
  1381. assert_success
  1382. refute_output
  1383. }
  1384. @test "DNS: Delete domain" {
  1385. # skip
  1386. run v-delete-dns-domain $user $domain
  1387. assert_success
  1388. refute_output
  1389. }
  1390. @test "WEB: Delete domain" {
  1391. # skip
  1392. run v-delete-web-domain $user $domain
  1393. assert_success
  1394. refute_output
  1395. }
  1396. @test "Delete user" {
  1397. # skip
  1398. run v-delete-user $user
  1399. assert_success
  1400. refute_output
  1401. }
  1402. @test "Ip: Delete the test IP" {
  1403. # skip
  1404. run v-delete-sys-ip 198.18.0.125
  1405. assert_success
  1406. refute_output
  1407. }
  1408. @test 'assert()' {
  1409. touch '/var/log/test.log'
  1410. assert [ -e '/var/log/test.log' ]
  1411. }