You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4KB

  1. #!/usr/bin/env bash
  2. # Frontend-agnostic test runner: plain curl + a JSON parser, no PowerShell,
  3. # no cscript, no SSH access to the VM required. Runnable from any CLI that
  4. # can reach the site over HTTP.
  5. #
  6. # Usage: ./run-self-test.sh http://100.127.62.31:8091
  7. set -euo pipefail
  8. BASE_URL="${1:?Usage: run-self-test.sh <base-url>, e.g. http://100.127.62.31:8091}"
  9. response=$(curl -sf "$BASE_URL/self-test")
  10. echo "$response" | python3 -m json.tool
  11. ok=$(echo "$response" | python3 -c 'import json, sys; print("true" if json.load(sys.stdin)["ok"] else "false")')
  12. if [ "$ok" != "true" ]; then
  13. echo "RESULT: FAILURE"
  14. exit 1
  15. fi
  16. root_ok=$(curl -sf "$BASE_URL/" | python3 -c 'import json, sys; print("true" if json.load(sys.stdin)["ok"] else "false")')
  17. if [ "$root_ok" != "true" ]; then
  18. echo "FAIL: test app root did not return passing self-test JSON" >&2
  19. exit 1
  20. fi
  21. echo "PASS: test app root maps to /self-test"
  22. # URL Rewrite is not the only entry path: Default.asp is directly addressable.
  23. # Prove this test app still cannot activate a production route through its
  24. # internal route query string.
  25. hello_status=$(curl -sS -o /dev/null -w '%{http_code}' "$BASE_URL/Default.asp?route=/hello")
  26. if [ "$hello_status" != "404" ]; then
  27. echo "FAIL: test app direct Default.asp activated production route (HTTP $hello_status)" >&2
  28. exit 1
  29. fi
  30. echo "PASS: test app rejects production route through direct Default.asp"
  31. echo "RESULT: ALL PASS"

Powered by TurnKey Linux.