Projects STRLCPY gophish Commits 166ff8a0
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    middleware/middleware.go
    skipped 76 lines
    77 77   return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    78 78   w.Header().Set("Access-Control-Allow-Origin", "*")
    79 79   if r.Method == "OPTIONS" {
    80  - w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
     80 + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
    81 81   w.Header().Set("Access-Control-Max-Age", "1000")
    82 82   w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
    83 83   return
    skipped 115 lines
  • ■ ■ ■ ■ ■ ■
    middleware/middleware_test.go
    skipped 132 lines
    133 133   }
    134 134  }
    135 135   
     136 +func TestCORSHeaders(t *testing.T) {
     137 + setupTest(t)
     138 + req := httptest.NewRequest(http.MethodOptions, "/", nil)
     139 + response := httptest.NewRecorder()
     140 + RequireAPIKey(successHandler).ServeHTTP(response, req)
     141 + expected := "POST, GET, OPTIONS, PUT, DELETE"
     142 + got := response.Result().Header.Get("Access-Control-Allow-Methods")
     143 + if got != expected {
     144 + t.Fatalf("incorrect cors options received. expected %s got %s", expected, got)
     145 + }
     146 +}
     147 + 
    136 148  func TestInvalidAPIKey(t *testing.T) {
    137 149   setupTest(t)
    138 150   req := httptest.NewRequest(http.MethodGet, "/", nil)
    skipped 62 lines
Please wait...
Page is in error, reload to recover