Finished extension validation
This commit is contained in:
parent
1818fdabf5
commit
766228bbad
@ -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<Tuple<String, DocumentLoaderOptions>, Document>() {
|
||||
public Document load(final Tuple<String, DocumentLoaderOptions> 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();) {
|
||||
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
@ -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(()->{
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user