From 7808392acf10a1b00bb47ecd481ee7a3b50dfe27 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:22:32 +0200 Subject: [PATCH] chore: add test to presenationquery transformer (#4324) --- ...esentationQueryMessageTransformerTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/extensions/common/iam/identity-trust/identity-trust-transform/src/test/java/org/eclipse/edc/iam/identitytrust/transform/to/JsonObjectToPresentationQueryMessageTransformerTest.java b/extensions/common/iam/identity-trust/identity-trust-transform/src/test/java/org/eclipse/edc/iam/identitytrust/transform/to/JsonObjectToPresentationQueryMessageTransformerTest.java index e9f9259d40e..c2ad3d26143 100644 --- a/extensions/common/iam/identity-trust/identity-trust-transform/src/test/java/org/eclipse/edc/iam/identitytrust/transform/to/JsonObjectToPresentationQueryMessageTransformerTest.java +++ b/extensions/common/iam/identity-trust/identity-trust-transform/src/test/java/org/eclipse/edc/iam/identitytrust/transform/to/JsonObjectToPresentationQueryMessageTransformerTest.java @@ -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 = """