test-web-path-handling.scm 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (use-modules
  2. ;; for unit testing forms
  3. (srfi srfi-64))
  4. (use-modules
  5. ;; import the module to test
  6. (web-path-handling)
  7. (path-handling))
  8. (define path-to-current-dir
  9. (dirname (or (current-filename)
  10. (canonicalize-path "."))))
  11. (define path-to-web-app-root
  12. (dirname
  13. (dirname
  14. (or (current-filename)
  15. (canonicalize-path ".")))))
  16. (test-begin "web-path-handling-test")
  17. (test-group
  18. "subpath?-test"
  19. (test-assert "subpath?--01"
  20. (subpath? (path-join "test-dir" "static")
  21. (path-join "test-dir"))))
  22. (test-group
  23. "safe-path?-test"
  24. (test-assert "safe-path?-test--01"
  25. (safe-path? "static" path-to-web-app-root))
  26. (test-assert "safe-path?-test--02"
  27. (not
  28. (safe-path? (path-join "static" "`" "eval" "`")
  29. path-to-web-app-root))))
  30. ;; Finish the testsuite, and report results.
  31. (test-end "web-path-handling-test")