Skip to content

Commit

Permalink
feat: enhanced the owned-credentials endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
leandro-cavalcante committed Aug 21, 2024
1 parent 7232f27 commit ae483b0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public record OwnedVerifiedCredentialData(
VerifiedCredentialTypeId CredentialType,
CompanySsiDetailStatusId Status,
DateTimeOffset? ExpiryDate,
string Authority
string Authority,
string? Version
);
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public IAsyncEnumerable<OwnedVerifiedCredentialData> GetOwnCredentialDetails(str
c.VerifiedCredentialTypeId,
c.CompanySsiDetailStatusId,
c.ExpiryDate,
c.IssuerBpn))
c.IssuerBpn,
c.VerifiedCredentialExternalTypeDetailVersion!.Version))
.ToAsyncEnumerable();

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,4 +989,50 @@ private void ConfigureHttpClientFactoryFixture(HttpResponseMessage httpResponseM
}

#endregion

#region GetCredentialsForBpn

[Fact]
public async void GetCredentialsForBpn_WithVersion_ReturnExpected()
{
OwnedVerifiedCredentialData[] ownedVerifiedCredentialData = [new OwnedVerifiedCredentialData(
Guid.NewGuid(),
VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK,
CompanySsiDetailStatusId.ACTIVE,
DateTimeOffset.Now,
"Test Authority",
"3.0")];

A.CallTo(() => _companySsiDetailsRepository.GetOwnCredentialDetails(_identity.Bpnl)).Returns(ownedVerifiedCredentialData.ToAsyncEnumerable());

var ownedCredentials = _sut.GetCredentialsForBpn();

await foreach (var credentialData in ownedCredentials)
{
credentialData.Version.Should().Be(ownedVerifiedCredentialData[0].Version);
}
}

[Fact]
public async void GetCredentialsForBpn_WithoutVersion_ReturnExpected()
{
OwnedVerifiedCredentialData[] ownedVerifiedCredentialData = [new OwnedVerifiedCredentialData(
Guid.NewGuid(),
VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK,
CompanySsiDetailStatusId.ACTIVE,
DateTimeOffset.Now,
"Test Authority",
null)];

A.CallTo(() => _companySsiDetailsRepository.GetOwnCredentialDetails(_identity.Bpnl)).Returns(ownedVerifiedCredentialData.ToAsyncEnumerable());

var ownedCredentials = _sut.GetCredentialsForBpn();

await foreach (var credentialData in ownedCredentials)
{
credentialData.Version.Should().BeNull();
}
}

#endregion
}

0 comments on commit ae483b0

Please sign in to comment.