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

fix(invitedUsers): filter deleted users for invitedUsers endpoint #155

Conversation

Phil91
Copy link
Member

@Phil91 Phil91 commented Jul 20, 2023

Description

Remove the deleted users from the invitedUsers request

Why

Deleted users don't have an userEntityId, therefor the request will fail when keycloak is requested for the user informations

Issue

N/A - Jira Issue: CPLP-2986

Checklist

  • I have followed the contributing guidelines
  • I have performed a self-review of my own code
  • I have successfully tested my changes locally
  • I have added tests that prove my changes work
  • I have checked that new and existing tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

@Phil91 Phil91 marked this pull request as ready for review July 21, 2023 07:13
@Phil91 Phil91 requested a review from ntruchsess July 21, 2023 07:13
@Phil91 Phil91 deleted the branch eclipse-tractusx:release/v1.6.0-RC4 July 21, 2023 13:03
@Phil91 Phil91 closed this Jul 21, 2023
@Phil91 Phil91 reopened this Jul 21, 2023
@Phil91 Phil91 changed the base branch from release/v1.6.0-RC2 to release/v1.6.0-RC3 July 21, 2023 14:01
@Phil91 Phil91 force-pushed the bugfix/CPLP-2986-inviteduser branch from 44b78f8 to e0cca89 Compare July 25, 2023 06:57
@Phil91 Phil91 changed the base branch from release/v1.6.0-RC3 to release/v1.6.0-RC4 July 25, 2023 09:41
invitationStatus.Id,
companyuser.Email
))
_dbContext.Invitations
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest:

    public IAsyncEnumerable<InvitedUserDetail> GetInvitedUserDetailsUntrackedAsync(Guid applicationId) =>
        _dbContext.Invitations
            .AsNoTracking()
            .Where(invitation => invitation.CompanyApplicationId == applicationId && invitation.CompanyUser!.Identity!.UserStatusId != UserStatusId.DELETED)
            .Select(invitation => new InvitedUserDetail(
                invitation.CompanyUser!.Identity!.UserEntityId,
                invitation.InvitationStatusId,
                invitation.CompanyUser.Email))
            .AsAsyncEnumerable();

Copy link
Member Author

Choose a reason for hiding this comment

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

adjusted


var result = await sut.GetInvitedUserDetailsUntrackedAsync(_applicationId).ToListAsync().ConfigureAwait(false);

result.Should().NotBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest:

        result.Should().HaveCount(2)
            .And.Satisfy(
                x => x.EmailId == "[email protected]" && x.InvitationStatus == InvitationStatusId.CREATED,
                x => x.EmailId == "[email protected]" && x.InvitationStatus == InvitationStatusId.CREATED);

(there's no point in asserting 'NotBeNull()' if there are more asserts that implicitly fail if NotBeNull is not satisfied)

Copy link
Member Author

Choose a reason for hiding this comment

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

adjusted

@ntruchsess ntruchsess self-assigned this Jul 28, 2023
@Phil91 Phil91 requested a review from ntruchsess July 29, 2023 15:21
@sonarcloud
Copy link

sonarcloud bot commented Jul 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ntruchsess ntruchsess merged commit 60c9b3a into eclipse-tractusx:release/v1.6.0-RC4 Jul 31, 2023
5 checks passed
@ntruchsess ntruchsess deleted the bugfix/CPLP-2986-inviteduser branch July 31, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants