Contains the Concourse pipeline definition for building a line-server container
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.

38 lines
772 B

  1. package main
  2. import (
  3. "net/http"
  4. "net/http/httptest"
  5. "testing"
  6. "github.com/zenazn/goji"
  7. )
  8. var testCSPHeaders = map[string]string{
  9. "Content-Security-Policy": "default-src 'none'; style-src 'self';",
  10. "X-Frame-Options": "SAMEORIGIN",
  11. }
  12. func TestContentSecurityPolicy(t *testing.T) {
  13. w := httptest.NewRecorder()
  14. req, err := http.NewRequest("GET", "/", nil)
  15. if err != nil {
  16. t.Fatal(err)
  17. }
  18. goji.Use(ContentSecurityPolicy(CSPOptions{
  19. policy: testCSPHeaders["Content-Security-Policy"],
  20. frame: testCSPHeaders["X-Frame-Options"],
  21. }))
  22. goji.DefaultMux.ServeHTTP(w, req)
  23. for k, v := range testCSPHeaders {
  24. if w.HeaderMap[k][0] != v {
  25. t.Fatalf("%s header did not match expected value set by middleware", k)
  26. }
  27. }
  28. }
  29. // vim:set ts=8 sw=8 noet: