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

feat(ssi): adjust certificateTypes endpoint #171

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,6 @@ public async Task RejectCredential(Guid userId, Guid credentialId)
}

/// <inheritdoc />
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
_portalRepositories.GetInstance<ICompanySsiDetailsRepository>().GetCertificateTypes();
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes(Guid companyId) =>
_portalRepositories.GetInstance<ICompanySsiDetailsRepository>().GetCertificateTypes(companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ public interface ICompanyDataBusinessLogic
Task ApproveCredential(Guid userId, Guid credentialId, CancellationToken cancellationToken);

Task RejectCredential(Guid userId, Guid credentialId);
IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes();
IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes(Guid companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public Task<IEnumerable<SsiCertificateData>> GetSsiCertificationData() =>
[Route("certificateTypes")]
[ProducesResponseType(typeof(IEnumerable<SsiCertificateTransferData>), StatusCodes.Status200OK)]
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
_logic.GetCertificateTypes();
this.WithCompanyId(companyId => _logic.GetCertificateTypes(companyId));

/// <summary>
/// Creates the useCaseParticipation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,13 @@ public void AttachAndModifyCompanySsiDetails(Guid id, Action<CompanySsiDetail>?
}

/// <inheritdoc />
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes() =>
public IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes(Guid companyId) =>
_context.VerifiedCredentialTypes
.Where(x => x.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == VerifiedCredentialTypeKindId.CERTIFICATE)
.Where(x =>
x.VerifiedCredentialTypeAssignedKind!.VerifiedCredentialTypeKindId == VerifiedCredentialTypeKindId.CERTIFICATE &&
!x.CompanySsiDetails.Any(ssi =>
ssi.CompanyId == companyId &&
(ssi.CompanySsiDetailStatusId == CompanySsiDetailStatusId.PENDING || ssi.CompanySsiDetailStatusId == CompanySsiDetailStatusId.ACTIVE)))
.Select(x => x.Id)
.ToAsyncEnumerable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ public interface ICompanySsiDetailsRepository
Task<(bool exists, SsiApprovalData data)> GetSsiApprovalData(Guid credentialId);
Task<(bool Exists, CompanySsiDetailStatusId Status, VerifiedCredentialTypeId Type, Guid RequesterId, string? RequesterEmail, string? Firstname, string? Lastname)> GetSsiRejectionData(Guid credentialId);
void AttachAndModifyCompanySsiDetails(Guid id, Action<CompanySsiDetail>? initialize, Action<CompanySsiDetail> updateFields);
IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes();
IAsyncEnumerable<VerifiedCredentialTypeId> GetCertificateTypes(Guid companyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1461,11 +1461,11 @@ public async Task RejectCredential_WithoutUserMail_ReturnsExpected()
public async Task GetCertificateTypes_WithFilter_ReturnsList()
{
// Arrange
A.CallTo(() => _companySsiDetailsRepository.GetCertificateTypes())
A.CallTo(() => _companySsiDetailsRepository.GetCertificateTypes(_identity.CompanyId))
.Returns(new[] { VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE }.ToAsyncEnumerable());

// Act
var result = await _sut.GetCertificateTypes().ToListAsync().ConfigureAwait(false);
var result = await _sut.GetCertificateTypes(_identity.CompanyId).ToListAsync().ConfigureAwait(false);

// Assert
result.Should().HaveCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public async Task GetCredentials_CallsExpected()
public async Task GetCredentialTypes()
{
// Arrange
A.CallTo(() => _logic.GetCertificateTypes())
A.CallTo(() => _logic.GetCertificateTypes(_identity.CompanyId))
.Returns(new[] { VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE }.ToAsyncEnumerable());

//Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,20 @@ public async Task GetCertificateTypes_ReturnsExpected()
var sut = await CreateSut();

// Act
var result = await sut.GetCertificateTypes().ToListAsync().ConfigureAwait(false);
var result = await sut.GetCertificateTypes(_validCompanyId).ToListAsync().ConfigureAwait(false);

// Assert
result.Should().BeEmpty();
}

[Fact]
public async Task GetCertificateTypes_WithoutCertificate_ReturnsExpected()
{
// Arrange
var sut = await CreateSut();

// Act
var result = await sut.GetCertificateTypes(Guid.NewGuid()).ToListAsync().ConfigureAwait(false);

// Assert
result.Should().ContainSingle().Which.Should().Be(VerifiedCredentialTypeId.DISMANTLER_CERTIFICATE);
Expand Down
Loading