Added more image validation tests

This commit is contained in:
Xavi Aracil 2022-12-12 18:26:16 +01:00
parent 59c96d68d1
commit e47061de8d
4 changed files with 55 additions and 1 deletions

View File

@ -116,7 +116,7 @@ public class OB20Tests {
}
@Test
void testDataImage() {
void testDataImageInBadge() {
assertDoesNotThrow(()->{
Report report = validator.run(Samples.OB20.JSON.BADGE_WITH_DATA_IMAGE_JSON.asFileResource());
if(verbose) PrintHelper.print(report, true);
@ -124,6 +124,24 @@ public class OB20Tests {
});
}
@Test
void testDataImageInAssertion() {
assertDoesNotThrow(()->{
Report report = validator.run(Samples.OB20.JSON.ASSERTION_WITH_DATA_IMAGE_JSON.asFileResource());
if(verbose) PrintHelper.print(report, true);
assertInvalid(report);
});
}
@Test
void testComplexImageInAssertion() {
assertDoesNotThrow(()->{
Report report = validator.run(Samples.OB20.JSON.BADGE_WITH_COMPLEX_IMAGE_JSON.asFileResource());
if(verbose) PrintHelper.print(report, true);
assertValid(report);
});
}
@Test
void testLanguageInBadgeClass() {
assertDoesNotThrow(()->{

View File

@ -85,6 +85,10 @@ public class Samples {
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);
// original: test_image_validation: test_base64_data_uri_in_assertion
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);
}
public static final class PNG {

View File

@ -0,0 +1,18 @@
{
"@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": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOUMyqsBwACeQFChxlltgAAAABJRU5ErkJggg==",
"evidence": "https://example.org/beths-robot-work.html",
"issuedOn": "2016-12-31T23:59:59Z",
"badge": "https://example.org/robotics-badge.json",
"verification": {
"type": "hosted"
}
}

View File

@ -0,0 +1,14 @@
{
"@context": "https://w3id.org/openbadges/v2",
"id": "http://example.org/badgeclass-with-complex-image.json",
"type": "BadgeClass",
"name": "Example Badge",
"description": "An example",
"criteria": "http://example.com/badgecriteria.json",
"issuer": "http://example.org/issuer1.json",
"image": {
"id": "http://example.org/beths-robot-badge.png",
"author": "http://someoneelse.org/1",
"caption": "A hexagon with attitude"
}
}