diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java index e904a5a..3f02a85 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java @@ -245,11 +245,10 @@ public class Assertion extends Credential { new Validation.Builder().name("claim").type(ValueType.ID).required(true).expectedTypes(List.of(Type.EndorsementClaim, Type.Endorsement)).fullValidate(false).build(), new Validation.Builder().name("issuedOn").type(ValueType.DATETIME).required(true).build(), new Validation.Builder().name("issuer").type(ValueType.ID).expectedType(Type.Profile).fetch(true).required(true).build(), - new Validation.Builder().name("verification").build(), + new Validation.Builder().name("verification").type(ValueType.ID).expectedType(Type.VerificationObjectAssertion).required(true).build(), new Validation.Builder().name("@language").type(ValueType.LANGUAGE).build(), new Validation.Builder().name("version").type(ValueType.TEXT_OR_NUMBER).build(), - new Validation.Builder().name("related").type(ValueType.ID).allowRemoteUrl(true).expectedType(Type.Endorsement).many(true).fullValidate(false).build(), - new Validation.Builder().name("endorsement").type(ValueType.ID).allowRemoteUrl(true).fetch(true).expectedType(Type.Endorsement).many(true).build() + new Validation.Builder().name("related").type(ValueType.ID).allowRemoteUrl(true).expectedType(Type.Endorsement).many(true).fullValidate(false).build() )) .put(Type.EndorsementClaim, List.of( new Validation.Builder().name("id").type(ValueType.IRI).required(true).build(), diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java index 816b6bd..a88266b 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/validation/ValidationPropertyProbeFactory.java @@ -15,7 +15,7 @@ public class ValidationPropertyProbeFactory { } public static ValidationPropertyProbe of(Validation validation, boolean fullValidate) { - checkNotNull(validation.getType()); + checkNotNull(validation.getType()); if (validation.getType() == ValueType.RDF_TYPE) { return new ValidationRdfTypePropertyProbe(validation, fullValidate); } 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 1949d92..455773b 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 @@ -143,12 +143,11 @@ public class OB20Tests { } @Test - void testLanguageInBadgeClass() { + void testEndorsementsInAssertion() { assertDoesNotThrow(()->{ - Report report = validator.run(Samples.OB20.JSON.SIMPLE_LANGUAGE_BADGECLASS.asFileResource()); + Report report = validator.run(Samples.OB20.JSON.ASSERTION_WITH_ENDORSEMENTS.asFileResource()); if(verbose) PrintHelper.print(report, true); assertValid(report); - // check than }); } @@ -158,7 +157,6 @@ public class OB20Tests { Report report = validator.run(Samples.OB20.JSON.SIMPLE_ASSERTION_ISSUER_WITHOUT_PUBLIC_KEY_JSON.asFileResource()); if(verbose) PrintHelper.print(report, true); assertValid(report); - // check than }); } 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 1b644af..e9e9bef 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 @@ -89,6 +89,8 @@ public class Samples { public final static Sample ASSERTION_WITH_DATA_IMAGE_JSON = new Sample("ob20/assertion-with-data-image.json", true); // original: test_image_validation: test_validate_badgeclass_image_formats public final static Sample BADGE_WITH_COMPLEX_IMAGE_JSON = new Sample("ob20/assets/badgeclass-with-complex-image.json", true); + // original: test_validate_endorsements + public final static Sample ASSERTION_WITH_ENDORSEMENTS = new Sample("ob20/assertion-with-endorsements.json", true); } public static final class PNG { diff --git a/inspector-vc/src/test/resources/ob20/assertion-with-endorsements.json b/inspector-vc/src/test/resources/ob20/assertion-with-endorsements.json new file mode 100644 index 0000000..4395cdb --- /dev/null +++ b/inspector-vc/src/test/resources/ob20/assertion-with-endorsements.json @@ -0,0 +1,19 @@ +{ + "@context": "https://w3id.org/openbadges/v2", + "type": "Assertion", + "id": "https://example.org/beths-robotics-badge.json", + "recipient": { + "type": "email", + "hashed": true, + "salt": "deadsea", + "identity": "sha256$ecf5409f3f4b91ab60cc5ef4c02aef7032354375e70cf4d8e43f6a1d29891942" + }, + "image": "https://example.org/beths-robot-badge.png", + "evidence": "https://example.org/beths-robot-work.html", + "issuedOn": "2016-12-31T23:59:59Z", + "badge": "https://example.org/robotics-badge.json", + "verification": { + "type": "hosted" + }, + "endorsement": ["https://example.org/endorsement-1.json", "https://example.org/endorsement-2.json"] +} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob20/assets/endorsement-1.json b/inspector-vc/src/test/resources/ob20/assets/endorsement-1.json new file mode 100644 index 0000000..44d6ac2 --- /dev/null +++ b/inspector-vc/src/test/resources/ob20/assets/endorsement-1.json @@ -0,0 +1,14 @@ +{ + "@context": "https://w3id.org/openbadges/v2", + "id": "http://example.org/endorsement-1.json", + "type": "Endorsement", + "claim": { + "id": "https://example.org/robotics-badge.json", + "endorsementComment": "Pretty good" + }, + "issuedOn": "2017-10-01T00:00Z", + "issuer": "http://example.org/issuer1.json", + "verification": { + "type": "HostedBadge" + } +} \ No newline at end of file diff --git a/inspector-vc/src/test/resources/ob20/assets/endorsement-2.json b/inspector-vc/src/test/resources/ob20/assets/endorsement-2.json new file mode 100644 index 0000000..70ccc4d --- /dev/null +++ b/inspector-vc/src/test/resources/ob20/assets/endorsement-2.json @@ -0,0 +1,14 @@ +{ + "@context": "https://w3id.org/openbadges/v2", + "id": "http://example.org/endorsement-2.json", + "type": "Endorsement", + "claim": { + "id": "https://example.org/robotics-badge.json", + "endorsementComment": "Pretty good" + }, + "issuedOn": "2017-10-01T00:00Z", + "issuer": "http://example.org/issuer1.json", + "verification": { + "type": "HostedBadge" + } +} \ No newline at end of file