From ea8d447816733ef67065de77eadbe791f1162c3b Mon Sep 17 00:00:00 2001 From: Kieran Klukas <92754843+kcoderhtml@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:41:17 -0400 Subject: [PATCH] bug: fix TestAuthenticateMiddleware_tryGetUserByApiKeyHeader_Success test it ended up being because config isn't initialized during testing so a equals check will fail; simply adding a nil check fixed the issue --- middlewares/authenticate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middlewares/authenticate.go b/middlewares/authenticate.go index 516f2278..e43c455e 100644 --- a/middlewares/authenticate.go +++ b/middlewares/authenticate.go @@ -119,7 +119,7 @@ func (m *AuthenticateMiddleware) tryGetUserByApiKeyHeader(r *http.Request) (*mod var user *models.User userKey := strings.TrimSpace(key) - if key == m.config.Security.AdminToken { + if m.config != nil && key == m.config.Security.AdminToken { user, err = m.userSrvc.GetUserById(r.URL.Query().Get("user")) } else { user, err = m.userSrvc.GetUserByKey(userKey)