Skip to content

Commit 84d0919

Browse files
committed
test: refactor CORS tests and expand coverage
- Add a new test function `TestDefaultConfig` to verify default configuration behavior in CORS tests Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 4447aeb commit 84d0919

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cors_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@ func TestValidateTauri(t *testing.T) {
314314
assert.Nil(t, c.Validate())
315315
}
316316

317+
func TestDefaultConfig(t *testing.T) {
318+
config := DefaultConfig()
319+
config.AllowAllOrigins = true
320+
router := newTestRouter(config)
321+
w := performRequest(router, "GET", "http://google.com")
322+
assert.Equal(t, "get", w.Body.String())
323+
assert.Equal(t, "*", w.Header().Get("Access-Control-Allow-Origin"))
324+
assert.Empty(t, w.Header().Get("Access-Control-Allow-Credentials"))
325+
assert.Empty(t, w.Header().Get("Access-Control-Expose-Headers"))
326+
}
327+
317328
func TestPassesAllowOrigins(t *testing.T) {
318329
router := newTestRouter(Config{
319330
AllowOrigins: []string{"http://google.com"},

0 commit comments

Comments
 (0)