Skip to content

Commit a1dd326

Browse files
authored
fix(document): adjust validation to allow the issuer to display documents of credentials (#229)
Refs: #225 Reviewed-By: Evelyn Gurschler <[email protected]>
1 parent 9ae194e commit a1dd326

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/database/SsiCredentialIssuer.DbAccess/Repositories/CredentialRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void AttachAndModifyCredential(Guid credentialId, Action<CompanySsiDetail
111111
.Where(x => x.Id == documentId)
112112
.Select(x => new ValueTuple<bool, bool, string, DocumentStatusId, byte[], MediaTypeId>(
113113
true,
114-
x.CompanySsiDetails.Any(c => c.Bpnl == bpnl),
114+
x.CompanySsiDetails.Any(c => c.Bpnl == bpnl || c.IssuerBpn == bpnl),
115115
x.DocumentName,
116116
x.DocumentStatusId,
117117
x.DocumentContent,

tests/database/SsiCredentialIssuer.DbAccess.Tests/CredentialRepositoryTests.cs

+15
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@ public async Task GetDocumentById_ReturnsExpectedDocument()
243243
result.MediaTypeId.Should().Be(MediaTypeId.PNG);
244244
}
245245

246+
[Fact]
247+
public async Task GetDocumentById_WithIssuerBpn_ReturnsExpected()
248+
{
249+
// Arrange
250+
var sut = await CreateSut();
251+
252+
// Act
253+
var result = await sut.GetDocumentById(new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1"), "BPNL000003ISSUER");
254+
255+
// Assert
256+
result.Exists.Should().BeTrue();
257+
result.IsSameCompany.Should().BeTrue();
258+
result.MediaTypeId.Should().Be(MediaTypeId.PNG);
259+
}
260+
246261
[Fact]
247262
public async Task GetDocumentById_WithWrongBpn_ReturnsExpected()
248263
{

0 commit comments

Comments
 (0)