Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # use timeout or gtimeout
  3. export TIMEOUT="timeout"
  4. if [ -z `which timeout` ]; then
  5. export TIMEOUT="gtimeout"
  6. fi
  7. SUITE_RET=0
  8. runtest() {
  9. NAME=$1
  10. OUTPUT=`$TIMEOUT -k 1 5 bash -c "$2" 2>&1`
  11. RET="$?"
  12. if [ $RET -eq 0 ]; then
  13. printf "$NAME: \e[00;32mPASSED\e[00m\n"
  14. elif [ $RET -eq 124 ]; then
  15. printf "$NAME: \e[00;31mTIMEOUT\e[00m\n"
  16. SUITE_RET=1
  17. else
  18. printf "$NAME: \e[00;31mFAILED\e[00m\n"
  19. echo "$OUTPUT"
  20. SUITE_RET=1
  21. fi
  22. }
  23. # SSH
  24. runtest test_ssh "nc -w1 172.16.100.2 22 | grep '^SSH'"
  25. # SMTP
  26. runtest test_smtp "echo 'quit' | nc -w1 172.16.100.2 25 | grep 'ESMTP Postfix'"
  27. runtest test_smtps "echo '' | openssl s_client -connect 172.16.100.2:465 | grep 'TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA'"
  28. runtest test_smtp_tls "echo '' | openssl s_client -connect 172.16.100.2:25 -starttls smtp | grep 'TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA'"
  29. # IMAP
  30. runtest test_imaps "echo '' | openssl s_client -connect 172.16.100.2:993 | grep 'TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA'"
  31. # HTTP/S
  32. runtest test_http "echo 'GET /' | nc -w1 172.16.100.2 80 | grep 'It works!'"
  33. runtest test_https "echo '' | openssl s_client -connect 172.16.100.2:443 | grep 'TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA'"
  34. runtest test_blog_redirect "curl 172.16.100.2:80 -H 'Host: sovereign.local' -v | grep '301 Moved Permanently'"
  35. # The blog will give 403 because it is an empty directory
  36. runtest test_blog "curl https://172.16.100.2:443/ -H 'Host: sovereign.local' -v --insecure | grep '403 Forbidden'"
  37. # Other web sites
  38. runtest test_roundcube "curl https://172.16.100.2:443/ -H 'Host: mail.sovereign.local' -v --insecure | grep 'Welcome to Roundcube Webmail'"
  39. runtest test_owncloud "curl https://172.16.100.2:443/ -H 'Host: cloud.sovereign.local' -v --insecure | grep 'ownCloud'"
  40. # ZNC
  41. runtest test_znc "echo '' | openssl s_client -connect 172.16.100.2:6697 | grep 'TLSv1/SSLv3, Cipher is AES256-SHA'"
  42. exit $SUITE_RET