config-tests.bats 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/usr/bin/env bats
  2. if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then
  3. . /etc/profile.d/hestia.sh
  4. fi
  5. load 'test_helper/bats-support/load'
  6. load 'test_helper/bats-assert/load'
  7. load 'test_helper/bats-file/load'
  8. function random() {
  9. head /dev/urandom | tr -dc 0-9 | head -c$1
  10. }
  11. function setup() {
  12. # echo "# Setup_file" > &3
  13. if [ $BATS_TEST_NUMBER = 1 ]; then
  14. echo 'user=test-5285' > /tmp/hestia-test-env.sh
  15. echo 'user2=test-5286' >> /tmp/hestia-test-env.sh
  16. echo 'userbk=testbk-5285' >> /tmp/hestia-test-env.sh
  17. echo 'userpass1=test-5285' >> /tmp/hestia-test-env.sh
  18. echo 'userpass2=t3st-p4ssw0rd' >> /tmp/hestia-test-env.sh
  19. echo 'HESTIA=/usr/local/hestia' >> /tmp/hestia-test-env.sh
  20. echo 'domain=test-5285.hestiacp.com' >> /tmp/hestia-test-env.sh
  21. echo 'domainuk=test-5285.hestiacp.com.uk' >> /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
  24. echo 'database=test-5285_database' >> /tmp/hestia-test-env.sh
  25. echo 'dbuser=test-5285_dbuser' >> /tmp/hestia-test-env.sh
  26. fi
  27. source /tmp/hestia-le-env.sh
  28. source /tmp/hestia-test-env.sh
  29. source $HESTIA/func/main.sh
  30. source $HESTIA/conf/hestia.conf
  31. source $HESTIA/func/ip.sh
  32. }
  33. @test "Prepare for tests" {
  34. run rm -f /usr/local/hestia/data/templates/web/nginx/php-fpm/*.*
  35. run rm -f /usr/local/hestia/data/templates/web/nginx/*.*
  36. run rm -f /usr/local/hestia/data/templates/web/apache2/php-fpm/*.*
  37. run rm -f /usr/local/hestia/data/templates/web/apache2/*.*
  38. run v-update-web-templates
  39. }
  40. @test "[ IPV6 ] Add IPV6 address" {
  41. # Remove IPV6 Address to be removed when merged with main
  42. run v-add-sys-ip $ipv6 "/64"
  43. assert_success
  44. refute_output
  45. }
  46. @test "Setup Test domain" {
  47. run v-add-user $user $user $user@hestiacp.com default "Super Test"
  48. assert_success
  49. refute_output
  50. run v-add-web-domain-ipv46 $user 'testhestiacp.com'
  51. assert_success
  52. refute_output
  53. ssl=$(v-generate-ssl-cert "testhestiacp.com" "info@testhestiacp.com" US CA "Orange County" HestiaCP IT "mail.$domain" | tail -n1 | awk '{print $2}')
  54. mv $ssl/testhestiacp.com.crt /tmp/testhestiacp.com.crt
  55. mv $ssl/testhestiacp.com.key /tmp/testhestiacp.com.key
  56. # Use self signed certificates during last test
  57. run v-add-web-domain-ssl $user testhestiacp.com /tmp
  58. assert_success
  59. refute_output
  60. }
  61. @test "Web Config test" {
  62. for template in $(v-list-web-templates plain); do
  63. run v-change-web-domain-tpl $user testhestiacp.com $template
  64. assert_success
  65. refute_output
  66. done
  67. }
  68. @test "Proxy Config test" {
  69. if [ "$PROXY_SYSTEM" = "nginx" ]; then
  70. for template in $(v-list-web-templates plain); do
  71. run v-change-web-domain-proxy-tpl $user testhestiacp.com $template
  72. assert_success
  73. refute_output
  74. done
  75. else
  76. skip "Proxy not installed"
  77. fi
  78. }
  79. @test "Clean up" {
  80. run v-delete-user $user
  81. assert_success
  82. refute_output
  83. }
  84. @test "[ IPV6 ] Delete IPV6 address" {
  85. # Remove IPV6 Address to be removed when merged with main
  86. run v-delete-sys-ip $ipv6
  87. assert_success
  88. refute_output
  89. }