fix: tests

This commit is contained in:
Ferdinand Mütsch 2021-10-11 11:38:55 +02:00
parent 9451848ad4
commit ed9a7ccd5a
1 changed files with 6 additions and 3 deletions

View File

@ -59,9 +59,11 @@ func TestAuthenticateMiddleware_tryGetUserByApiKeyQuery_Success(t *testing.T) {
testApiKey := "z5uig69cn9ut93n" testApiKey := "z5uig69cn9ut93n"
testUser := &models.User{ApiKey: testApiKey} testUser := &models.User{ApiKey: testApiKey}
params := url.Values{}
params.Add("api_key", testApiKey)
mockRequest := &http.Request{ mockRequest := &http.Request{
URL: &url.URL{ URL: &url.URL{
RawQuery: fmt.Sprintf("api_token=%s", testApiKey), RawQuery: params.Encode(),
}, },
} }
@ -79,10 +81,11 @@ func TestAuthenticateMiddleware_tryGetUserByApiKeyQuery_Success(t *testing.T) {
func TestAuthenticateMiddleware_tryGetUserByApiKeyQuery_Invalid(t *testing.T) { func TestAuthenticateMiddleware_tryGetUserByApiKeyQuery_Invalid(t *testing.T) {
testApiKey := "z5uig69cn9ut93n" testApiKey := "z5uig69cn9ut93n"
params := url.Values{}
params.Add("token", testApiKey)
mockRequest := &http.Request{ mockRequest := &http.Request{
URL: &url.URL{ URL: &url.URL{
// Use the wrong parameter name. RawQuery: params.Encode(),
RawQuery: fmt.Sprintf("token=%s", testApiKey),
}, },
} }