fix(test): update CORS preflight test for deny-all default
Empty CORSConfig now means no CORS headers, matching the security fix. Test explicitly configures an origin to test preflight behavior.
This commit is contained in:
parent
5884c080fd
commit
a316763aca
1 changed files with 2 additions and 1 deletions
|
|
@ -51,7 +51,7 @@ func TestCORS_SpecificOrigin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCORS_Preflight(t *testing.T) {
|
func TestCORS_Preflight(t *testing.T) {
|
||||||
h := CORS(CORSConfig{})(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
h := CORS(CORSConfig{AllowedOrigins: []string{"https://example.com"}})(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
t.Error("handler should not be called for preflight")
|
t.Error("handler should not be called for preflight")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
@ -100,6 +100,7 @@ func TestCORS_CustomMethodsAndHeaders(t *testing.T) {
|
||||||
})(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
})(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||||
|
|
||||||
req := httptest.NewRequest("OPTIONS", "/search", nil)
|
req := httptest.NewRequest("OPTIONS", "/search", nil)
|
||||||
|
req.Header.Set("Origin", "https://example.com")
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
h.ServeHTTP(rec, req)
|
h.ServeHTTP(rec, req)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue