secure.es.tst 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. secure.tst - SSL http tests
  3. */
  4. if (!Config.SSL) {
  5. tskip("SSL not enabled in ejscript")
  6. } else if (thas('ME_SSL')) {
  7. const HTTP = tget('TM_HTTP') || "127.0.0.1:8080"
  8. const HTTPS = tget('TM_HTTPS') || "127.0.0.1:4443"
  9. let http: Http = new Http
  10. http.verify = false
  11. http.get(HTTP + "/index.html")
  12. ttrue(!http.isSecure)
  13. http.close()
  14. http.verify = false
  15. http.get(HTTPS + "/index.html")
  16. http.wait()
  17. ttrue(http.isSecure)
  18. http.close()
  19. http.verify = false
  20. http.get(HTTPS + "/index.html")
  21. ttrue(http.readString(12) == "<html><head>")
  22. http.close()
  23. // Validate get contents
  24. http.verify = false
  25. http.get(HTTPS + "/index.html?a=b")
  26. ttrue(http.response.endsWith("</html>\n"))
  27. ttrue(http.response.endsWith("</html>\n"))
  28. http.close()
  29. http.verify = false
  30. http.post(HTTPS + "/index.html", "Some data")
  31. ttrue(http.status == 200)
  32. http.close()
  33. } else {
  34. tskip("SSL not enabled")
  35. }