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

SSO login bug fix #2492

Merged
merged 8 commits into from
Jun 26, 2024
Merged

SSO login bug fix #2492

merged 8 commits into from
Jun 26, 2024

Conversation

muralibasani
Copy link
Contributor

Linked issue

Resolves: #2484

What kind of change does this PR introduce?

  • When a user request is declined, record is deleted from staging table, so user can register again with similar data

  • A bug fix when an email is sent out, decode was applied on plain text.

  • An if condition is fixed to allow staging and pending requests

  • Bug fix

  • New feature

  • Refactor

  • Docs update

  • CI update

What is the current behavior?

Describe the state of the application before this PR. Illustrations appreciated (videos, gifs, screenshots).

What is the new behavior?

Describe the state of the application after this PR. Illustrations appreciated (videos, gifs, screenshots).

Other information

Additional changes, explanations of the approach taken, unresolved issues, necessary follow ups, etc.

Requirements (all must be checked before review)

  • The pull request title follows our guidelines
  • Tests for the changes have been added (if relevant)
  • The latest changes from the main branch have been pulled
  • pnpm lint has been run successfully

return "Failure. Registration already exists";
Optional<RegisterUserInfo> optionalUserRegistration =
registerInfoRepo.findByUsername(userInfo.getUsername());
if (optionalUserRegistration.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the User Registration is not present should we return "Failure. Registration doesn't exist"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should create a new one if not present which is done at line 401.

status = NewUserStatus.DECLINED.value;
// In case if user registration is declined, delete the record from db, so user can try to
// register again with any new data.
registerInfoRepo.deleteById("" + registerUser.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: a stylistic choice but could we use String.valueOf(registerUser.getId())

@@ -633,7 +636,7 @@ public void showUserList() throws Exception {
.getContentAsString();
List<UserInfoModelResponse> userInfoModelList =
new ObjectMapper().readValue(response, new TypeReference<>() {});
assertThat(userInfoModelList).hasSizeBetween(3, 6); // superadmin, kwuserb, kwuserc
assertThat(userInfoModelList).hasSizeBetween(3, 9); // superadmin, kwuserb, kwuserc
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a bit more precise, I am assuming it should equal the same amount every time, or use assertThat(userInfoModelList).containsAll(a,b,c,d) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We added this as this test might run before or after other integration tests, and we are not cleaning up users after the integration test.
So there are about 9 users created totally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I think we can maybe improve this later, it doesn't need to hold up this PR

String jsonReq = OBJECT_MAPPER.writer().writeValueAsString(userInfoModel);

String registerUserResponse =
mvc.perform(
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably extract these three performs into a method each and re-use them.
It would reduce code duplication

@@ -195,8 +195,7 @@ private static Stream<Arguments> insertIntoRegisterUsers() {
Arguments.of(
"[email protected]", "[email protected]", ApiResultStatus.SUCCESS.value),
Arguments.of("Octopus2", "[email protected]", "Failure. User already exists"),
Arguments.of(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this test it covers a test case we still have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently have only userid field as primary key, however an emailid can be mentioned as userid. But this testcase assumes emailid column as primary key, hence removed.

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

A few Nits but change looks good.

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

LGTM

@muralibasani muralibasani merged commit d073e3e into main Jun 26, 2024
30 checks passed
@muralibasani muralibasani deleted the sso-login-fix branch June 26, 2024 12:54
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.

NullPointerException when trying to login with Keycloak SSO
2 participants