From 3a4678e4b4bf9e98170737f9ea068674590df02d Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 7 Jan 2024 15:45:51 +1000 Subject: [PATCH 01/12] updated api --- go.mod | 4 + go.sum | 8 +- pkg/controller/signup_test.go | 29 +-- .../service/informer_service_test.go | 18 +- pkg/signup/service/signup_service.go | 35 +-- pkg/signup/service/signup_service_test.go | 245 +----------------- .../service/verification_service_test.go | 158 +++++------ 7 files changed, 123 insertions(+), 374 deletions(-) diff --git a/go.mod b/go.mod index f5ed0860..8c1caa28 100644 --- a/go.mod +++ b/go.mod @@ -145,3 +145,7 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) + +replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e + +replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd diff --git a/go.sum b/go.sum index 2f9ee20b..60c48913 100644 --- a/go.sum +++ b/go.sum @@ -115,10 +115,6 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/codeready-toolchain/api v0.0.0-20231129193441-f6c9b7feee01 h1:Pl8UIl/m2/n9C4pXzaR6A3vxRFX+4QRw90x8RDhCdXw= -github.com/codeready-toolchain/api v0.0.0-20231129193441-f6c9b7feee01/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= -github.com/codeready-toolchain/toolchain-common v0.0.0-20231206125932-41dd47e8aa56 h1:W/VrNwL++P6TRw6BqhPfnzaq3YmytBIvestbLDvVv1E= -github.com/codeready-toolchain/toolchain-common v0.0.0-20231206125932-41dd47e8aa56/go.mod h1:cEkJH2jz88KIZt5W8wSnK3Gz6OfszzXv74OIndbTlRE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -428,6 +424,10 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e h1:1p4jHPdkwSARcFuJw2o2uQgfZExsm84kuzr+fb9wCLg= +github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd h1:R43Igwo/4HFk87gTvUgLbXz+OYLfrgHHxJfvBCNdQEk= +github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd/go.mod h1:YW7uwt6yxnN0Nt+fOL2syHjpU7BhCDXiXojkmvnE8qg= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= diff --git a/pkg/controller/signup_test.go b/pkg/controller/signup_test.go index 53ce2303..40775508 100644 --- a/pkg/controller/signup_test.go +++ b/pkg/controller/signup_test.go @@ -97,18 +97,16 @@ func (s *TestSignupSuite) TestSignupPostHandler() { expectedUserID := ob.String() ctx.Set(context.SubKey, expectedUserID) ctx.Set(context.EmailKey, expectedUserID+"@test.com") - email := ctx.GetString(context.EmailKey) signup := &crtapi.UserSignup{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{ Name: userID.String(), Namespace: "namespace-foo", - Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: email, - }, }, Spec: crtapi.UserSignupSpec{ - Username: "bill", + IdentityClaims: crtapi.IdentityClaimsEmbedded{ + PreferredUsername: "bill", + }, }, Status: crtapi.UserSignupStatus{ Conditions: []crtapi.Condition{ @@ -279,7 +277,6 @@ func (s *TestSignupSuite) TestInitVerificationHandler() { Name: userID, Namespace: configuration.Namespace(), Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: "jsmith@redhat.com", crtapi.UserSignupVerificationCounterAnnotationKey: "0", crtapi.UserSignupVerificationCodeAnnotationKey: "", }, @@ -392,9 +389,6 @@ func (s *TestSignupSuite) TestInitVerificationHandler() { ObjectMeta: v1.ObjectMeta{ Name: userID, Namespace: configuration.Namespace(), - Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: "jsmith@redhat.com", - }, }, Spec: crtapi.UserSignupSpec{}, Status: crtapi.UserSignupStatus{}, @@ -436,10 +430,7 @@ func (s *TestSignupSuite) TestInitVerificationHandler() { us := crtapi.UserSignup{ TypeMeta: v1.TypeMeta{}, ObjectMeta: v1.ObjectMeta{ - Name: userID, - Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: "jsmith@redhat.com", - }, + Name: userID, Labels: map[string]string{}, }, Spec: crtapi.UserSignupSpec{}, @@ -483,7 +474,6 @@ func (s *TestSignupSuite) TestVerifyPhoneCodeHandler() { Name: userID, Namespace: configuration.Namespace(), Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: "jsmith@redhat.com", crtapi.UserVerificationAttemptsAnnotationKey: "0", crtapi.UserSignupVerificationCodeAnnotationKey: "999888", crtapi.UserVerificationExpiryAnnotationKey: time.Now().Add(10 * time.Second).Format(service.TimestampLayout), @@ -671,15 +661,18 @@ func (s *TestSignupSuite) TestVerifyPhoneCodeHandler() { Name: "jsmith", Namespace: configuration.Namespace(), Annotations: map[string]string{ - crtapi.UserSignupUserEmailAnnotationKey: "jsmith@acme.com", crtapi.UserVerificationAttemptsAnnotationKey: "0", crtapi.UserSignupVerificationCodeAnnotationKey: "999127", crtapi.UserVerificationExpiryAnnotationKey: time.Now().Add(10 * time.Second).Format(service.TimestampLayout), }, }, Spec: crtapi.UserSignupSpec{ - Userid: otherUserID, - Username: "jsmith", + IdentityClaims: crtapi.IdentityClaimsEmbedded{ + PreferredUsername: "jsmith", + PropagatedClaims: crtapi.PropagatedClaims{ + Sub: otherUserID, + }, + }, }, Status: crtapi.UserSignupStatus{}, } @@ -695,7 +688,7 @@ func (s *TestSignupSuite) TestVerifyPhoneCodeHandler() { Key: "code", Value: "999127", } - rr := initPhoneVerification(s.T(), handler, param, nil, "", otherUserSignup.Spec.Username, http.MethodGet, "/api/v1/signup/verification") + rr := initPhoneVerification(s.T(), handler, param, nil, "", otherUserSignup.Spec.IdentityClaims.PreferredUsername, http.MethodGet, "/api/v1/signup/verification") // Check the status code is what we expect. require.Equal(s.T(), http.StatusOK, rr.Code) diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index 37ba44c0..50f9d79c 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -89,12 +89,14 @@ func (s *TestInformerServiceSuite) TestInformerService() { expected := &toolchainv1alpha1.MasterUserRecord{ Spec: toolchainv1alpha1.MasterUserRecordSpec{ TierName: "deactivate30", - UserID: "john-id", UserAccounts: []toolchainv1alpha1.UserAccountEmbedded{ { TargetCluster: "member1", }, }, + PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ + Sub: "john-id", + }, }, } @@ -353,12 +355,16 @@ func (s *TestInformerServiceSuite) TestInformerService() { expected := &toolchainv1alpha1.UserSignup{ Spec: toolchainv1alpha1.UserSignupSpec{ TargetCluster: "member2", - Username: "foo@redhat.com", - Userid: "foo", - GivenName: "Foo", - FamilyName: "Bar", - Company: "Red Hat", OriginalSub: "sub-key", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "foo@redhat.com", + GivenName: "Foo", + FamilyName: "Bar", + Company: "Red Hat", + PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ + UserID: "foo", + }, + }, }, } diff --git a/pkg/signup/service/signup_service.go b/pkg/signup/service/signup_service.go index be0ce330..951c8a4b 100644 --- a/pkg/signup/service/signup_service.go +++ b/pkg/signup/service/signup_service.go @@ -111,10 +111,7 @@ func (s *ServiceImpl) newUserSignup(ctx *gin.Context) (*toolchainv1alpha1.UserSi Name: EncodeUserIdentifier(ctx.GetString(context.UsernameKey)), Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: userEmail, toolchainv1alpha1.UserSignupVerificationCounterAnnotationKey: "0", - toolchainv1alpha1.SSOUserIDAnnotationKey: userID, - toolchainv1alpha1.SSOAccountIDAnnotationKey: accountID, }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserEmailHashLabelKey: emailHash, @@ -122,11 +119,6 @@ func (s *ServiceImpl) newUserSignup(ctx *gin.Context) (*toolchainv1alpha1.UserSi }, Spec: toolchainv1alpha1.UserSignupSpec{ TargetCluster: "", - Userid: ctx.GetString(context.SubKey), - Username: ctx.GetString(context.UsernameKey), - GivenName: ctx.GetString(context.GivenNameKey), - FamilyName: ctx.GetString(context.FamilyNameKey), - Company: ctx.GetString(context.CompanyKey), OriginalSub: ctx.GetString(context.OriginalSubKey), IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ @@ -408,7 +400,7 @@ func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, provider ResourceProvider, u signupResponse := &signup.Signup{ Name: userSignup.GetName(), - Username: userSignup.Spec.Username, + Username: userSignup.Spec.IdentityClaims.PreferredUsername, } if userSignup.Status.CompliantUsername != "" { signupResponse.CompliantUsername = userSignup.Status.CompliantUsername @@ -521,29 +513,6 @@ func (s *ServiceImpl) auditUserSignupAgainstClaims(ctx *gin.Context, userSignup userSignup.Spec.IdentityClaims = c - // Check the user_id and account_id annotations in the retrieved UserSignup. If either of them are empty, but the - // values exist within the claims of the current user's Access Token then set the values in the UserSignup and update - // the resource. - // FIXME the following code may be removed after all UserSignup records have their IdentityClaims property fully populated - userIDValue, userIDFound := userSignup.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey] - accountIDValue, accountIDFound := userSignup.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey] - - if !userIDFound || userIDValue == "" { - userID := ctx.GetString(context.UserIDKey) - if userID != "" { - userSignup.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey] = userID - updated = true - } - } - - if !accountIDFound || accountIDValue == "" { - accountID := ctx.GetString(context.AccountIDKey) - if accountID != "" { - userSignup.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey] = accountID - updated = true - } - } - return updated } @@ -602,7 +571,7 @@ func (s *ServiceImpl) PhoneNumberAlreadyInUse(userID, username, phoneNumberOrHas return errors.NewInternalError(err, "failed listing userSignups") } for _, signup := range userSignups { - if signup.Spec.Userid != userID && signup.Spec.Username != username && !states.Deactivated(signup) { // nolint:gosec + if signup.Spec.IdentityClaims.Sub != userID && signup.Spec.IdentityClaims.PreferredUsername != username && !states.Deactivated(signup) { // nolint:gosec return errors.NewForbiddenError("cannot re-register with phone number", "phone number already in use") } diff --git a/pkg/signup/service/signup_service_test.go b/pkg/signup/service/signup_service_test.go index edb2b510..b30e9fe2 100644 --- a/pkg/signup/service/signup_service_test.go +++ b/pkg/signup/service/signup_service_test.go @@ -81,16 +81,8 @@ func (s *TestSignupServiceSuite) TestSignup() { val := userSignups.Items[0] require.Equal(s.T(), configuration.Namespace(), val.Namespace) - require.Equal(s.T(), userID.String(), val.Spec.Userid) require.Equal(s.T(), username, val.Name) - require.Equal(s.T(), username, val.Spec.Username) - require.Equal(s.T(), "jane", val.Spec.GivenName) - require.Equal(s.T(), "doe", val.Spec.FamilyName) - require.Equal(s.T(), "red hat", val.Spec.Company) require.True(s.T(), states.VerificationRequired(&val)) - require.Equal(s.T(), "jsmith@gmail.com", val.Annotations[toolchainv1alpha1.UserSignupUserEmailAnnotationKey]) - require.Equal(s.T(), "13349822", val.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.Equal(s.T(), "45983711", val.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey]) require.Equal(s.T(), "a7b1b413c1cbddbcd19a51222ef8e20a", val.Labels[toolchainv1alpha1.UserSignupUserEmailHashLabelKey]) require.Empty(s.T(), val.Annotations[toolchainv1alpha1.SkipAutoCreateSpaceAnnotationKey]) // skip auto create space annotation is not set by default @@ -531,13 +523,8 @@ func (s *TestSignupServiceSuite) TestFailsIfUserSignupNameAlreadyExists() { ObjectMeta: v1.ObjectMeta{ Name: userID.String(), Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "john@gmail.com", - }, - }, - Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "john@gmail.com", }, + Spec: toolchainv1alpha1.UserSignupSpec{}, }) require.NoError(s.T(), err) @@ -706,13 +693,7 @@ func (s *TestSignupServiceSuite) TestOKIfOtherUserBanned() { val := userSignups.Items[0] require.Equal(s.T(), configuration.Namespace(), val.Namespace) require.Equal(s.T(), "jsmith", val.Name) - require.Equal(s.T(), "jsmith", val.Spec.Username) - require.Equal(s.T(), userID.String(), val.Spec.Userid) - require.Equal(s.T(), "", val.Spec.GivenName) - require.Equal(s.T(), "", val.Spec.FamilyName) - require.Equal(s.T(), "", val.Spec.Company) require.False(s.T(), states.ApprovedManually(&val)) - require.Equal(s.T(), "jsmith@gmail.com", val.Annotations[toolchainv1alpha1.UserSignupUserEmailAnnotationKey]) require.Equal(s.T(), "a7b1b413c1cbddbcd19a51222ef8e20a", val.Labels[toolchainv1alpha1.UserSignupUserEmailHashLabelKey]) } @@ -810,9 +791,7 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusNotComplete() { Name: userID.String(), Namespace: configuration.Namespace(), }, - Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "bill", - }, + Spec: toolchainv1alpha1.UserSignupSpec{}, Status: toolchainv1alpha1.UserSignupStatus{ CompliantUsername: "bill", Conditions: []toolchainv1alpha1.Condition{ @@ -949,7 +928,7 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusNotComplete() { // when // we set checkUserSignupCompleted to false - response, err := svc.GetSignupFromInformer(c, userID.String(), userSignupNotComplete.Spec.Username, false) + response, err := svc.GetSignupFromInformer(c, userID.String(), userSignupNotComplete.Spec.IdentityClaims.PreferredUsername, false) // then require.NoError(s.T(), err) @@ -1013,9 +992,7 @@ func (s *TestSignupServiceSuite) TestGetSignupNoStatusNotCompleteCondition() { Name: userID.String(), Namespace: configuration.Namespace(), }, - Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "bill", - }, + Spec: toolchainv1alpha1.UserSignupSpec{}, Status: status, } @@ -1248,7 +1225,7 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() { s.ServiceConfiguration(configuration.Namespace(), true, "", 5) us := s.newUserSignupComplete() - us.Name = service.EncodeUserIdentifier(us.Spec.Username) + us.Name = service.EncodeUserIdentifier(us.Spec.IdentityClaims.PreferredUsername) err := s.FakeUserSignupClient.Tracker.Add(us) require.NoError(s.T(), err) @@ -1271,7 +1248,7 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() { require.NoError(s.T(), err) // when - response, err := s.Application.SignupService().GetSignup(c, "foo", us.Spec.Username) + response, err := s.Application.SignupService().GetSignup(c, "foo", us.Spec.IdentityClaims.PreferredUsername) // then require.NoError(s.T(), err) @@ -1326,7 +1303,7 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() { ) // when - response, err := svc.GetSignupFromInformer(c, "foo", us.Spec.Username, true) + response, err := svc.GetSignupFromInformer(c, "foo", us.Spec.IdentityClaims.PreferredUsername, true) // then require.NoError(s.T(), err) @@ -1842,12 +1819,12 @@ func (s *TestSignupServiceSuite) TestUpdateUserSignup() { val, err := s.Application.SignupService().GetUserSignupFromIdentifier(us.Name, "") require.NoError(s.T(), err) - val.Spec.FamilyName = "Johnson" + val.Spec.IdentityClaims.FamilyName = "Johnson" updated, err := s.Application.SignupService().UpdateUserSignup(val) require.NoError(s.T(), err) - require.Equal(s.T(), val.Spec.FamilyName, updated.Spec.FamilyName) + require.Equal(s.T(), val.Spec.IdentityClaims.FamilyName, updated.Spec.IdentityClaims.FamilyName) }) s.Run("updateusersignup returns error", func() { @@ -1973,206 +1950,6 @@ func (s *TestSignupServiceSuite) TestIsPhoneVerificationRequired() { } -func (s *TestSignupServiceSuite) TestGetSignupUpdatesUserSignupAnnotationsAndIdentityClaims() { - - s.ServiceConfiguration(configuration.Namespace(), false, "", 5) - - // Create a new UserSignup, set its UserID and AccountID annotations - userSignup := s.newUserSignupComplete() - - err := s.FakeUserSignupClient.Tracker.Add(userSignup) - require.NoError(s.T(), err) - - mur := &toolchainv1alpha1.MasterUserRecord{ - TypeMeta: v1.TypeMeta{}, - ObjectMeta: v1.ObjectMeta{ - Name: userSignup.Status.CompliantUsername, - Namespace: configuration.Namespace(), - }, - Spec: toolchainv1alpha1.MasterUserRecordSpec{ - UserAccounts: []toolchainv1alpha1.UserAccountEmbedded{{TargetCluster: "member-123"}}, - }, - Status: toolchainv1alpha1.MasterUserRecordStatus{ - Conditions: []toolchainv1alpha1.Condition{ - { - Type: toolchainv1alpha1.MasterUserRecordReady, - Status: "true", - }, - }, - }, - } - err = s.FakeMasterUserRecordClient.Tracker.Add(mur) - require.NoError(s.T(), err) - - s.Run("confirm nothing changed when context empty", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.NotContains(s.T(), modified.Annotations, toolchainv1alpha1.SSOUserIDAnnotationKey) - require.NotContains(s.T(), modified.Annotations, toolchainv1alpha1.SSOAccountIDAnnotationKey) - }) - - s.Run("userID annotation updated when set in context", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - c.Set(context.UserIDKey, "888888") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "888888", modified.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.NotContains(s.T(), modified.Annotations, toolchainv1alpha1.SSOAccountIDAnnotationKey) - }) - - s.Run("confirm nothing changed when context nil", func() { - _, err := s.Application.SignupService().GetSignup(nil, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "888888", modified.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.NotContains(s.T(), modified.Annotations, toolchainv1alpha1.SSOAccountIDAnnotationKey) - }) - - s.Run("accountID annotation updated when set in context and some update attempts fail", func() { - counter := 0 - s.FakeUserSignupClient.MockUpdate = func(value *toolchainv1alpha1.UserSignup) (userSignup *toolchainv1alpha1.UserSignup, e error) { - counter++ - if counter < 3 { - s.FakeUserSignupClient.MockUpdate = nil - return s.FakeUserSignupClient.Update(value) - } - return value, nil - } - defer func() { - s.FakeUserSignupClient.MockUpdate = nil - }() - - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - // Set the userID context value to empty string - c.Set(context.UserIDKey, "") - c.Set(context.AccountIDKey, "1234567890") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - // Confirm that the userID annotation wasn't updated - require.Equal(s.T(), "888888", modified.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.Equal(s.T(), "1234567890", modified.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey]) - }) - - s.Run("userID and accountID annotations not overridden when already set and context values different", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - // Set the userID and accountID context values to different values - c.Set(context.UserIDKey, "7777777") - c.Set(context.AccountIDKey, "0987654321") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - // Confirm that both annotations are NOT updated - require.Equal(s.T(), "888888", modified.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.Equal(s.T(), "1234567890", modified.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey]) - }) - - s.Run("userID and accountID annotations not overridden when already set and context values are the same", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - // Set the userID and accountID context values to same values - c.Set(context.UserIDKey, "888888") - c.Set(context.AccountIDKey, "1234567890") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - // Confirm that both annotations are still not updated - require.Equal(s.T(), "888888", modified.Annotations[toolchainv1alpha1.SSOUserIDAnnotationKey]) - require.Equal(s.T(), "1234567890", modified.Annotations[toolchainv1alpha1.SSOAccountIDAnnotationKey]) - }) - - s.Run("PreferredUsername property updated when set in context", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - c.Set(context.UsernameKey, "cocochanel") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "cocochanel", modified.Spec.IdentityClaims.PreferredUsername) - - s.Run("GivenName property updated when set in context", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - c.Set(context.GivenNameKey, "Jonathan") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "Jonathan", modified.Spec.IdentityClaims.GivenName) - - // Confirm that some other properties were not changed - require.Equal(s.T(), "cocochanel", modified.Spec.IdentityClaims.PreferredUsername) - require.Equal(s.T(), "1234567890", modified.Spec.IdentityClaims.AccountID) - }) - }) - - s.Run("FamilyName and Company properties updated when set in context", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - c.Set(context.FamilyNameKey, "Smythe") - c.Set(context.CompanyKey, "Red Hat") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "Smythe", modified.Spec.IdentityClaims.FamilyName) - require.Equal(s.T(), "Red Hat", modified.Spec.IdentityClaims.Company) - }) - - s.Run("Remaining properties updated when set in context", func() { - c, _ := gin.CreateTestContext(httptest.NewRecorder()) - c.Set(context.SubKey, "987654321") - c.Set(context.UserIDKey, "123456777") - c.Set(context.AccountIDKey, "777654321") - c.Set(context.OriginalSubKey, "jsmythe-original-sub") - c.Set(context.EmailKey, "jsmythe@redhat.com") - - _, err := s.Application.SignupService().GetSignup(c, userSignup.Name, userSignup.Spec.Username) - require.NoError(s.T(), err) - - modified, err := s.FakeUserSignupClient.Get(userSignup.Name) - require.NoError(s.T(), err) - - require.Equal(s.T(), "987654321", modified.Spec.IdentityClaims.Sub) - require.Equal(s.T(), "123456777", modified.Spec.IdentityClaims.UserID) - require.Equal(s.T(), "777654321", modified.Spec.IdentityClaims.AccountID) - require.Equal(s.T(), "jsmythe-original-sub", modified.Spec.IdentityClaims.OriginalSub) - require.Equal(s.T(), "jsmythe@redhat.com", modified.Spec.IdentityClaims.Email) - }) - -} - func (s *TestSignupServiceSuite) newUserSignupComplete() *toolchainv1alpha1.UserSignup { return s.newUserSignupCompleteWithReason("") } @@ -2185,12 +1962,8 @@ func (s *TestSignupServiceSuite) newUserSignupCompleteWithReason(reason string) ObjectMeta: v1.ObjectMeta{ Name: userID.String(), Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "ted@domain.com", - }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "ted@domain.com", IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ Sub: "123456789", diff --git a/pkg/verification/service/verification_service_test.go b/pkg/verification/service/verification_service_test.go index ad507e01..d7e888c5 100644 --- a/pkg/verification/service/verification_service_test.go +++ b/pkg/verification/service/verification_service_test.go @@ -141,15 +141,14 @@ func (s *TestVerificationServiceSuite) TestInitVerification() { ObjectMeta: metav1.ObjectMeta{ Name: "123", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", - }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserPhoneHashLabelKey: "+1NUMBER", }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "sbryzak@redhat.com", + }, }, } @@ -160,15 +159,14 @@ func (s *TestVerificationServiceSuite) TestInitVerification() { ObjectMeta: metav1.ObjectMeta{ Name: "jsmith", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "jsmith@redhat.com", - }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserPhoneHashLabelKey: "+61NUMBER", }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "jsmith", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "jsmith", + }, }, } @@ -185,7 +183,7 @@ func (s *TestVerificationServiceSuite) TestInitVerification() { // Test the init verification for the first UserSignup ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.NoError(s.T(), err) userSignup, err = s.FakeUserSignupClient.Get(userSignup.Name) @@ -220,7 +218,7 @@ func (s *TestVerificationServiceSuite) TestInitVerification() { ctx, _ = gin.CreateTestContext(httptest.NewRecorder()) // This time we won't pass in the UserID, just the username yet still expect the UserSignup to be found - err = s.Application.VerificationService().InitVerification(ctx, "", userSignup2.Spec.Username, "+61NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, "", userSignup2.Spec.IdentityClaims.PreferredUsername, "+61NUMBER", "1") require.NoError(s.T(), err) userSignup2, err = s.FakeUserSignupClient.Get(userSignup2.Name) @@ -283,15 +281,14 @@ func (s *TestVerificationServiceSuite) TestInitVerificationClientFailure() { ObjectMeta: metav1.ObjectMeta{ Name: "123", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", - }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserPhoneHashLabelKey: "+1NUMBER", }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -309,7 +306,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationClientFailure() { defer func() { s.FakeUserSignupClient.MockGet = nil }() ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.EqualError(s.T(), err, "get failed: error retrieving usersignup: 123", err.Error()) }) @@ -322,7 +319,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationClientFailure() { defer func() { s.FakeUserSignupClient.MockUpdate = nil }() ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.EqualError(s.T(), err, "there was an error while updating your account - please wait a moment before "+ "trying again. If this error persists, please contact the Developer Sandbox team at devsandbox@redhat.com "+ "for assistance: error while verifying phone code") @@ -344,7 +341,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationClientFailure() { defer func() { s.FakeUserSignupClient.MockUpdate = nil }() ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.NoError(s.T(), err) userSignup, err = s.FakeUserSignupClient.Get(userSignup.Name) @@ -391,7 +388,6 @@ func (s *TestVerificationServiceSuite) TestInitVerificationPassesWhenMaxCountRea Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "testuser@redhat.com", toolchainv1alpha1.UserSignupVerificationInitTimestampAnnotationKey: now.Add(-25 * time.Hour).Format(verificationservice.TimestampLayout), toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "3", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", @@ -401,7 +397,9 @@ func (s *TestVerificationServiceSuite) TestInitVerificationPassesWhenMaxCountRea }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } states.SetVerificationRequired(userSignup, true) @@ -410,7 +408,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationPassesWhenMaxCountRea require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.NoError(s.T(), err) userSignup, err = s.FakeUserSignupClient.Get(userSignup.Name) @@ -449,7 +447,6 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenCountContain Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "testuser@redhat.com", toolchainv1alpha1.UserSignupVerificationCounterAnnotationKey: "abc", toolchainv1alpha1.UserSignupVerificationInitTimestampAnnotationKey: now.Format(verificationservice.TimestampLayout), }, @@ -458,7 +455,9 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenCountContain }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } states.SetVerificationRequired(userSignup, true) @@ -467,7 +466,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenCountContain require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.EqualError(s.T(), err, "daily limit exceeded: cannot generate new verification code") } @@ -491,7 +490,6 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsDailyCounterExce Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "testuser@redhat.com", toolchainv1alpha1.UserSignupVerificationCounterAnnotationKey: strconv.Itoa(cfg.Verification().DailyLimit()), toolchainv1alpha1.UserSignupVerificationInitTimestampAnnotationKey: now.Format(verificationservice.TimestampLayout), }, @@ -500,7 +498,9 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsDailyCounterExce }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } states.SetVerificationRequired(userSignup, true) @@ -509,7 +509,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsDailyCounterExce require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.Username, "+1NUMBER", "1") + err = s.Application.VerificationService().InitVerification(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "+1NUMBER", "1") require.EqualError(s.T(), err, "daily limit exceeded: cannot generate new verification code", err.Error()) require.Empty(s.T(), userSignup.Annotations[toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey]) } @@ -535,15 +535,14 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenPhoneNumberI ObjectMeta: metav1.ObjectMeta{ Name: "alpha", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "alpha@foxtrot.com", - }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserPhoneHashLabelKey: phoneHash, }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "alpha@foxtrot.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "alpha@foxtrot.com", + }, }, } states.SetApprovedManually(alphaUserSignup, true) @@ -556,13 +555,12 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenPhoneNumberI ObjectMeta: metav1.ObjectMeta{ Name: "bravo", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "bravo@foxtrot.com", - }, - Labels: map[string]string{}, + Labels: map[string]string{}, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "bravo@foxtrot.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "bravo@foxtrot.com", + }, }, } states.SetVerificationRequired(bravoUserSignup, true) @@ -571,7 +569,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationFailsWhenPhoneNumberI require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, bravoUserSignup.Name, bravoUserSignup.Spec.Username, e164PhoneNumber, "1") + err = s.Application.VerificationService().InitVerification(ctx, bravoUserSignup.Name, bravoUserSignup.Spec.IdentityClaims.PreferredUsername, e164PhoneNumber, "1") require.Error(s.T(), err) require.Equal(s.T(), "phone number already in use: cannot register using phone number: +19875551122", err.Error()) @@ -603,16 +601,15 @@ func (s *TestVerificationServiceSuite) TestInitVerificationOKWhenPhoneNumberInUs ObjectMeta: metav1.ObjectMeta{ Name: "alpha", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "alpha@foxtrot.com", - }, Labels: map[string]string{ toolchainv1alpha1.UserSignupUserPhoneHashLabelKey: phoneHash, toolchainv1alpha1.UserSignupStateLabelKey: toolchainv1alpha1.UserSignupStateLabelValueDeactivated, }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "alpha@foxtrot.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "alpha@foxtrot.com", + }, }, } states.SetApprovedManually(alphaUserSignup, true) @@ -626,13 +623,12 @@ func (s *TestVerificationServiceSuite) TestInitVerificationOKWhenPhoneNumberInUs ObjectMeta: metav1.ObjectMeta{ Name: "bravo", Namespace: configuration.Namespace(), - Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "bravo@foxtrot.com", - }, - Labels: map[string]string{}, + Labels: map[string]string{}, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "bravo@foxtrot.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "bravo@foxtrot.com", + }, }, } states.SetVerificationRequired(bravoUserSignup, true) @@ -641,7 +637,7 @@ func (s *TestVerificationServiceSuite) TestInitVerificationOKWhenPhoneNumberInUs require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().InitVerification(ctx, bravoUserSignup.Name, bravoUserSignup.Spec.Username, e164PhoneNumber, "1") + err = s.Application.VerificationService().InitVerification(ctx, bravoUserSignup.Name, bravoUserSignup.Spec.IdentityClaims.PreferredUsername, e164PhoneNumber, "1") require.NoError(s.T(), err) // Reload bravoUserSignup @@ -663,7 +659,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupCaptchaScoreAnnotationKey: "0.8", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", @@ -674,7 +669,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } states.SetVerificationRequired(userSignup, true) @@ -683,7 +680,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") require.NoError(s.T(), err) userSignup, err = s.FakeUserSignupClient.Get(userSignup.Name) @@ -699,7 +696,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "employee085", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "employee085@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupCaptchaScoreAnnotationKey: "0.7", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "654321", @@ -710,7 +706,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "employee085@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "employee085@redhat.com", + }, }, } states.SetVerificationRequired(userSignup, true) @@ -735,7 +733,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "000000", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: now.Add(10 * time.Second).Format(verificationservice.TimestampLayout), @@ -745,7 +742,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -756,7 +755,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") require.Error(s.T(), err) e := &crterrors.Error{} require.True(s.T(), errors.As(err, &e)) @@ -771,7 +770,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: now.Add(-10 * time.Second).Format(verificationservice.TimestampLayout), @@ -781,7 +779,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -791,7 +791,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") e := &crterrors.Error{} require.True(s.T(), errors.As(err, &e)) require.Equal(s.T(), "expired: verification code expired", e.Error()) @@ -805,7 +805,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "3", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: now.Add(10 * time.Second).Format(verificationservice.TimestampLayout), @@ -815,7 +814,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -825,7 +826,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") require.EqualError(s.T(), err, "too many verification attempts", err.Error()) }) @@ -836,7 +837,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "ABC", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: now.Add(10 * time.Second).Format(verificationservice.TimestampLayout), @@ -846,7 +846,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -856,7 +858,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") require.EqualError(s.T(), err, "too many verification attempts", err.Error()) userSignup, err = s.FakeUserSignupClient.Get(userSignup.Name) @@ -872,7 +874,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: "ABC", @@ -882,7 +883,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } @@ -892,7 +895,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") require.EqualError(s.T(), err, "parsing time \"ABC\" as \"2006-01-02T15:04:05.000Z07:00\": cannot parse \"ABC\" as \"2006\": error parsing expiry timestamp", err.Error()) }) @@ -978,7 +981,6 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { Name: "123", Namespace: configuration.Namespace(), Annotations: map[string]string{ - toolchainv1alpha1.UserSignupUserEmailAnnotationKey: "sbryzak@redhat.com", toolchainv1alpha1.UserVerificationAttemptsAnnotationKey: "0", toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey: "123456", toolchainv1alpha1.UserVerificationExpiryAnnotationKey: now.Add(10 * time.Minute).Format(verificationservice.TimestampLayout), @@ -988,7 +990,9 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { }, }, Spec: toolchainv1alpha1.UserSignupSpec{ - Username: "sbryzak@redhat.com", + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "shane@redhat.com", + }, }, } if tc.activationCounterAnnotationValue != "" { @@ -1010,7 +1014,7 @@ func (s *TestVerificationServiceSuite) TestVerifyPhoneCode() { require.NoError(s.T(), err) ctx, _ := gin.CreateTestContext(httptest.NewRecorder()) - err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.Username, "123456") + err = s.Application.VerificationService().VerifyPhoneCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "123456") // then if tc.expectedErr != "" { @@ -1043,7 +1047,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.NoError(t, err) @@ -1060,7 +1064,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.NoError(t, err) @@ -1079,7 +1083,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.EqualError(t, err, "too many verification attempts: 3") @@ -1097,7 +1101,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, "invalid") + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "invalid") // then require.EqualError(t, err, "invalid code: the provided code is invalid") @@ -1116,7 +1120,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, "invalid") + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, "invalid") // then require.EqualError(t, err, "invalid code: the provided code is invalid") @@ -1135,7 +1139,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.EqualError(t, err, "invalid code: the event is full") @@ -1153,7 +1157,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.EqualError(t, err, "invalid code: the provided code is invalid") @@ -1171,7 +1175,7 @@ func (s *TestVerificationServiceSuite) TestVerifyActivationCode() { require.NoError(t, err) // when - err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.Username, event.Name) + err = s.Application.VerificationService().VerifyActivationCode(ctx, userSignup.Name, userSignup.Spec.IdentityClaims.PreferredUsername, event.Name) // then require.EqualError(t, err, "invalid code: the provided code is invalid") From 67a0367164216facb5d94ad18435566b9c846f99 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 7 Jan 2024 16:00:42 +1000 Subject: [PATCH 02/12] updated toolchain-common --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8c1caa28..8ea1f5ca 100644 --- a/go.mod +++ b/go.mod @@ -148,4 +148,4 @@ require ( replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e -replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd +replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20240107055000-3d9023112235 diff --git a/go.sum b/go.sum index 60c48913..80714554 100644 --- a/go.sum +++ b/go.sum @@ -426,8 +426,8 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e h1:1p4jHPdkwSARcFuJw2o2uQgfZExsm84kuzr+fb9wCLg= github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= -github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd h1:R43Igwo/4HFk87gTvUgLbXz+OYLfrgHHxJfvBCNdQEk= -github.com/sbryzak/toolchain-common v0.0.0-20231231220541-48116bc60abd/go.mod h1:YW7uwt6yxnN0Nt+fOL2syHjpU7BhCDXiXojkmvnE8qg= +github.com/sbryzak/toolchain-common v0.0.0-20240107055000-3d9023112235 h1:VRdgqqhAy55aJqzfzonjs+KyPeZuiijcsaRd6VYGIyk= +github.com/sbryzak/toolchain-common v0.0.0-20240107055000-3d9023112235/go.mod h1:s76M4eSzRUx7cL/Mvch2gx0fb5jTW+xYqFlfX+aSuME= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= From cb06df337a6c8098fe0591c8858dfe978e5964f3 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 28 Jan 2024 15:52:21 +1000 Subject: [PATCH 03/12] updated dependencies --- go.mod | 2 +- go.sum | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 8ea1f5ca..2a0014af 100644 --- a/go.mod +++ b/go.mod @@ -148,4 +148,4 @@ require ( replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e -replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20240107055000-3d9023112235 + diff --git a/go.sum b/go.sum index 80714554..7ad0e15b 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,7 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/codeready-toolchain/toolchain-common v0.0.0-20231206125932-41dd47e8aa56/go.mod h1:cEkJH2jz88KIZt5W8wSnK3Gz6OfszzXv74OIndbTlRE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From bd89ba1444b61656063734fadfef812d46613821 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 28 Jan 2024 15:58:17 +1000 Subject: [PATCH 04/12] fixed go.sum --- go.sum | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/go.sum b/go.sum index 7f1b739e..ea2905c3 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,6 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240115235114-36095a5f2acc h1:tiRzD0Xasn/o2aBfZttt/O9Dw5S/13dY3dtqJ5wvu5I= -github.com/codeready-toolchain/toolchain-common v0.0.0-20240115235114-36095a5f2acc/go.mod h1:9YS35niqlaKOpGTKX9RoXhonHopTkwH9W4C9Bcg7ZjM= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -428,9 +426,9 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e h1:1p4jHPdkwSARcFuJw2o2uQgfZExsm84kuzr+fb9wCLg= -github.com/sbryzak/api v0.0.0-20240102042357-82134b76d69e/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/sbryzak/api v0.0.0-20240122043958-5766c6177c5f h1:Yy4DgctB2UhAtKdCTJlNSs0eOlMlrcOFEaGlO7NGY9E= github.com/sbryzak/api v0.0.0-20240122043958-5766c6177c5f/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 h1:+M6r5HekZ3z5N/v1aZEjlkhwumlZAtvCBZEEEsnV3Tk= github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0/go.mod h1:vuxDx4HKxnb8xJV21OufzRhh/6qNP46stTkn2ni06UY= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= From e2b5f426dd92565e4247afbb7d960affcf698cf9 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 28 Jan 2024 16:51:10 +1000 Subject: [PATCH 05/12] fixed some tests --- pkg/informers/service/informer_service_test.go | 8 ++++---- pkg/signup/service/signup_service_test.go | 12 ++++++++---- pkg/verification/service/verification_service.go | 8 ++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index 50f9d79c..eaddc17b 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -106,7 +106,7 @@ func (s *TestInformerServiceSuite) TestInformerService() { // then require.NotNil(s.T(), val) require.NoError(s.T(), err) - assert.Equal(s.T(), val, expected) + assert.Equal(s.T(), expected, val) }) }) @@ -166,7 +166,7 @@ func (s *TestInformerServiceSuite) TestInformerService() { // then require.NotNil(s.T(), val) require.NoError(s.T(), err) - assert.Equal(s.T(), val, expected) + assert.Equal(s.T(), expected, val) }) }) @@ -355,14 +355,14 @@ func (s *TestInformerServiceSuite) TestInformerService() { expected := &toolchainv1alpha1.UserSignup{ Spec: toolchainv1alpha1.UserSignupSpec{ TargetCluster: "member2", - OriginalSub: "sub-key", IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ PreferredUsername: "foo@redhat.com", GivenName: "Foo", FamilyName: "Bar", Company: "Red Hat", PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ - UserID: "foo", + UserID: "foo", + OriginalSub: "sub-key", }, }, }, diff --git a/pkg/signup/service/signup_service_test.go b/pkg/signup/service/signup_service_test.go index aaeb91f9..26664c09 100644 --- a/pkg/signup/service/signup_service_test.go +++ b/pkg/signup/service/signup_service_test.go @@ -992,7 +992,11 @@ func (s *TestSignupServiceSuite) TestGetSignupNoStatusNotCompleteCondition() { Name: userID.String(), Namespace: configuration.Namespace(), }, - Spec: toolchainv1alpha1.UserSignupSpec{}, + Spec: toolchainv1alpha1.UserSignupSpec{ + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "bill", + }, + }, Status: status, } @@ -1002,7 +1006,7 @@ func (s *TestSignupServiceSuite) TestGetSignupNoStatusNotCompleteCondition() { require.NoError(s.T(), err) // when - response, err := s.Application.SignupService().GetSignup(c, userID.String(), "") + response, err := s.Application.SignupService().GetSignup(c, userID.String(), "bill") // then require.NoError(s.T(), err) @@ -1255,7 +1259,7 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() { require.NotNil(s.T(), response) require.Equal(s.T(), us.Name, response.Name) - require.Equal(s.T(), "ted@domain.com", response.Username) + require.Equal(s.T(), "jsmith", response.Username) require.Equal(s.T(), "ted", response.CompliantUsername) assert.True(s.T(), response.Status.Ready) assert.Equal(s.T(), "mur_ready_reason", response.Status.Reason) @@ -1310,7 +1314,7 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() { require.NotNil(s.T(), response) require.Equal(s.T(), us.Name, response.Name) - require.Equal(s.T(), "ted@domain.com", response.Username) + require.Equal(s.T(), "jsmith", response.Username) require.Equal(s.T(), "ted", response.CompliantUsername) assert.True(s.T(), response.Status.Ready) assert.Equal(s.T(), "mur_ready_reason", response.Status.Reason) diff --git a/pkg/verification/service/verification_service.go b/pkg/verification/service/verification_service.go index a2f4690e..3a1f3461 100644 --- a/pkg/verification/service/verification_service.go +++ b/pkg/verification/service/verification_service.go @@ -172,6 +172,10 @@ func (s *ServiceImpl) InitVerification(ctx *gin.Context, userID, username, e164P signup.Labels = map[string]string{} } + if signup.Annotations == nil { + signup.Annotations = map[string]string{} + } + for k, v := range labelValues { signup.Labels[k] = v } @@ -320,6 +324,10 @@ func (s *ServiceImpl) VerifyPhoneCode(ctx *gin.Context, userID, username, code s return err } + if signup.Annotations == nil { + signup.Annotations = map[string]string{} + } + if unsetVerificationRequired { states.SetVerificationRequired(signup, false) } From ca453f0197b3d865ca1bccb145e6c577fd9041a9 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 28 Jan 2024 18:49:21 +1000 Subject: [PATCH 06/12] fixed some more tests --- .../service/informer_service_test.go | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index eaddc17b..332f41bd 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -43,6 +43,9 @@ func (s *TestInformerServiceSuite) TestInformerService() { "spec": map[string]interface{}{ "tierName": "deactivate30", "userID": "john-id", + "propagatedClaims": map[string]interface{}{ + "sub": "john-id", + }, "userAccounts": []map[string]interface{}{ { "targetCluster": "member1", @@ -55,7 +58,9 @@ func (s *TestInformerServiceSuite) TestInformerService() { Object: map[string]interface{}{ "spec": map[string]interface{}{ "tierName": "deactivate30", - "userID": "noise-id", + "propagatedClaims": map[string]interface{}{ + "sub": "noise-id", + }, "userAccounts": []map[string]interface{}{ { "targetCluster": "member2", @@ -307,12 +312,16 @@ func (s *TestInformerServiceSuite) TestInformerService() { Object: map[string]interface{}{ "spec": map[string]interface{}{ "targetCluster": "member2", - "username": "foo@redhat.com", - "userid": "foo", - "givenName": "Foo", - "familyName": "Bar", - "company": "Red Hat", - "originalSub": "sub-key", + "identityClaims": map[string]interface{}{ + "propagatedClaims": map[string]interface{}{ + "sub": "foo", + "originalSub": "sub-key", + }, + "preferredUsername": "foo@redhat.com", + "givenName": "Foo", + "familyName": "Bar", + "company": "Red Hat", + }, }, }, }, @@ -320,12 +329,16 @@ func (s *TestInformerServiceSuite) TestInformerService() { Object: map[string]interface{}{ "spec": map[string]interface{}{ "targetCluster": "member1", - "username": "noise@redhat.com", - "userid": "noise", - "givenName": "Noise", - "familyName": "Make", - "company": "Noisy", - "originalSub": "noise-key", + "identityClaims": map[string]interface{}{ + "propagatedClaims": map[string]interface{}{ + "sub": "noise", + "originalSub": "noise-key", + }, + "preferredUsername": "noise@redhat.com", + "givenName": "Noise", + "familyName": "Make", + "company": "Noisy", + }, }, }, }, @@ -361,7 +374,7 @@ func (s *TestInformerServiceSuite) TestInformerService() { FamilyName: "Bar", Company: "Red Hat", PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ - UserID: "foo", + Sub: "foo", OriginalSub: "sub-key", }, }, @@ -374,7 +387,7 @@ func (s *TestInformerServiceSuite) TestInformerService() { // then require.NotNil(s.T(), val) require.NoError(s.T(), err) - assert.Equal(s.T(), val, expected) + assert.Equal(s.T(), expected, val) }) }) From b6e5b1235e18fdec72fa02a8e6d98cb0902cfa62 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 28 Jan 2024 22:28:29 +1000 Subject: [PATCH 07/12] fixed more tests --- pkg/informers/service/informer_service_test.go | 2 +- pkg/signup/service/signup_service_test.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index 332f41bd..a08d140f 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -313,7 +313,7 @@ func (s *TestInformerServiceSuite) TestInformerService() { "spec": map[string]interface{}{ "targetCluster": "member2", "identityClaims": map[string]interface{}{ - "propagatedClaims": map[string]interface{}{ + "PropagatedClaims": map[string]interface{}{ "sub": "foo", "originalSub": "sub-key", }, diff --git a/pkg/signup/service/signup_service_test.go b/pkg/signup/service/signup_service_test.go index 26664c09..804c4e4e 100644 --- a/pkg/signup/service/signup_service_test.go +++ b/pkg/signup/service/signup_service_test.go @@ -791,7 +791,11 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusNotComplete() { Name: userID.String(), Namespace: configuration.Namespace(), }, - Spec: toolchainv1alpha1.UserSignupSpec{}, + Spec: toolchainv1alpha1.UserSignupSpec{ + IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ + PreferredUsername: "bill", + }, + }, Status: toolchainv1alpha1.UserSignupStatus{ CompliantUsername: "bill", Conditions: []toolchainv1alpha1.Condition{ @@ -1152,7 +1156,7 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusOK() { require.NotNil(s.T(), response) require.Equal(s.T(), us.Name, response.Name) - require.Equal(s.T(), "ted@domain.com", response.Username) + require.Equal(s.T(), "jsmith", response.Username) require.Equal(s.T(), "ted", response.CompliantUsername) assert.True(s.T(), response.Status.Ready) assert.Equal(s.T(), "mur_ready_reason", response.Status.Reason) @@ -1206,7 +1210,7 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusOK() { require.NoError(s.T(), err) require.NotNil(s.T(), response) - require.Equal(s.T(), "ted@domain.com", response.Username) + require.Equal(s.T(), "jsmith", response.Username) require.Equal(s.T(), "ted", response.CompliantUsername) assert.True(s.T(), response.Status.Ready) assert.Equal(s.T(), "mur_ready_reason", response.Status.Reason) From c15dc911ba9470dd25c1deb5318be78f0dd40ad2 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Tue, 30 Jan 2024 06:24:25 +1000 Subject: [PATCH 08/12] fixed test --- go.mod | 2 +- go.sum | 4 ++-- pkg/informers/service/informer_service_test.go | 12 ++++-------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index f783b91e..d53a5cd9 100644 --- a/go.mod +++ b/go.mod @@ -147,6 +147,6 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) -replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240122043958-5766c6177c5f +replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48 replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 diff --git a/go.sum b/go.sum index ea2905c3..ea816456 100644 --- a/go.sum +++ b/go.sum @@ -426,8 +426,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/sbryzak/api v0.0.0-20240122043958-5766c6177c5f h1:Yy4DgctB2UhAtKdCTJlNSs0eOlMlrcOFEaGlO7NGY9E= -github.com/sbryzak/api v0.0.0-20240122043958-5766c6177c5f/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48 h1:+rBh367F0wNcfNrp7Z7gGcoRM+nPfjAiu6RkvojvPk0= +github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 h1:+M6r5HekZ3z5N/v1aZEjlkhwumlZAtvCBZEEEsnV3Tk= github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0/go.mod h1:vuxDx4HKxnb8xJV21OufzRhh/6qNP46stTkn2ni06UY= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index a08d140f..faef2aaf 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -313,10 +313,8 @@ func (s *TestInformerServiceSuite) TestInformerService() { "spec": map[string]interface{}{ "targetCluster": "member2", "identityClaims": map[string]interface{}{ - "PropagatedClaims": map[string]interface{}{ - "sub": "foo", - "originalSub": "sub-key", - }, + "sub": "foo", + "originalSub": "sub-key", "preferredUsername": "foo@redhat.com", "givenName": "Foo", "familyName": "Bar", @@ -330,10 +328,8 @@ func (s *TestInformerServiceSuite) TestInformerService() { "spec": map[string]interface{}{ "targetCluster": "member1", "identityClaims": map[string]interface{}{ - "propagatedClaims": map[string]interface{}{ - "sub": "noise", - "originalSub": "noise-key", - }, + "sub": "noise", + "originalSub": "noise-key", "preferredUsername": "noise@redhat.com", "givenName": "Noise", "familyName": "Make", From 583006ae0fd54c9d8f0eee97fadae3c34439ca21 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sat, 3 Feb 2024 22:04:26 +1000 Subject: [PATCH 09/12] minor --- go.mod | 2 +- go.sum | 4 ++-- pkg/signup/service/signup_service.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d53a5cd9..8abac5c2 100644 --- a/go.mod +++ b/go.mod @@ -147,6 +147,6 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) -replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48 +replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 diff --git a/go.sum b/go.sum index ea816456..b9e079f7 100644 --- a/go.sum +++ b/go.sum @@ -426,8 +426,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48 h1:+rBh367F0wNcfNrp7Z7gGcoRM+nPfjAiu6RkvojvPk0= -github.com/sbryzak/api v0.0.0-20240129201259-6f21cc1f6f48/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e h1:KFtfY3vwtRWyJYcpYUXieKtbFB7wepm/cOCpJneI2ew= +github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 h1:+M6r5HekZ3z5N/v1aZEjlkhwumlZAtvCBZEEEsnV3Tk= github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0/go.mod h1:vuxDx4HKxnb8xJV21OufzRhh/6qNP46stTkn2ni06UY= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= diff --git a/pkg/signup/service/signup_service.go b/pkg/signup/service/signup_service.go index 3a760ced..f8ffb9c2 100644 --- a/pkg/signup/service/signup_service.go +++ b/pkg/signup/service/signup_service.go @@ -126,7 +126,7 @@ func (s *ServiceImpl) newUserSignup(ctx *gin.Context) (*toolchainv1alpha1.UserSi UserID: ctx.GetString(context.UserIDKey), AccountID: ctx.GetString(context.AccountIDKey), OriginalSub: ctx.GetString(context.OriginalSubKey), - Email: ctx.GetString(context.EmailKey), + Email: userEmail, }, PreferredUsername: ctx.GetString(context.UsernameKey), GivenName: ctx.GetString(context.GivenNameKey), From f44629d98b25e7f638e2538e48f20842f4a129a0 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 4 Feb 2024 15:59:32 +1000 Subject: [PATCH 10/12] fix merge --- pkg/signup/service/signup_service_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/signup/service/signup_service_test.go b/pkg/signup/service/signup_service_test.go index ad895cab..804c4e4e 100644 --- a/pkg/signup/service/signup_service_test.go +++ b/pkg/signup/service/signup_service_test.go @@ -82,13 +82,6 @@ func (s *TestSignupServiceSuite) TestSignup() { val := userSignups.Items[0] require.Equal(s.T(), configuration.Namespace(), val.Namespace) require.Equal(s.T(), username, val.Name) -<<<<<<< HEAD -======= - require.Equal(s.T(), username, val.Spec.IdentityClaims.PreferredUsername) - require.Equal(s.T(), "jane", val.Spec.GivenName) - require.Equal(s.T(), "doe", val.Spec.FamilyName) - require.Equal(s.T(), "red hat", val.Spec.Company) ->>>>>>> origin/master require.True(s.T(), states.VerificationRequired(&val)) require.Equal(s.T(), "a7b1b413c1cbddbcd19a51222ef8e20a", val.Labels[toolchainv1alpha1.UserSignupUserEmailHashLabelKey]) require.Empty(s.T(), val.Annotations[toolchainv1alpha1.SkipAutoCreateSpaceAnnotationKey]) // skip auto create space annotation is not set by default From 898abd61782dc3e76516ce20707bc532baf35026 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 4 Feb 2024 17:51:12 +1000 Subject: [PATCH 11/12] removed replaced dependencies --- go.mod | 4 ---- go.sum | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 8abac5c2..0761ba89 100644 --- a/go.mod +++ b/go.mod @@ -146,7 +146,3 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -replace github.com/codeready-toolchain/api => github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e - -replace github.com/codeready-toolchain/toolchain-common => github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 diff --git a/go.sum b/go.sum index b9e079f7..c0302a1c 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,10 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/codeready-toolchain/api v0.0.0-20240103194050-d5c7803671c1 h1:R+5BmQrz9hBfj6QFL+ojExD6CiZ5EuuVUbeb3pqxdds= +github.com/codeready-toolchain/api v0.0.0-20240103194050-d5c7803671c1/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240115235114-36095a5f2acc h1:tiRzD0Xasn/o2aBfZttt/O9Dw5S/13dY3dtqJ5wvu5I= +github.com/codeready-toolchain/toolchain-common v0.0.0-20240115235114-36095a5f2acc/go.mod h1:9YS35niqlaKOpGTKX9RoXhonHopTkwH9W4C9Bcg7ZjM= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -426,10 +430,6 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e h1:KFtfY3vwtRWyJYcpYUXieKtbFB7wepm/cOCpJneI2ew= -github.com/sbryzak/api v0.0.0-20240131054331-2fd5fe48d69e/go.mod h1:FO7kgXH1x1LqkF327D5a36u0WIrwjVCbeijPkzgwaZc= -github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0 h1:+M6r5HekZ3z5N/v1aZEjlkhwumlZAtvCBZEEEsnV3Tk= -github.com/sbryzak/toolchain-common v0.0.0-20240127001349-e2601d8aaca0/go.mod h1:vuxDx4HKxnb8xJV21OufzRhh/6qNP46stTkn2ni06UY= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= From db677101a86248b074ad0a252845c85db38b7641 Mon Sep 17 00:00:00 2001 From: Shane Bryzak Date: Sun, 4 Feb 2024 18:48:37 +1000 Subject: [PATCH 12/12] fixed test --- pkg/informers/service/informer_service_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/informers/service/informer_service_test.go b/pkg/informers/service/informer_service_test.go index faef2aaf..74da9237 100644 --- a/pkg/informers/service/informer_service_test.go +++ b/pkg/informers/service/informer_service_test.go @@ -42,7 +42,6 @@ func (s *TestInformerServiceSuite) TestInformerService() { Object: map[string]interface{}{ "spec": map[string]interface{}{ "tierName": "deactivate30", - "userID": "john-id", "propagatedClaims": map[string]interface{}{ "sub": "john-id", },