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.

39 lines
811 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. "X-Content-Type-Options": "nosniff",
  12. }
  13. func TestContentSecurityPolicy(t *testing.T) {
  14. w := httptest.NewRecorder()
  15. req, err := http.NewRequest("GET", "/", nil)
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. goji.Use(ContentSecurityPolicy(CSPOptions{
  20. policy: testCSPHeaders["Content-Security-Policy"],
  21. frame: testCSPHeaders["X-Frame-Options"],
  22. }))
  23. goji.DefaultMux.ServeHTTP(w, req)
  24. for k, v := range testCSPHeaders {
  25. if w.HeaderMap[k][0] != v {
  26. t.Fatalf("%s header did not match expected value set by middleware", k)
  27. }
  28. }
  29. }
  30. // vim:set ts=8 sw=8 noet: