-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor remaining service and test code to remove references to old identity properties #399
Merged
sbryzak
merged 17 commits into
codeready-toolchain:master
from
sbryzak:SANDBOX-504-intermediate
Feb 6, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3a4678e
updated api
sbryzak 67a0367
updated toolchain-common
sbryzak 8607e5f
Merge remote-tracking branch 'origin/master' into SANDBOX-504
sbryzak cb06df3
updated dependencies
sbryzak 0f3c145
Merge remote-tracking branch 'origin/master' into SANDBOX-504
sbryzak bd89ba1
fixed go.sum
sbryzak e2b5f42
fixed some tests
sbryzak ca453f0
fixed some more tests
sbryzak b6e5b12
fixed more tests
sbryzak c15dc91
fixed test
sbryzak b379441
Merge remote-tracking branch 'origin/master' into SANDBOX-504
sbryzak 583006a
minor
sbryzak 169d92e
Merge remote-tracking branch 'origin/master' into SANDBOX-504
sbryzak f44629d
fix merge
sbryzak 898abd6
removed replaced dependencies
sbryzak db67710
fixed test
sbryzak 5111800
Merge branch 'master' into SANDBOX-504-intermediate
mfrancisc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: "[email protected]", | ||
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: "[email protected]", | ||
}, | ||
}, | ||
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: "[email protected]", | ||
}, | ||
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: "[email protected]", | ||
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: "[email protected]", | ||
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,9 @@ func (s *TestInformerServiceSuite) TestInformerService() { | |
Object: map[string]interface{}{ | ||
"spec": map[string]interface{}{ | ||
"tierName": "deactivate30", | ||
"userID": "john-id", | ||
"propagatedClaims": map[string]interface{}{ | ||
"sub": "john-id", | ||
}, | ||
"userAccounts": []map[string]interface{}{ | ||
{ | ||
"targetCluster": "member1", | ||
|
@@ -55,7 +57,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", | ||
|
@@ -89,12 +93,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", | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -104,7 +110,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) | ||
}) | ||
}) | ||
|
||
|
@@ -164,7 +170,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) | ||
}) | ||
}) | ||
|
||
|
@@ -305,25 +311,29 @@ func (s *TestInformerServiceSuite) TestInformerService() { | |
Object: map[string]interface{}{ | ||
"spec": map[string]interface{}{ | ||
"targetCluster": "member2", | ||
"username": "[email protected]", | ||
"userid": "foo", | ||
"givenName": "Foo", | ||
"familyName": "Bar", | ||
"company": "Red Hat", | ||
"originalSub": "sub-key", | ||
"identityClaims": map[string]interface{}{ | ||
"sub": "foo", | ||
"originalSub": "sub-key", | ||
"preferredUsername": "[email protected]", | ||
"givenName": "Foo", | ||
"familyName": "Bar", | ||
"company": "Red Hat", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"noise": { | ||
Object: map[string]interface{}{ | ||
"spec": map[string]interface{}{ | ||
"targetCluster": "member1", | ||
"username": "[email protected]", | ||
"userid": "noise", | ||
"givenName": "Noise", | ||
"familyName": "Make", | ||
"company": "Noisy", | ||
"originalSub": "noise-key", | ||
"identityClaims": map[string]interface{}{ | ||
"sub": "noise", | ||
"originalSub": "noise-key", | ||
"preferredUsername": "[email protected]", | ||
"givenName": "Noise", | ||
"familyName": "Make", | ||
"company": "Noisy", | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -353,12 +363,16 @@ func (s *TestInformerServiceSuite) TestInformerService() { | |
expected := &toolchainv1alpha1.UserSignup{ | ||
Spec: toolchainv1alpha1.UserSignupSpec{ | ||
TargetCluster: "member2", | ||
Username: "[email protected]", | ||
Userid: "foo", | ||
GivenName: "Foo", | ||
FamilyName: "Bar", | ||
Company: "Red Hat", | ||
OriginalSub: "sub-key", | ||
IdentityClaims: toolchainv1alpha1.IdentityClaimsEmbedded{ | ||
PreferredUsername: "[email protected]", | ||
GivenName: "Foo", | ||
FamilyName: "Bar", | ||
Company: "Red Hat", | ||
PropagatedClaims: toolchainv1alpha1.PropagatedClaims{ | ||
Sub: "foo", | ||
OriginalSub: "sub-key", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -368,7 +382,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) | ||
}) | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the
userID
param to something likesub
in the function signature in the line 574, so it's bit less confusing.