Skip to content

Commit

Permalink
fix(tests): fix missing constructor extension for aaguid map
Browse files Browse the repository at this point in the history
Closes: #1027
  • Loading branch information
Stefan Jacobi committed Jan 24, 2024
1 parent abd7213 commit 55e371b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions backend/handler/email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *emailSuite) TestEmailHandler_List() {
err := s.LoadFixtures("../test/fixtures/email")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
s.Require().NoError(err)
Expand Down Expand Up @@ -172,7 +172,7 @@ func (s *emailSuite) TestEmailHandler_Create() {
cfg.AuditLog.Storage.Enabled = true
cfg.Emails.RequireVerification = currentTest.requiresVerification
cfg.Emails.MaxNumOfAddresses = currentTest.maxNumberOfAddresses
e := NewPublicRouter(&cfg, s.Storage, nil)
e := NewPublicRouter(&cfg, s.Storage, nil, nil)
jwkManager, err := jwk.NewDefaultManager(cfg.Secrets.Keys, s.Storage.GetJwkPersister())
s.Require().NoError(err)
sessionManager, err := session.NewManager(jwkManager, cfg)
Expand Down Expand Up @@ -234,7 +234,7 @@ func (s *emailSuite) TestEmailHandler_SetPrimaryEmail() {
err := s.LoadFixtures("../test/fixtures/email")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
s.Require().NoError(err)
Expand Down Expand Up @@ -278,7 +278,7 @@ func (s *emailSuite) TestEmailHandler_Delete() {
err := s.LoadFixtures("../test/fixtures/email")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)
userId := uuid.FromStringOrNil("b5dd5267-b462-48be-b70d-bcd6f1bbe7a5")

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
Expand Down
4 changes: 2 additions & 2 deletions backend/handler/passcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (s *passcodeSuite) TestPasscodeHandler_Init() {
return cfg
}

e := NewPublicRouter(cfg(), s.Storage, nil)
e := NewPublicRouter(cfg(), s.Storage, nil, nil)

emailId := "51b7c175-ceb6-45ba-aae6-0092221c1b84"
unknownEmailId := "83618f24-2db8-4ea2-b370-ac8335f782d8"
Expand Down Expand Up @@ -278,7 +278,7 @@ func (s *passcodeSuite) TestPasscodeHandler_Finish() {
sessionManager, err := session.NewManager(jwkManager, test.DefaultConfig)
s.Require().NoError(err)

e := NewPublicRouter(currentTest.cfg(), s.Storage, nil)
e := NewPublicRouter(currentTest.cfg(), s.Storage, nil, nil)

// Setup passcode
err = s.Storage.GetPasscodePersister().Create(currentTest.passcode)
Expand Down
4 changes: 2 additions & 2 deletions backend/handler/password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *passwordSuite) TestPasswordHandler_Set_Create() {
req.AddCookie(cookie)
rec := httptest.NewRecorder()

e := NewPublicRouter(cfg, s.Storage, nil)
e := NewPublicRouter(cfg, s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(currentTest.expectedCode, rec.Code)
Expand Down Expand Up @@ -171,7 +171,7 @@ func (s *passwordSuite) TestPasswordHandler_Login() {
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()

e := NewPublicRouter(currentTest.cfg(), s.Storage, nil)
e := NewPublicRouter(currentTest.cfg(), s.Storage, nil, nil)
e.ServeHTTP(rec, req)

if s.Equal(currentTest.expectedCode, rec.Code) {
Expand Down
12 changes: 6 additions & 6 deletions backend/handler/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *tokenSuite) TestToken_Validate_TokenInCookie() {

cfg := s.setupConfig()
cfg.Session.EnableAuthTokenHeader = false
e := NewPublicRouter(cfg, s.Storage, nil)
e := NewPublicRouter(cfg, s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusOK)
Expand Down Expand Up @@ -94,7 +94,7 @@ func (s *tokenSuite) TestToken_Validate_TokenInHeader() {
rec := httptest.NewRecorder()

cfg := s.setupConfig()
e := NewPublicRouter(cfg, s.Storage, nil)
e := NewPublicRouter(cfg, s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusOK)
Expand Down Expand Up @@ -127,7 +127,7 @@ func (s *tokenSuite) TestToken_Validate_ExpiredToken() {
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()

e := NewPublicRouter(s.setupConfig(), s.Storage, nil)
e := NewPublicRouter(s.setupConfig(), s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusUnprocessableEntity)
Expand All @@ -150,7 +150,7 @@ func (s *tokenSuite) TestToken_Validate_MissingTokenFromRequest() {
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()

e := NewPublicRouter(s.setupConfig(), s.Storage, nil)
e := NewPublicRouter(s.setupConfig(), s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusBadRequest)
Expand All @@ -173,7 +173,7 @@ func (s *tokenSuite) TestToken_Validate_InvalidJson() {
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()

e := NewPublicRouter(s.setupConfig(), s.Storage, nil)
e := NewPublicRouter(s.setupConfig(), s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusBadRequest)
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s *tokenSuite) TestToken_Validate_TokenNotFound() {
req.Header.Set("Content-Type", "application/json")
rec := httptest.NewRecorder()

e := NewPublicRouter(s.setupConfig(), s.Storage, nil)
e := NewPublicRouter(s.setupConfig(), s.Storage, nil, nil)
e.ServeHTTP(rec, req)

s.Equal(rec.Code, http.StatusNotFound)
Expand Down
38 changes: 19 additions & 19 deletions backend/handler/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *userSuite) TestUserHandler_Create_TokenInCookie() {
}

cfg := test.DefaultConfig
e := NewPublicRouter(&cfg, s.Storage, nil)
e := NewPublicRouter(&cfg, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand Down Expand Up @@ -78,7 +78,7 @@ func (s *userSuite) TestUserHandler_Create_TokenInHeader() {

cfg := test.DefaultConfig
cfg.Session.EnableAuthTokenHeader = true
e := NewPublicRouter(&cfg, s.Storage, nil)
e := NewPublicRouter(&cfg, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand Down Expand Up @@ -118,7 +118,7 @@ func (s *userSuite) TestUserHandler_Create_CaseInsensitive() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand Down Expand Up @@ -153,7 +153,7 @@ func (s *userSuite) TestUserHandler_Create_UserExists() {
err := s.LoadFixtures("../test/fixtures/user")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand All @@ -175,7 +175,7 @@ func (s *userSuite) TestUserHandler_Create_UserExists_CaseInsensitive() {
err := s.LoadFixtures("../test/fixtures/user")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand All @@ -194,7 +194,7 @@ func (s *userSuite) TestUserHandler_Create_InvalidEmail() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/users", strings.NewReader(`{"email": 123"}`))
req.Header.Set("Content-Type", "application/json")
Expand All @@ -209,7 +209,7 @@ func (s *userSuite) TestUserHandler_Create_EmailMissing() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/users", strings.NewReader(`{"bogus": 123}`))
req.Header.Set("Content-Type", "application/json")
Expand All @@ -226,7 +226,7 @@ func (s *userSuite) TestUserHandler_Create_AccountCreationDisabled() {
}
testConfig := test.DefaultConfig
testConfig.Account.AllowSignup = false
e := NewPublicRouter(&testConfig, s.Storage, nil)
e := NewPublicRouter(&testConfig, s.Storage, nil, nil)

body := UserCreateBody{Email: "[email protected]"}
bodyJson, err := json.Marshal(body)
Expand All @@ -250,7 +250,7 @@ func (s *userSuite) TestUserHandler_Get() {

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
if err != nil {
Expand Down Expand Up @@ -290,7 +290,7 @@ func (s *userSuite) TestUserHandler_GetUserWithWebAuthnCredential() {

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
if err != nil {
Expand Down Expand Up @@ -325,7 +325,7 @@ func (s *userSuite) TestUserHandler_Get_InvalidUserId() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

Expand Down Expand Up @@ -356,7 +356,7 @@ func (s *userSuite) TestUserHandler_GetUserIdByEmail_InvalidEmail() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/user", strings.NewReader(`{"email": "123"}`))
req.Header.Set("Content-Type", "application/json")
Expand All @@ -371,7 +371,7 @@ func (s *userSuite) TestUserHandler_GetUserIdByEmail_InvalidJson() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/user", strings.NewReader(`"email": "123}`))
req.Header.Set("Content-Type", "application/json")
Expand All @@ -386,7 +386,7 @@ func (s *userSuite) TestUserHandler_GetUserIdByEmail_UserNotFound() {
if testing.Short() {
s.T().Skip("skipping test in short mode.")
}
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/user", strings.NewReader(`{"email": "[email protected]"}`))
req.Header.Set("Content-Type", "application/json")
Expand All @@ -406,7 +406,7 @@ func (s *userSuite) TestUserHandler_GetUserIdByEmail() {

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/user", strings.NewReader(`{"email": "[email protected]"}`))
req.Header.Set("Content-Type", "application/json")
Expand Down Expand Up @@ -435,7 +435,7 @@ func (s *userSuite) TestUserHandler_GetUserIdByEmail_CaseInsensitive() {

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodPost, "/user", strings.NewReader(`{"email": "[email protected]"}`))
req.Header.Set("Content-Type", "application/json")
Expand Down Expand Up @@ -464,7 +464,7 @@ func (s *userSuite) TestUserHandler_Me() {

userId := "b5dd5267-b462-48be-b70d-bcd6f1bbe7a5"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
if err != nil {
Expand Down Expand Up @@ -501,7 +501,7 @@ func (s *userSuite) TestUserHandler_Logout() {
s.T().Skip("skipping test in short mode.")
}
userId, _ := uuid.NewV4()
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
if err != nil {
Expand Down Expand Up @@ -542,7 +542,7 @@ func (s *userSuite) TestUserHandler_Delete() {
userId, _ := uuid.FromString("b5dd5267-b462-48be-b70d-bcd6f1bbe7a5")
cfg := test.DefaultConfig
cfg.Account.AllowDeletion = true
e := NewPublicRouter(&cfg, s.Storage, nil)
e := NewPublicRouter(&cfg, s.Storage, nil, nil)

jwkManager, err := jwk.NewDefaultManager(test.DefaultConfig.Secrets.Keys, s.Storage.GetJwkPersister())
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions backend/handler/webauthn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *webauthnSuite) TestWebauthnHandler_NewHandler() {
if testing.Short() {
s.T().Skip("skipping test in short mode")
}
handler, err := NewWebauthnHandler(&test.DefaultConfig, s.Storage, s.GetDefaultSessionManager(), test.NewAuditLogger())
handler, err := NewWebauthnHandler(&test.DefaultConfig, s.Storage, s.GetDefaultSessionManager(), test.NewAuditLogger(), nil)
s.NoError(err)
s.NotEmpty(handler)
}
Expand All @@ -48,7 +48,7 @@ func (s *webauthnSuite) TestWebauthnHandler_BeginRegistration() {

userId := "ec4ef049-5b88-4321-a173-21b0eff06a04"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

sessionManager := s.GetDefaultSessionManager()
token, err := sessionManager.GenerateJWT(uuid.FromStringOrNil(userId))
Expand Down Expand Up @@ -89,7 +89,7 @@ func (s *webauthnSuite) TestWebauthnHandler_FinalizeRegistration() {

userId := "ec4ef049-5b88-4321-a173-21b0eff06a04"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

sessionManager := s.GetDefaultSessionManager()
token, err := sessionManager.GenerateJWT(uuid.FromStringOrNil(userId))
Expand Down Expand Up @@ -135,7 +135,7 @@ func (s *webauthnSuite) TestWebauthnHandler_FinalizeRegistration_SessionDataExpi

userId := "ec4ef049-5b88-4321-a173-21b0eff06a04"

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

sessionManager := s.GetDefaultSessionManager()
token, err := sessionManager.GenerateJWT(uuid.FromStringOrNil(userId))
Expand Down Expand Up @@ -170,7 +170,7 @@ func (s *webauthnSuite) TestWebauthnHandler_BeginAuthentication() {
err := s.LoadFixtures("../test/fixtures/webauthn")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)
req := httptest.NewRequest(http.MethodPost, "/webauthn/login/initialize", nil)
rec := httptest.NewRecorder()

Expand All @@ -194,7 +194,7 @@ func (s *webauthnSuite) TestWebauthnHandler_FinalizeAuthentication() {
err := s.LoadFixtures("../test/fixtures/webauthn")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

body := `{
"id": "AaFdkcD4SuPjF-jwUoRwH8-ZHuY5RW46fsZmEvBX6RNKHaGtVzpATs06KQVheIOjYz-YneG4cmQOedzl0e0jF951ukx17Hl9jeGgWz5_DKZCO12p2-2LlzjH",
Expand Down Expand Up @@ -247,7 +247,7 @@ func (s *webauthnSuite) TestWebauthnHandler_FinalizeAuthentication_SessionDataEx
err := s.LoadFixtures("../test/fixtures/webauthn")
s.Require().NoError(err)

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

body := `{
"id": "4iVZGFN_jktXJmwmBmaSq0Qr4T62T0jX7PS7XcgAWlM",
Expand Down Expand Up @@ -279,7 +279,7 @@ func (s *webauthnSuite) TestWebauthnHandler_FinalizeAuthentication_TokenInHeader

cfg := test.DefaultConfig
cfg.Session.EnableAuthTokenHeader = true
e := NewPublicRouter(&cfg, s.Storage, nil)
e := NewPublicRouter(&cfg, s.Storage, nil, nil)

body := `{
"id": "AaFdkcD4SuPjF-jwUoRwH8-ZHuY5RW46fsZmEvBX6RNKHaGtVzpATs06KQVheIOjYz-YneG4cmQOedzl0e0jF951ukx17Hl9jeGgWz5_DKZCO12p2-2LlzjH",
Expand Down
2 changes: 1 addition & 1 deletion backend/handler/well_known_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (s *wellKnownSuite) TestWellKnownHandler_GetPublicKeys() {
s.T().Skip("skipping test in short mode")
}

e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil)
e := NewPublicRouter(&test.DefaultConfig, s.Storage, nil, nil)

req := httptest.NewRequest(http.MethodGet, "/.well-known/jwks.json", nil)
rec := httptest.NewRecorder()
Expand Down

0 comments on commit 55e371b

Please sign in to comment.