Skip to content

Commit

Permalink
feat: make statuslist type configureable
Browse files Browse the repository at this point in the history
Refs: #299
  • Loading branch information
Phil91 committed Nov 13, 2024
1 parent 8ce67a1 commit 8bdf822
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ spec:
value: "{{ .Values.service.credential.issuerBpn }}"
- name: "CREDENTIAL__STATUSLISTURL"
value: "{{ .Values.service.credential.statusListUrl }}"
- name: "CREDENTIAL__STATUSLISTTYPE"
value: "{{ .Values.service.credential.statusListType }}"
- name: "CREDENTIAL__ENCRYPTIONCONFIG__ENCRYPTIONCONFIGINDEX"
value: "{{ .Values.service.credential.encryptionConfigIndex }}"
- name: "CREDENTIAL__ENCRYPTIONCONFIGS__0__INDEX"
Expand Down
3 changes: 3 additions & 0 deletions charts/ssi-credential-issuer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ service:
issuerDid: "did:web:example"
issuerBpn: "BPNL00000001TEST"
statusListUrl: "https://example.org/statuslist"
# -- Type of the status list that is referenced unter statusListUrl
# -- valid types are: StatusList2021, BitstringStatusList
statusListType: "BitstringStatusList"
encryptionConfigIndex: 0
encryptionConfigs:
index0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Service.BusinessLogic;

public class IssuerBusinessLogic : IIssuerBusinessLogic
{
private const string StatusList = "StatusList2021";
private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
private static readonly IEnumerable<string> Context = new[] { "https://www.w3.org/2018/credentials/v1", "https://w3id.org/catenax/credentials/v1.0.0" };
private static readonly Regex UrlPathInvalidCharsRegex = new("""[""<>#%{}|\\^~\[\]`]+""", RegexOptions.Compiled, TimeSpan.FromSeconds(1));
Expand Down Expand Up @@ -355,7 +354,7 @@ public async Task<Guid> CreateBpnCredential(CreateBpnCredentialRequest requestDa
),
new CredentialStatus(
_settings.StatusListUrl,
StatusList)
_settings.StatusListType)
);
var schema = JsonSerializer.Serialize(schemaData, Options);
return await HandleCredentialProcessCreation(requestData.BusinessPartnerNumber, VerifiedCredentialTypeKindId.BPN, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, expiryDate, schema, requestData.TechnicalUserDetails, null, requestData.CallbackUrl, companyCredentialDetailsRepository);
Expand Down Expand Up @@ -383,7 +382,7 @@ public async Task<Guid> CreateMembershipCredential(CreateMembershipCredentialReq
),
new CredentialStatus(
_settings.StatusListUrl,
StatusList)
_settings.StatusListType)
);
var schema = JsonSerializer.Serialize(schemaData, Options);
return await HandleCredentialProcessCreation(requestData.HolderBpn, VerifiedCredentialTypeKindId.MEMBERSHIP, VerifiedCredentialTypeId.MEMBERSHIP, expiryDate, schema, requestData.TechnicalUserDetails, null, requestData.CallbackUrl, companyCredentialDetailsRepository);
Expand Down Expand Up @@ -452,7 +451,7 @@ public async Task<Guid> CreateFrameworkCredential(CreateFrameworkCredentialReque
),
new CredentialStatus(
_settings.StatusListUrl,
StatusList)
_settings.StatusListType)
);
var schema = JsonSerializer.Serialize(schemaData, Options);
return await HandleCredentialProcessCreation(requestData.HolderBpn, VerifiedCredentialTypeKindId.FRAMEWORK, requestData.UseCaseFrameworkId, result.Expiry, schema, requestData.TechnicalUserDetails, requestData.UseCaseFrameworkVersionId, requestData.CallbackUrl, companyCredentialDetailsRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class IssuerSettings
[Required(AllowEmptyStrings = false)]
public string StatusListUrl { get; set; } = null!;

[Required(AllowEmptyStrings = false)]
public string StatusListType { get; set; } = null!;

[Required(AllowEmptyStrings = false)]
public string IssuerBpn { get; set; } = null!;
}
Expand Down
1 change: 1 addition & 0 deletions src/issuer/SsiCredentialIssuer.Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"IssuerDid": "",
"IssuerBpn": "",
"StatusListUrl": "",
"StatusListType": "",
"MaxPageSize": 15,
"EncryptionConfigIndex": 0,
"EncryptionConfigs": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public async Task RejectCredential_WithValidRequestAndPendingProcessStepIds_Retu
VerifiedCredentialExternalTypeId.TRACEABILITY_CREDENTIAL,
CompanyUserId.ToString(),
Guid.NewGuid(),
Enumerable.Repeat<Guid>(Guid.NewGuid(), 1)));
Enumerable.Repeat(Guid.NewGuid(), 1)));
A.CallTo(() => _companySsiDetailsRepository.AttachAndModifyCompanySsiDetails(CredentialId, A<Action<CompanySsiDetail>?>._, A<Action<CompanySsiDetail>>._!))
.Invokes((Guid _, Action<CompanySsiDetail>? initialize, Action<CompanySsiDetail> updateFields) =>
{
Expand Down Expand Up @@ -678,15 +678,14 @@ public async Task CreateBpnCredential_ReturnsExpected()
var data = new CreateBpnCredentialRequest("https://example.org/holder/BPNL12343546/did.json", Bpnl, null, null);
var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, _identity.IdentityId, DateTimeOffset.Now);

HttpRequestMessage? request = null;
ConfigureHttpClientFactoryFixture(new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(JsonSerializer.Serialize(didDocument))
}, requestMessage => request = requestMessage);
});

A.CallTo(() => _companySsiDetailsRepository.CreateSsiDetails(_identity.Bpnl, VerifiedCredentialTypeId.BUSINESS_PARTNER_NUMBER, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, _identity.IdentityId, A<Action<CompanySsiDetail>>._))
.Invokes((string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, string userId, Action<CompanySsiDetail>? setOptionalFields) => setOptionalFields?.Invoke(detail));
.Invokes((string _, VerifiedCredentialTypeId _, CompanySsiDetailStatusId _, string _, string _, Action<CompanySsiDetail>? setOptionalFields) => setOptionalFields?.Invoke(detail));

// Act
await _sut.CreateBpnCredential(data, CancellationToken.None);
Expand Down Expand Up @@ -718,12 +717,11 @@ public async Task CreateBpnCredential_WithInvalidUri_ReturnsExpected(string hold
var didId = Guid.NewGuid().ToString();
var didDocument = new DidDocument(didId);
var data = new CreateBpnCredentialRequest(holderUrl, Bpnl, null, null);
HttpRequestMessage? request = null;
ConfigureHttpClientFactoryFixture(new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(JsonSerializer.Serialize(didDocument))
}, requestMessage => request = requestMessage);
});
Task Act() => _sut.CreateBpnCredential(data, CancellationToken.None);

// Act
Expand Down Expand Up @@ -754,17 +752,16 @@ public async Task CreateMembershipCredential_ReturnsExpected()
var data = new CreateMembershipCredentialRequest("https://example.org/holder/BPNL12343546/did.json", Bpnl, "Test", null, null);
var detail = new CompanySsiDetail(CredentialId, _identity.Bpnl, VerifiedCredentialTypeId.MEMBERSHIP, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, _identity.IdentityId, DateTimeOffset.Now);

HttpRequestMessage? request = null;
A.CallTo(() => _companySsiDetailsRepository.GetCertificateTypes(A<string>._))
.Returns(Enum.GetValues<VerifiedCredentialTypeId>().ToAsyncEnumerable());
ConfigureHttpClientFactoryFixture(new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(JsonSerializer.Serialize(didDocument))
}, requestMessage => request = requestMessage);
});

A.CallTo(() => _companySsiDetailsRepository.CreateSsiDetails(_identity.Bpnl, VerifiedCredentialTypeId.MEMBERSHIP, CompanySsiDetailStatusId.ACTIVE, IssuerBpnl, _identity.IdentityId, A<Action<CompanySsiDetail>>._))
.Invokes((string bpnl, VerifiedCredentialTypeId verifiedCredentialTypeId, CompanySsiDetailStatusId companySsiDetailStatusId, string issuerBpn, string userId, Action<CompanySsiDetail>? setOptionalFields) => setOptionalFields?.Invoke(detail));
.Invokes((string _, VerifiedCredentialTypeId _, CompanySsiDetailStatusId _, string _, string _, Action<CompanySsiDetail>? setOptionalFields) => setOptionalFields?.Invoke(detail));

// Act
await _sut.CreateMembershipCredential(data, CancellationToken.None);
Expand Down Expand Up @@ -925,14 +922,13 @@ public async Task CreateFrameworkCredential_ReturnsExpected()
var now = DateTimeOffset.Now;
A.CallTo(() => _dateTimeProvider.OffsetNow).Returns(now);
var data = new CreateFrameworkCredentialRequest("https://example.org/holder/BPNL12343546/did.json", Bpnl, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, useCaseId, null, null);
HttpRequestMessage? request = null;
A.CallTo(() => _companySsiDetailsRepository.CheckCredentialTypeIdExistsForExternalTypeDetailVersionId(useCaseId, VerifiedCredentialTypeId.TRACEABILITY_FRAMEWORK, Bpnl))
.Returns((true, "1.0.0", "https://example.org/tempalte", Enumerable.Repeat(VerifiedCredentialExternalTypeId.TRACEABILITY_CREDENTIAL, 1), now.AddDays(5), false));
ConfigureHttpClientFactoryFixture(new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(JsonSerializer.Serialize(didDocument))
}, requestMessage => request = requestMessage);
});

// Act
await _sut.CreateFrameworkCredential(data, CancellationToken.None);
Expand Down

0 comments on commit 8bdf822

Please sign in to comment.