Skip to content

Commit

Permalink
chore: add test to presenationquery transformer (#4324)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger authored Jul 3, 2024
1 parent 7abbdad commit 7808392
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,51 @@ void transform_withScopes() throws JsonProcessingException {
assertThat(query.getPresentationDefinition()).isNull();
}


@Test
void transform_withEmptyScopes() throws JsonProcessingException {
var obj = """
{
"@context": [
"https://identity.foundation/presentation-exchange/submission/v1",
"https://w3id.org/tractusx-trust/v0.8"
],
"@type": "PresentationQueryMessage",
"scope": []
}
""";
var json = mapper.readValue(obj, JsonObject.class);
var jo = jsonLd.expand(json);
assertThat(jo.succeeded()).withFailMessage(jo::getFailureDetail).isTrue();

var query = transformer.transform(jo.getContent(), context);
assertThat(query).isNotNull();
assertThat(query.getScopes()).isEmpty();
assertThat(query.getPresentationDefinition()).isNull();
}

@Test
void transform_withNullScopes() throws JsonProcessingException {
var obj = """
{
"@context": [
"https://identity.foundation/presentation-exchange/submission/v1",
"https://w3id.org/tractusx-trust/v0.8"
],
"@type": "PresentationQueryMessage"
}
""";
var json = mapper.readValue(obj, JsonObject.class);
var jo = jsonLd.expand(json);
assertThat(jo.succeeded()).withFailMessage(jo::getFailureDetail).isTrue();

var query = transformer.transform(jo.getContent(), context);
assertThat(query).isNotNull();
assertThat(query.getScopes()).isEmpty();
assertThat(query.getPresentationDefinition()).isNull();
}


@Test
void transform_withScopes_separatedByWhitespace() throws JsonProcessingException {
var obj = """
Expand Down

0 comments on commit 7808392

Please sign in to comment.