From bd1a6c5b943259ff55e34a83e46b3734f7182cd4 Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Wed, 18 Dec 2024 13:48:08 +0100 Subject: [PATCH] feat(issuer): add process and process step status to GET: /api/issuer Refs: #300 --- docs/api/issuer-service.yaml | 83 ++++++++++++++----- .../Models/CredentialDetailData.cs | 9 +- .../CompanySsiDetailsRepository.cs | 47 +++++++++-- .../ICompanySsiDetailsRepository.cs | 4 +- .../SsiCredentialIssuer.DbAccess.csproj | 1 + .../BusinessLogic/IssuerBusinessLogic.cs | 66 ++++----------- .../CompanySsiDetailsRepositoryTests.cs | 49 +++++------ .../BusinessLogic/IssuerBusinessLogicTests.cs | 8 +- 8 files changed, 163 insertions(+), 104 deletions(-) diff --git a/docs/api/issuer-service.yaml b/docs/api/issuer-service.yaml index a3bc8b3f..c3a464d2 100644 --- a/docs/api/issuer-service.yaml +++ b/docs/api/issuer-service.yaml @@ -288,6 +288,10 @@ paths: type: string format: uuid responses: + '200': + description: OK + content: + application/json: { } '401': description: Unauthorized content: @@ -333,6 +337,10 @@ paths: type: string format: uuid responses: + '200': + description: OK + content: + application/json: { } '401': description: Unauthorized content: @@ -384,6 +392,10 @@ paths: schema: $ref: '#/components/schemas/ProcessStepTypeId' responses: + '200': + description: OK + content: + application/json: { } '401': description: Unauthorized content: @@ -429,6 +441,13 @@ paths: type: string format: uuid responses: + '200': + description: OK + content: + application/json: + schema: + type: string + format: uuid '401': description: Unauthorized content: @@ -441,13 +460,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '200': - description: OK - content: - application/json: - schema: - type: string - format: uuid '/api/revocation/credentials/{credentialId}': post: tags: @@ -463,6 +475,13 @@ paths: type: string format: uuid responses: + '200': + description: OK + content: + application/json: + schema: + type: string + format: uuid '401': description: Unauthorized content: @@ -475,13 +494,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '200': - description: OK - content: - application/json: - schema: - type: string - format: uuid '/api/revocation/{processId}/retrigger-step/{processStepTypeId}': post: tags: @@ -503,6 +515,10 @@ paths: schema: $ref: '#/components/schemas/ProcessStepTypeId' responses: + '200': + description: OK + content: + application/json: { } '401': description: Unauthorized content: @@ -584,6 +600,13 @@ paths: type: string format: uuid responses: + '200': + description: OK + content: + application/json: + schema: + type: string + format: binary '401': description: Unauthorized content: @@ -596,13 +619,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' - '200': - description: OK - content: - application/json: - schema: - type: string - format: binary '409': description: Conflict content: @@ -736,6 +752,15 @@ components: $ref: '#/components/schemas/DocumentData' externalTypeDetail: $ref: '#/components/schemas/ExternalTypeDetailData' + processId: + type: string + format: uuid + nullable: true + processSteps: + type: array + items: + $ref: '#/components/schemas/ProcessStepDetailData' + nullable: true additionalProperties: false DocumentData: type: object @@ -843,6 +868,22 @@ components: type: string nullable: true additionalProperties: false + ProcessStepDetailData: + type: object + properties: + processStepStatusId: + $ref: '#/components/schemas/ProcessStepStatusId' + processStepTypeId: + $ref: '#/components/schemas/ProcessStepTypeId' + additionalProperties: false + ProcessStepStatusId: + enum: + - TODO + - DONE + - SKIPPED + - FAILED + - DUPLICATE + type: string ProcessStepTypeId: enum: - CREATE_SIGNED_CREDENTIAL diff --git a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs index f6333934..5fa741a5 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Models/CredentialDetailData.cs @@ -29,5 +29,12 @@ public record CredentialDetailData( CompanySsiDetailStatusId ParticipantStatus, DateTimeOffset? ExpiryDate, IEnumerable Documents, - ExternalTypeDetailData? ExternalTypeDetail + ExternalTypeDetailData? ExternalTypeDetail, + Guid? ProcessId, + IEnumerable? ProcessSteps +); + +public record ProcessStepDetailData( + ProcessStepStatusId ProcessStepStatusId, + ProcessStepTypeId ProcessStepTypeId ); diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs index 220585f8..9dec14db 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/CompanySsiDetailsRepository.cs @@ -18,6 +18,7 @@ ********************************************************************************/ using Microsoft.EntityFrameworkCore; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; @@ -159,12 +160,46 @@ public Task CheckSsiDetailsExistsForCompany(string bpnl, VerifiedCredentia .SingleOrDefaultAsync(); /// - public IQueryable GetAllCredentialDetails(CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType) => - context.CompanySsiDetails.AsNoTracking() - .Where(c => - (!companySsiDetailStatusId.HasValue || c.CompanySsiDetailStatusId == companySsiDetailStatusId.Value) && - (!credentialTypeId.HasValue || c.VerifiedCredentialTypeId == credentialTypeId) && - (!approvalType.HasValue || (approvalType.Value == CompanySsiDetailApprovalType.Automatic && c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == VerifiedCredentialTypeKindId.FRAMEWORK) || (approvalType.Value == CompanySsiDetailApprovalType.Manual && c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId != VerifiedCredentialTypeKindId.FRAMEWORK))); + public Func?>> GetAllCredentialDetails(CompanySsiDetailSorting? sorting, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType) => + (skip, take) => Pagination.CreateSourceQueryAsync( + skip, + take, + context.CompanySsiDetails.AsNoTracking() + .Where(c => + (!companySsiDetailStatusId.HasValue || c.CompanySsiDetailStatusId == companySsiDetailStatusId.Value) && + (!credentialTypeId.HasValue || c.VerifiedCredentialTypeId == credentialTypeId) && + (!approvalType.HasValue || + (approvalType.Value == CompanySsiDetailApprovalType.Automatic && c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == VerifiedCredentialTypeKindId.FRAMEWORK) || + (approvalType.Value == CompanySsiDetailApprovalType.Manual && c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId != VerifiedCredentialTypeKindId.FRAMEWORK))) + .GroupBy(x => x.IssuerBpn), + credentials => sorting == null || sorting == CompanySsiDetailSorting.BpnlAsc ? + credentials.OrderBy(c => c.Bpnl) : + credentials.OrderByDescending(c => c.Bpnl), + credential => new CredentialDetailData( + credential.Id, + credential.Bpnl, + credential.VerifiedCredentialTypeId, + credential.VerifiedCredentialType!.VerifiedCredentialTypeAssignedUseCase!.UseCase!.Name, + credential.CompanySsiDetailStatusId, + credential.ExpiryDate, + credential.Documents.Select(d => new DocumentData(d.Id, d.DocumentName, d.DocumentTypeId)), + credential.VerifiedCredentialExternalTypeDetailVersion == null + ? null + : new ExternalTypeDetailData( + credential.VerifiedCredentialExternalTypeDetailVersion.Id, + credential.VerifiedCredentialExternalTypeDetailVersion.VerifiedCredentialExternalTypeId, + credential.VerifiedCredentialExternalTypeDetailVersion.Version, + credential.VerifiedCredentialExternalTypeDetailVersion.Template, + credential.VerifiedCredentialExternalTypeDetailVersion.ValidFrom, + credential.VerifiedCredentialExternalTypeDetailVersion.Expiry), + credential.ProcessId, + credential.ProcessId == null ? + null : + credential.Process!.ProcessSteps.Select(ps => + new ProcessStepDetailData( + ps.ProcessStepStatusId, + ps.ProcessStepTypeId))) + ).SingleOrDefaultAsync(); /// public IAsyncEnumerable GetOwnCredentialDetails(string bpnl) => diff --git a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs index 6291c544..9f7d3fd3 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs +++ b/src/database/SsiCredentialIssuer.DbAccess/Repositories/ICompanySsiDetailsRepository.cs @@ -17,6 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ +using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums; @@ -83,11 +84,12 @@ public interface ICompanySsiDetailsRepository /// /// Gets all credential details /// + /// The sorting of the result /// The status of the details /// OPTIONAL: The type of the credential that should be returned /// OPTIONAL: The approval type of the credential /// Returns data to create the pagination - IQueryable GetAllCredentialDetails(CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType); + Func?>> GetAllCredentialDetails(CompanySsiDetailSorting? sorting, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType); /// /// Gets all credentials for a specific bpn diff --git a/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj b/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj index f43b7667..bd697566 100644 --- a/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj +++ b/src/database/SsiCredentialIssuer.DbAccess/SsiCredentialIssuer.DbAccess.csproj @@ -31,6 +31,7 @@ + diff --git a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs index d9a03a3a..4124f9ca 100644 --- a/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs +++ b/src/issuer/SsiCredentialIssuer.Service/BusinessLogic/IssuerBusinessLogic.cs @@ -17,7 +17,6 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; @@ -29,7 +28,6 @@ using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Enums; -using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Extensions; using Org.Eclipse.TractusX.SsiCredentialIssuer.Portal.Service.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.Portal.Service.Services; using Org.Eclipse.TractusX.SsiCredentialIssuer.Processes.Library; @@ -97,45 +95,16 @@ public IAsyncEnumerable GetSsiCertificatesAsync() .GetSsiCertificates(_identity.Bpnl, _dateTimeProvider.OffsetNow); /// - public Task> GetCredentials(int page, int size, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType, CompanySsiDetailSorting? sorting) - { - var query = _repositories - .GetInstance() - .GetAllCredentialDetails(companySsiDetailStatusId, credentialTypeId, approvalType); - var sortedQuery = sorting switch - { - CompanySsiDetailSorting.BpnlAsc or null => query.OrderBy(c => c.Bpnl), - CompanySsiDetailSorting.BpnlDesc => query.OrderByDescending(c => c.Bpnl), - _ => query - }; - - return Pagination.CreateResponseAsync(page, size, _settings.MaxPageSize, (skip, take) => - new Pagination.AsyncSource - ( - query.CountAsync(), - sortedQuery - .Skip(skip) - .Take(take) - .Select(c => new CredentialDetailData( - c.Id, - c.Bpnl, - c.VerifiedCredentialTypeId, - c.VerifiedCredentialType!.VerifiedCredentialTypeAssignedUseCase!.UseCase!.Name, - c.CompanySsiDetailStatusId, - c.ExpiryDate, - c.Documents.Select(d => new DocumentData(d.Id, d.DocumentName, d.DocumentTypeId)), - c.VerifiedCredentialExternalTypeDetailVersion == null - ? null - : new ExternalTypeDetailData( - c.VerifiedCredentialExternalTypeDetailVersion.Id, - c.VerifiedCredentialExternalTypeDetailVersion.VerifiedCredentialExternalTypeId, - c.VerifiedCredentialExternalTypeDetailVersion.Version, - c.VerifiedCredentialExternalTypeDetailVersion.Template, - c.VerifiedCredentialExternalTypeDetailVersion.ValidFrom, - c.VerifiedCredentialExternalTypeDetailVersion.Expiry)) - ).AsAsyncEnumerable() - )); - } + public Task> GetCredentials(int page, int size, CompanySsiDetailStatusId? companySsiDetailStatusId, VerifiedCredentialTypeId? credentialTypeId, CompanySsiDetailApprovalType? approvalType, CompanySsiDetailSorting? sorting) => + Pagination.CreateResponseAsync( + page, + size, + _settings.MaxPageSize, + _repositories.GetInstance().GetAllCredentialDetails( + sorting, + companySsiDetailStatusId, + credentialTypeId, + approvalType)); public IAsyncEnumerable GetCredentialsForBpn() => _repositories @@ -152,7 +121,13 @@ public async Task ApproveCredential(Guid credentialId, CancellationToken cancell var companySsiRepository = _repositories.GetInstance(); var (exists, data) = await companySsiRepository.GetSsiApprovalData(credentialId).ConfigureAwait(ConfigureAwaitOptions.None); - ValidateApprovalData(credentialId, exists, data); + + if (!exists) + { + throw NotFoundException.Create(IssuerErrors.SSI_DETAILS_NOT_FOUND, new ErrorParameter[] { new("credentialId", credentialId.ToString()) }); + } + + ValidateApprovalData(credentialId, data); var processId = CreateProcess(); @@ -212,13 +187,8 @@ private Guid CreateProcess() return processId; } - private static void ValidateApprovalData(Guid credentialId, bool exists, SsiApprovalData data) + private static void ValidateApprovalData(Guid credentialId, SsiApprovalData data) { - if (!exists) - { - throw NotFoundException.Create(IssuerErrors.SSI_DETAILS_NOT_FOUND, new ErrorParameter[] { new("credentialId", credentialId.ToString()) }); - } - if (data.Status != CompanySsiDetailStatusId.PENDING) { throw ConflictException.Create(IssuerErrors.CREDENTIAL_NOT_PENDING, new ErrorParameter[] { new("credentialId", credentialId.ToString()), new("status", CompanySsiDetailStatusId.PENDING.ToString()) }); diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs b/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs index c9ed176a..811072e6 100644 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs +++ b/tests/database/SsiCredentialIssuer.DbAccess.Tests/CompanySsiDetailsRepositoryTests.cs @@ -22,6 +22,7 @@ using FluentAssertions; using Microsoft.EntityFrameworkCore; using Org.Eclipse.TractusX.SsiCredentialIssuer.DbAccess.Tests.Setup; +using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Models; using Org.Eclipse.TractusX.SsiCredentialIssuer.DBAccess.Repositories; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities; using Org.Eclipse.TractusX.SsiCredentialIssuer.Entities.Entities; @@ -115,22 +116,21 @@ public async Task GetAllCredentialDetails_WithValidData_ReturnsExpected() var sut = await CreateSut(); // Act - var result = await sut.GetAllCredentialDetails(null, null, null).ToListAsync(); + var result = await sut.GetAllCredentialDetails(null, null, null, null)(0, 15); // Assert result.Should().NotBeNull(); - result.Count.Should().Be(7); - result.Should().HaveCount(7); - result.Where(x => x.Bpnl == ValidBpnl).Should().HaveCount(6) + result!.Count.Should().Be(7); + result.Data.Where(x => x.Bpnl == ValidBpnl).Should().HaveCount(6) .And.Satisfy( - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.PCF_FRAMEWORK && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.MEMBERSHIP && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.MEMBERSHIP && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.INACTIVE, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.MEMBERSHIP && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.INACTIVE, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.BEHAVIOR_TWIN_FRAMEWORK && x.CompanySsiDetailStatusId == CompanySsiDetailStatusId.INACTIVE); - result.Where(x => x.Bpnl == "BPNL00000001LLHA").Should().ContainSingle() - .And.Satisfy(x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK); + x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK && x.ParticipantStatus == CompanySsiDetailStatusId.PENDING, + x => x.CredentialType == VerifiedCredentialTypeId.PCF_FRAMEWORK && x.ParticipantStatus == CompanySsiDetailStatusId.PENDING, + x => x.CredentialType == VerifiedCredentialTypeId.MEMBERSHIP && x.ParticipantStatus == CompanySsiDetailStatusId.PENDING, + x => x.CredentialType == VerifiedCredentialTypeId.MEMBERSHIP && x.ParticipantStatus == CompanySsiDetailStatusId.INACTIVE, + x => x.CredentialType == VerifiedCredentialTypeId.MEMBERSHIP && x.ParticipantStatus == CompanySsiDetailStatusId.INACTIVE, + x => x.CredentialType == VerifiedCredentialTypeId.BEHAVIOR_TWIN_FRAMEWORK && x.ParticipantStatus == CompanySsiDetailStatusId.INACTIVE); + result.Data.Where(x => x.Bpnl == "BPNL00000001LLHA").Should().ContainSingle() + .And.Satisfy(x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK); } [Fact] @@ -140,18 +140,18 @@ public async Task GetAllCredentialDetails_WithWithStatusId_ReturnsExpected() var sut = await CreateSut(); // Act - var result = await sut.GetAllCredentialDetails(CompanySsiDetailStatusId.PENDING, null, null).ToListAsync(); + var result = await sut.GetAllCredentialDetails(null, CompanySsiDetailStatusId.PENDING, null, null)(0, 15); // Assert - result.Should().NotBeNull().And.HaveCount(4); - result.Count.Should().Be(4); - result.Where(x => x.Bpnl == ValidBpnl).Should().HaveCount(3) + result.Should().NotBeNull(); + result!.Count.Should().Be(4); + result.Data.Where(x => x.Bpnl == ValidBpnl).Should().HaveCount(3) .And.Satisfy( - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.PCF_FRAMEWORK, - x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.MEMBERSHIP); - result.Should().ContainSingle(x => x.Bpnl == "BPNL00000001LLHA") - .Which.Should().Match(x => x.VerifiedCredentialTypeId == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK); + x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, + x => x.CredentialType == VerifiedCredentialTypeId.PCF_FRAMEWORK, + x => x.CredentialType == VerifiedCredentialTypeId.MEMBERSHIP); + result.Data.Should().ContainSingle(x => x.Bpnl == "BPNL00000001LLHA") + .Which.Should().Match(x => x.CredentialType == VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK); } [Fact] @@ -161,11 +161,12 @@ public async Task GetAllCredentialDetails_WithWithCredentialType_ReturnsExpected var sut = await CreateSut(); // Act - var result = await sut.GetAllCredentialDetails(null, VerifiedCredentialTypeId.PCF_FRAMEWORK, null).ToListAsync(); + var result = await sut.GetAllCredentialDetails(null, null, VerifiedCredentialTypeId.PCF_FRAMEWORK, null)(0, 15); // Assert - result.Should().NotBeNull().And.ContainSingle().Which.Bpnl.Should().Be(ValidBpnl); - result.Count.Should().Be(1); + result.Should().NotBeNull(); + result!.Count.Should().Be(1); + result.Data.Should().ContainSingle().Which.Bpnl.Should().Be(ValidBpnl); } #endregion diff --git a/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs b/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs index f159cc07..3c403fd1 100644 --- a/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs +++ b/tests/issuer/SsiCredentialIssuer.Service.Tests/BusinessLogic/IssuerBusinessLogicTests.cs @@ -1056,9 +1056,11 @@ public async Task RetriggerProcessStep_ReturnsExpected(ProcessTypeId processType [InlineData(1, 15, 20, 2, 1, 5)] public async Task GetCredentials_ReturnsExpected(int page, int size, int numberOfElements, int numberOfPages, int resultPage, int resultPageSize) { - var data = new AsyncEnumerableStub(_fixture.CreateMany(numberOfElements)); - A.CallTo(() => _companySsiDetailsRepository.GetAllCredentialDetails(A._, A._, A._)) - .Returns(data.AsQueryable()); + var data = _fixture.CreateMany(numberOfElements); + Task?> PaginationResult(int skip, int take) => Task.FromResult(new Pagination.Source(data.Count(), data.Skip(skip).Take(take))); + + A.CallTo(() => _companySsiDetailsRepository.GetAllCredentialDetails(A._, A._, A._, A._)) + .Returns(PaginationResult); // Act var result = await _sut.GetCredentials(page, size, null, null, null, null);