Endorsements validation
This commit is contained in:
parent
e47061de8d
commit
c7dee3bdf7
@ -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("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("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("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("@language").type(ValueType.LANGUAGE).build(),
|
||||||
new Validation.Builder().name("version").type(ValueType.TEXT_OR_NUMBER).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("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()
|
|
||||||
))
|
))
|
||||||
.put(Type.EndorsementClaim, List.of(
|
.put(Type.EndorsementClaim, List.of(
|
||||||
new Validation.Builder().name("id").type(ValueType.IRI).required(true).build(),
|
new Validation.Builder().name("id").type(ValueType.IRI).required(true).build(),
|
||||||
|
@ -15,7 +15,7 @@ public class ValidationPropertyProbeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationPropertyProbe of(Validation validation, boolean fullValidate) {
|
public static ValidationPropertyProbe of(Validation validation, boolean fullValidate) {
|
||||||
checkNotNull(validation.getType());
|
checkNotNull(validation.getType());
|
||||||
if (validation.getType() == ValueType.RDF_TYPE) {
|
if (validation.getType() == ValueType.RDF_TYPE) {
|
||||||
return new ValidationRdfTypePropertyProbe(validation, fullValidate);
|
return new ValidationRdfTypePropertyProbe(validation, fullValidate);
|
||||||
}
|
}
|
||||||
|
@ -143,12 +143,11 @@ public class OB20Tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLanguageInBadgeClass() {
|
void testEndorsementsInAssertion() {
|
||||||
assertDoesNotThrow(()->{
|
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);
|
if(verbose) PrintHelper.print(report, true);
|
||||||
assertValid(report);
|
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());
|
Report report = validator.run(Samples.OB20.JSON.SIMPLE_ASSERTION_ISSUER_WITHOUT_PUBLIC_KEY_JSON.asFileResource());
|
||||||
if(verbose) PrintHelper.print(report, true);
|
if(verbose) PrintHelper.print(report, true);
|
||||||
assertValid(report);
|
assertValid(report);
|
||||||
// check than
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
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
|
// 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);
|
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 {
|
public static final class PNG {
|
||||||
|
@ -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"]
|
||||||
|
}
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user