Skip to content

Commit 9677e36

Browse files
authored
JCL-299: Unwrap presentation for verify method (#474)
1 parent 2c90f87 commit 9677e36

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

access-grant/src/main/java/com/inrupt/client/accessgrant/AccessGrantClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ public CompletionStage<AccessGrant> grantAccess(final AccessRequest request) {
232232
}
233233
});
234234
});
235-
236235
}
237236

238237
/**
@@ -298,7 +297,8 @@ public CompletionStage<VerificationResponse> verify(final AccessCredential crede
298297
try (final InputStream is = new ByteArrayInputStream(credential.serialize().getBytes(UTF_8))) {
299298
final Map<String, Object> data = jsonService.fromJson(is,
300299
new HashMap<String, Object>(){}.getClass().getGenericSuperclass());
301-
presentation.put(VERIFIABLE_CREDENTIAL, data);
300+
Utils.getCredentialsFromPresentation(data, credential.getTypes()).stream().findFirst()
301+
.ifPresent(c -> presentation.put(VERIFIABLE_CREDENTIAL, c));
302302
} catch (final IOException ex) {
303303
throw new AccessGrantException("Unable to serialize credential", ex);
304304
}

access-grant/src/test/java/com/inrupt/client/accessgrant/MockAccessGrantServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ private void setupMocks() {
207207
.atPriority(1)
208208
.withHeader("Authorization", containing("Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9."))
209209
.withRequestBody(containing("\"" + wireMockServer.baseUrl() + "/access-grant-1\""))
210+
.withRequestBody(containing("\"verifiableCredential\":{\""))
210211
.willReturn(aResponse()
211212
.withStatus(200)
212213
.withHeader("Content-Type", "application/json")
@@ -216,6 +217,7 @@ private void setupMocks() {
216217
.atPriority(1)
217218
.withHeader("Authorization", containing("Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9."))
218219
.withRequestBody(containing("\"" + wireMockServer.baseUrl() + "/access-request-5\""))
220+
.withRequestBody(containing("\"verifiableCredential\":{\""))
219221
.willReturn(aResponse()
220222
.withStatus(200)
221223
.withHeader("Content-Type", "application/json")

0 commit comments

Comments
 (0)