MCPcopy
hub / github.com/gophish/gophish / TestRequireAPIKey

Function TestRequireAPIKey

middleware/middleware_test.go:122–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestRequireAPIKey(t *testing.T) {
123 setupTest(t)
124 req := httptest.NewRequest(http.MethodGet, "/", nil)
125 req.Header.Set("Content-Type", "application/json")
126 response := httptest.NewRecorder()
127 // Test that making a request without an API key is denied
128 RequireAPIKey(successHandler).ServeHTTP(response, req)
129 expected := http.StatusUnauthorized
130 got := response.Code
131 if got != expected {
132 t.Fatalf("incorrect status code received. expected %d got %d", expected, got)
133 }
134}
135
136func TestCORSHeaders(t *testing.T) {
137 setupTest(t)

Callers

nothing calls this directly

Calls 3

RequireAPIKeyFunction · 0.85
ServeHTTPMethod · 0.80
setupTestFunction · 0.70

Tested by

no test coverage detected