Last active
November 3, 2021 02:53
-
-
Save shrmpy/14638c7b525cb09e6cf7cae712c4892c to your computer and use it in GitHub Desktop.
Add the negative test to verify there is logic that enforces the correct extension secret
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 TestWrongExtensionSecret(t *testing.T) { | |
// prepare data | |
wrongHeader := make(map[string]string) | |
wrongHeader["Authorization"] = "Bearer WRONG-KEY" | |
req := events.APIGatewayProxyRequest{ | |
HTTPMethod: "GET", | |
Body: "", | |
Headers: wrongHeader, | |
} | |
// run request handlerlogic | |
result, err := handler(req) | |
assert.IsType(t, nil, err) | |
assert.Equal(t, http.StatusOK, result.StatusCode) | |
// case specific expectation | |
missing := newResponse("Wrong authorization header", http.StatusUnauthorized) | |
expected := ignoreTimestamp(missing.Body) | |
actual := ignoreTimestamp(result.Body) | |
// inspect content | |
assert.Equal(t, expected, actual) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment