diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyServiceAccountData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyServiceAccountData.cs index b02924c9db..a12cb3cb9d 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyServiceAccountData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyServiceAccountData.cs @@ -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, diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ServiceAccountRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ServiceAccountRepository.cs index c4efb0c00a..9458d35cf4 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ServiceAccountRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ServiceAccountRepository.cs @@ -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, diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs index 2279da64dd..fe05bb7cc0 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs @@ -490,7 +490,17 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithExternalService public async Task GetOwnCompanyServiceAccountsDataAsync_GetsExpectedData(IEnumerable? userStatusIds, bool isUserInactive, IEnumerable expectedStatusIds) { // Arrange - var data = _fixture.CreateMany(15); + var count = 0; + var data = _fixture + .Build() + .With(x => x.CompanyServiceAccountKindId, (IFixture _) => + { + var kind = count % 2 == 0 ? CompanyServiceAccountKindId.INTERNAL + : CompanyServiceAccountKindId.EXTERNAL; + count++; + return kind; + }) + .CreateMany(15); A.CallTo(() => _serviceAccountRepository.GetOwnCompanyServiceAccountsUntracked(A._, A._, A._, A>._)) .Returns((int skip, int take) => Task.FromResult?>(new(data.Count(), data.Skip(skip).Take(take)))); @@ -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>.That.IsSameSequenceAs(expectedStatusIds))) .MustHaveHappenedOnceExactly(); }