Created
November 19, 2021 05:43
-
-
Save shrmpy/1961ee953b5f9b84d762919dc346998f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestAccessControlAllowOrigin(t *testing.T) { | |
// prepare data | |
conf := ebs.NewConfig() | |
conf.ExtensionId("HOSTNAME-TEST") | |
expectMethods := "POST, GET, OPTIONS, PUT" | |
expectHeaders := "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization" | |
expectOrigin := "https://HOSTNAME-TEST.ext-twitch.tv" | |
req := newTestRequest("GET") | |
// run handler logic | |
result, err := ebs.MiddlewareCORS(conf, handler)(req) | |
assert.IsType(t, nil, err) | |
assert.Equal(t, http.StatusOK, result.StatusCode) | |
// check for expected CORS | |
assert.Equal(t, expectMethods, result.Headers["Access-Control-Allow-Methods"]) | |
assert.Equal(t, expectHeaders, result.Headers["Access-Control-Allow-Headers"]) | |
assert.Equal(t, expectOrigin, result.Headers["Access-Control-Allow-Origin"]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment