Added image validation tests
This commit is contained in:
parent
ed74e2a60d
commit
59c96d68d1
@ -217,7 +217,8 @@ public class Assertion extends Credential {
|
||||
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.BadgeClass).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("endorsement").type(ValueType.ID).allowRemoteUrl(true).fetch(true).expectedType(Type.Endorsement).many(true).build(),
|
||||
new Validation.Builder().name("image").type(ValueType.IMAGE).allowDataUri(true).build()
|
||||
))
|
||||
.put(Type.AlignmentObject, List.of(
|
||||
new Validation.Builder().name("type").type(ValueType.RDF_TYPE).many(true).defaultType(Type.AlignmentObject).build(),
|
||||
@ -286,7 +287,8 @@ public class Assertion extends Credential {
|
||||
new Validation.Builder().name("type").type(ValueType.RDF_TYPE).many(true).defaultType("schema:ImageObject").build(),
|
||||
new Validation.Builder().name("id").type(ValueType.DATA_URI_OR_URL).required(true).build(),
|
||||
new Validation.Builder().name("caption").type(ValueType.TEXT).build(),
|
||||
new Validation.Builder().name("author").type(ValueType.IRI).build()
|
||||
new Validation.Builder().name("author").type(ValueType.IRI).build(),
|
||||
new Validation.Builder().name("id").type(ValueType.IMAGE).allowDataUri(true).build()
|
||||
))
|
||||
.put(Type.Issuer, List.of(
|
||||
new Validation.Builder().name("id").type(ValueType.IRI).required(true).build(),
|
||||
@ -321,8 +323,7 @@ public class Assertion extends Credential {
|
||||
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.Profile).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("endorsement").type(ValueType.ID).allowRemoteUrl(true).fetch(true).expectedType(Type.Endorsement).many(true).build() ))
|
||||
.put(Type.RevocationList, List.of(
|
||||
new Validation.Builder().name("type").type(ValueType.RDF_TYPE).required(true).many(true).mustContainOneType(List.of(Type.RevocationList)).build(),
|
||||
new Validation.Builder().name("id").type(ValueType.IRI).build()
|
||||
|
@ -44,7 +44,7 @@ public class ValidationPropertyProbe extends PropertyProbe {
|
||||
}
|
||||
|
||||
public ValidationPropertyProbe(String id, Validation validation) {
|
||||
this(ID, validation, true);
|
||||
this(id, validation, true);
|
||||
}
|
||||
|
||||
public ValidationPropertyProbe(Validation validation, boolean fullValidate) {
|
||||
|
@ -115,6 +115,15 @@ public class OB20Tests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDataImage() {
|
||||
assertDoesNotThrow(()->{
|
||||
Report report = validator.run(Samples.OB20.JSON.BADGE_WITH_DATA_IMAGE_JSON.asFileResource());
|
||||
if(verbose) PrintHelper.print(report, true);
|
||||
assertValid(report);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLanguageInBadgeClass() {
|
||||
assertDoesNotThrow(()->{
|
||||
|
@ -83,6 +83,8 @@ public class Samples {
|
||||
public final static Sample SIMPLE_FUTURE_ASSERTION_JSON = new Sample("ob20/basic-assertion-in-future.json", true);
|
||||
// original: test_validate_related: test_validate_related_language
|
||||
public final static Sample BASIC_WITH_LANGUAGE_JSON = new Sample("ob20/basic-assertion-with-language.json", true);
|
||||
// original: test_image_validation: test_base64_data_uri_in_badgeclass
|
||||
public final static Sample BADGE_WITH_DATA_IMAGE_JSON = new Sample("ob20/assets/badge-with-data-image.json", true);
|
||||
}
|
||||
|
||||
public static final class PNG {
|
||||
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"@context": "https://w3id.org/openbadges/v2",
|
||||
"type": "BadgeClass",
|
||||
"id": "https://example.org/badge-from-organization-with-revocation-list.json",
|
||||
"name": "Awesome Robotics Badge",
|
||||
"description": "For doing awesome things with robots that people think is pretty great.",
|
||||
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOUMyqsBwACeQFChxlltgAAAABJRU5ErkJggg==",
|
||||
"criteria": "http://example.com/badgecriteria.json",
|
||||
"issuer": "https://example.org/organization-with-revocation-list.json"
|
||||
}
|
Loading…
Reference in New Issue
Block a user