Skip to content
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

Update common libraries to use PropagatedClaims #345

Merged
merged 12 commits into from
Dec 13, 2023

Conversation

sbryzak
Copy link
Contributor

@sbryzak sbryzak commented Nov 30, 2023

This is a companion PR to codeready-toolchain/host-operator#943 which refactors the MasterUserRecordController to only use the user's SSO claim values from PropagatedClaims and nowhere else.

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Merging #345 (8b31f7c) into master (aee8d2b) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #345   +/-   ##
=======================================
  Coverage   76.41%   76.41%           
=======================================
  Files          43       43           
  Lines        1997     1997           
=======================================
  Hits         1526     1526           
  Misses        424      424           
  Partials       47       47           

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the description still contains "WIP" so not sure if it's already ready for review or not.

Anyway, I got a bit lost in the changes you have made and you are planning to do. I'm also not sure when you want to drop the fields from the CRDs.

Apart from that, you missed a few cases:

Comment on lines 89 to 92
func UserID(userID string) MurModifier {
return func(mur *toolchainv1alpha1.MasterUserRecord) error {
mur.Spec.UserID = userID
mur.Spec.PropagatedClaims.UserID = userID
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please create corresponding PRs for this PR in:

  • host-operator
  • member-operator
  • registration-service

because for example this function should be used in different cases. IIRC, the original mur.Spec.UserID is now stored as mur.Spec.PropagatedClaims.Sub, so it would be good to see the corresponding changes in the tests.

Also, shouldn't you:

  • either create a new function for setting the Sub
  • or rename this one including the var names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host operator PR is already here: codeready-toolchain/host-operator#943

I've created two new PRs as requested, I'm not sure what value these have though:

Registration service: codeready-toolchain/registration-service#380
Member operator: codeready-toolchain/member-operator#512

I've also added a new function for setting the Sub

Copy link
Contributor

@MatousJobanek MatousJobanek Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created two new PRs as requested, I'm not sure what value these have though:

well the reason is that you are changing logic of functions that are used in these repositories, so it's good to make sure that the repos are compatible with the changes.

I've also added a new function for setting the Sub

I don't see anything like that in the PR, but still, do you want to keep the changes of the UserID function? See my comment in the host-operator PR - does it make sense to have the function there when changing it's logic doesn't have any impact on the tests. Or I'm maybe just missing some small detail.

Comment on lines -205 to -211
func (a *MasterUserRecordAssertion) HasOriginalSub(sub string) *MasterUserRecordAssertion {
err := a.loadMasterUserRecord()
require.NoError(a.t, err)
assert.Equal(a.t, sub, a.mur.Spec.OriginalSub)
return a
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, why did you drop this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatousJobanek

the description still contains "WIP" so not sure if it's already ready for review or not.

Anyway, I got a bit lost in the changes you have made and you are planning to do. I'm also not sure when you want to drop the fields from the CRDs.

Apart from that, you missed a few cases:

the usersignup.go file still uses the UserSignupUserEmailAnnotationKey
the same for notification_builder.go
plus there is also one in the useraccount_test.go 

The PR is indeed ready for review. Fields won't be dropped from the CRDs until everything has been refactored to only use the PropagatedClaims.

The cases mentioned in usersignup.go and notification_builder.go are not missed, they are not within the scope of this PR and will be updated when the UserSignupController is refactored (these changes are limited to only the MasterUserRecordController).

I've updated useraccount_test.go to perform an equality check of the entire PropagatedClaims instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, thanks for the explanation 👍 I was missing the description in the PR - what the PR is changing and what are the next steps.

I've updated useraccount_test.go to perform an equality check of the entire PropagatedClaims instead.

I don't see any changes in the file. Apart from that, it's still using the UserId from spec

assert.Equal(t, mur.Spec.UserID, userAcc.Spec.UserID)

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comments 👍

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
5.0% Duplication on New Code

See analysis details on SonarCloud

@sbryzak sbryzak merged commit 5c6d88f into codeready-toolchain:master Dec 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants