diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/util/CachingDocumentLoader.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/util/CachingDocumentLoader.java index 18251b9..8b55b7d 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/util/CachingDocumentLoader.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/util/CachingDocumentLoader.java @@ -6,7 +6,6 @@ import java.net.URISyntaxException; import java.net.URL; import java.time.Duration; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; @@ -27,7 +26,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.io.Resources; import foundation.identity.jsonld.ConfigurableDocumentLoader; -import jakarta.json.JsonStructure; /** * A com.apicatalog DocumentLoader with a threadsafe static cache. @@ -128,6 +126,8 @@ public class CachingDocumentLoader extends ConfigurableDocumentLoader { .put("https://w3id.org/openbadges/v2", Resources.getResource("contexts/obv2x.jsonld")) .put("https://w3id.org/openbadges/extensions/exampleExtension/context.json", Resources.getResource("contexts/obv2x-extensions.json")) .put("https://openbadgespec.org/extensions/exampleExtension/schema.json", Resources.getResource("catalog/openbadgespec.org/extensions/exampleExtension/schema.json")) + .put("https://w3id.org/openbadges/extensions/applyLinkExtension/context.json", Resources.getResource("contexts/obv2x-applylink-extensions.json")) + .put("https://openbadgespec.org/extensions/applyLinkExtension/schema.json", Resources.getResource("catalog/openbadgespec.org/extensions/applyLinkExtension/schema.json")) .build(); @@ -135,7 +135,6 @@ public class CachingDocumentLoader extends ConfigurableDocumentLoader { .initialCapacity(32).maximumSize(64).expireAfterAccess(Duration.ofHours(24)) .build(new CacheLoader, Document>() { public Document load(final Tuple id) throws Exception { - System.out.println("CachingDocumentLoader " + id.t1 + ": " + bundled.containsKey(id.t1)); try (InputStream is = bundled.containsKey(id.t1) ? bundled.get(id.t1).openStream() : new URI(id.t1).toURL().openStream();) { diff --git a/inspector-vc/src/main/resources/contexts/obv2x-applylink-extensions.json b/inspector-vc/src/main/resources/contexts/obv2x-applylink-extensions.json new file mode 100644 index 0000000..da70560 --- /dev/null +++ b/inspector-vc/src/main/resources/contexts/obv2x-applylink-extensions.json @@ -0,0 +1,13 @@ +{ + "@context": { + "obi": "https://w3id.org/openbadges#", + "extensions": "https://w3id.org/openbadges/extensions#", + "url": "extensions:applyLink" + }, + "obi:validation": [ + { + "obi:validatesType": "extensions:ApplyLink", + "obi:validationSchema": "https://openbadgespec.org/extensions/applyLinkExtension/schema.json" + } + ] + } \ No newline at end of file diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB20Tests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB20Tests.java index 1ef7c47..2cf8d99 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB20Tests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB20Tests.java @@ -277,6 +277,15 @@ public class OB20Tests { }); } + @Test + void testMultipleExtensionNode() { + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB20.JSON.ASSERTION_WITH_MULTIPLE_EXTENSIONS_JSON.asFileResource()); + if(verbose) PrintHelper.print(report, true); + assertValid(report); + }); + } + @Test void testInvalidExtensionNode() { assertDoesNotThrow(()->{ diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java index c217cec..f95ce38 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java @@ -95,6 +95,8 @@ public class Samples { public final static Sample ASSERTION_WITH_EXTENSION_NODE_BASIC_JSON = new Sample("ob20/assertion-with-extension-node-basic.json", true); // original: test_validate_extensions: test_validate_extension_node_invalid public final static Sample ASSERTION_WITH_EXTENSION_NODE_INVALID_JSON = new Sample("ob20/assertion-with-extension-node-invalid.json", true); + // original: test_validate_extensions: test_validation_breaks_down_multiple_extensions + public final static Sample ASSERTION_WITH_MULTIPLE_EXTENSIONS_JSON = new Sample("ob20/assertion-with-multiple-extensions.json", true); } public static final class PNG { diff --git a/inspector-vc/src/test/resources/ob20/assertion-with-multiple-extensions.json b/inspector-vc/src/test/resources/ob20/assertion-with-multiple-extensions.json new file mode 100644 index 0000000..51a4b48 --- /dev/null +++ b/inspector-vc/src/test/resources/ob20/assertion-with-multiple-extensions.json @@ -0,0 +1,35 @@ +{ + "@context": [ + "https://w3id.org/openbadges/v2", + "https://w3id.org/openbadges/extensions/exampleExtension/context.json", + "https://w3id.org/openbadges/extensions/applyLinkExtension/context.json" + ], + "id": "http://example.org/assertion", + "type": "Assertion", + "recipient": { + "type": "email", + "hashed": true, + "salt": "deadsea", + "identity": "sha256$ecf5409f3f4b91ab60cc5ef4c02aef7032354375e70cf4d8e43f6a1d29891942" + }, + "image": "https://example.org/beths-robot-badge.png", + "badge": "https://example.org/robotics-badge.json", + "issuedOn": "2016-12-31T23:59:59Z", + "verification": { + "type": "hosted" + }, + "extensions:exampleExtension": { + "id": "_:b0", + "type": [ + "Extension", + "obi:extensions/#ExampleExtension", + "extensions:ApplyLink" + ], + "http://schema.org/text": "I'm a property, short and sweet", + "url": "http://www.1edtech.org" + }, + "evidence": { + "id": "_:b1", + "narrative": "Rocked the free world" + } +} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob20/rdf-validation/valid-issuer-extension.json b/inspector-vc/src/test/resources/ob20/rdf-validation/valid-issuer-extension.json index 139dac8..ebc8f1d 100644 --- a/inspector-vc/src/test/resources/ob20/rdf-validation/valid-issuer-extension.json +++ b/inspector-vc/src/test/resources/ob20/rdf-validation/valid-issuer-extension.json @@ -199,7 +199,7 @@ "verify": "verification" }, "id": "http://example.com/badge1", - "type": ["Issuer", "Extension"], + "type": ["Issuer", "http://example.com/CoolClass"], "name": "Chumley", "url": "https://example.org", "email": "contact@example.org"