Skip to content

Commit

Permalink
fix: adjust create credential request structure (#266)
Browse files Browse the repository at this point in the history
Refs: #265
Reviewed-By: Evelyn Gurschler <evelyn.gurschler@bmw.de>
  • Loading branch information
Phil91 authored Oct 2, 2024
1 parent a9c63a4 commit e466fa3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ namespace Org.Eclipse.TractusX.SsiCredentialIssuer.Wallet.Service.Models;

public record CreateSignedCredentialRequest(
[property: JsonPropertyName("application")] string Application,
[property: JsonPropertyName("payload")] CreateSignedPayload Payload
[property: JsonPropertyName("payload")] IssueWithSignature Issue
);

public record IssueWithSignature(
[property: JsonPropertyName("issueWithSignature")] CreateSignedPayload Payload
);

public record CreateSignedPayload(
[property: JsonPropertyName("content")] JsonDocument Issue,
[property: JsonPropertyName("content")] JsonDocument Content,
[property: JsonPropertyName("signature")] SignData Signature
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class WalletService(
public async Task<CreateSignedCredentialResponse> CreateSignedCredential(JsonDocument payload, CancellationToken cancellationToken)
{
using var client = await basicAuthTokenService.GetBasicAuthorizedClient<WalletService>(_settings, cancellationToken);
var data = new CreateSignedCredentialRequest(_settings.WalletApplication, new CreateSignedPayload(payload, new SignData("external", "jwt", null)));
var data = new CreateSignedCredentialRequest(_settings.WalletApplication, new IssueWithSignature(new CreateSignedPayload(payload, new SignData("external", "jwt", null))));
var result = await client.PostAsJsonAsync(_settings.CreateSignedCredentialPath, data, Options, cancellationToken)
.CatchingIntoServiceExceptionFor("create-credential", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE,
async x => (false, await x.Content.ReadAsStringAsync().ConfigureAwait(ConfigureAwaitOptions.None)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public async Task CreateCredential_WithValid_DoesNotThrowException()
x.Content is JsonContent &&
(x.Content as JsonContent)!.ObjectType == typeof(CreateSignedCredentialRequest) &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Application == "catena-x-portal" &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Payload.Signature.ProofMechanism == "external" &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Payload.Signature.ProofType == "jwt" &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Payload.Signature.KeyName == null &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Payload.Issue == payload
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Issue.Payload.Signature.ProofMechanism == "external" &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Issue.Payload.Signature.ProofType == "jwt" &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Issue.Payload.Signature.KeyName == null &&
((x.Content as JsonContent)!.Value as CreateSignedCredentialRequest)!.Issue.Payload.Content == payload
);
result.Should().BeOfType<CreateSignedCredentialResponse>().Which.Id.Should().Be(id);
}
Expand Down

0 comments on commit e466fa3

Please sign in to comment.