Skip to content

Commit

Permalink
feat(technicaluser): add usertype to get service account data (eclips…
Browse files Browse the repository at this point in the history
…e-tractusx#1028)

Refs: eclipse-tractusx#976
Reviewed-by: Phil Schneider <info@philschneider.de>
Co-authored-by: Phil Schneider <info@philschneider.de>
  • Loading branch information
AnuragNagpure and Phil91 authored Sep 23, 2024
1 parent 32105bc commit a3bbcbb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public record CompanyServiceAccountData(
[property: JsonPropertyName("serviceAccountId")] Guid ServiceAccountId,
[property: JsonPropertyName("clientId")] string? ClientId,
[property: JsonPropertyName("name")] string Name,
[property: JsonPropertyName("userType")] CompanyServiceAccountKindId CompanyServiceAccountKindId,
[property: JsonPropertyName("serviceAccountType")] CompanyServiceAccountTypeId CompanyServiceAccountTypeId,
[property: JsonPropertyName("status")] UserStatusId UserStatusId,
[property: JsonPropertyName("isOwner")] bool IsOwner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void AttachAndModifyCompanyServiceAccount(
x.ServiceAccount.Id,
x.ServiceAccount.ClientClientId,
x.ServiceAccount.Name,
x.ServiceAccount.CompanyServiceAccountKindId,
x.ServiceAccount.CompanyServiceAccountTypeId,
x.ServiceAccount.Identity!.UserStatusId,
x.IsOwner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,17 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithExternalService
public async Task GetOwnCompanyServiceAccountsDataAsync_GetsExpectedData(IEnumerable<UserStatusId>? userStatusIds, bool isUserInactive, IEnumerable<UserStatusId> expectedStatusIds)
{
// Arrange
var data = _fixture.CreateMany<CompanyServiceAccountData>(15);
var count = 0;
var data = _fixture
.Build<CompanyServiceAccountData>()
.With(x => x.CompanyServiceAccountKindId, (IFixture _) =>
{
var kind = count % 2 == 0 ? CompanyServiceAccountKindId.INTERNAL
: CompanyServiceAccountKindId.EXTERNAL;
count++;
return kind;
})
.CreateMany(15);
A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountsUntracked(A<Guid>._, A<string?>._, A<bool?>._, A<IEnumerable<UserStatusId>>._))
.Returns((int skip, int take) => Task.FromResult<Pagination.Source<CompanyServiceAccountData>?>(new(data.Count(), data.Skip(skip).Take(take))));

Expand All @@ -503,6 +513,14 @@ public async Task GetOwnCompanyServiceAccountsDataAsync_GetsExpectedData(IEnumer
// Assert
result.Should().NotBeNull();
result.Content.Should().HaveCount(5);
result.Content
.Where(x => x.CompanyServiceAccountKindId == CompanyServiceAccountKindId.INTERNAL)
.Should()
.HaveCount(3);
result.Content
.Where(x => x.CompanyServiceAccountKindId == CompanyServiceAccountKindId.EXTERNAL)
.Should()
.HaveCount(2);
A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountsUntracked(ValidCompanyId, null, null, A<IEnumerable<UserStatusId>>.That.IsSameSequenceAs(expectedStatusIds)))
.MustHaveHappenedOnceExactly();
}
Expand Down

0 comments on commit a3bbcbb

Please sign in to comment.