Added more image validation tests
This commit is contained in:
		
							parent
							
								
									59c96d68d1
								
							
						
					
					
						commit
						e47061de8d
					
				@ -116,7 +116,7 @@ public class OB20Tests {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	void testDataImage() {
 | 
						void testDataImageInBadge() {
 | 
				
			||||||
		assertDoesNotThrow(()->{
 | 
							assertDoesNotThrow(()->{
 | 
				
			||||||
			Report report = validator.run(Samples.OB20.JSON.BADGE_WITH_DATA_IMAGE_JSON.asFileResource());
 | 
								Report report = validator.run(Samples.OB20.JSON.BADGE_WITH_DATA_IMAGE_JSON.asFileResource());
 | 
				
			||||||
			if(verbose) PrintHelper.print(report, true);
 | 
								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
 | 
						@Test
 | 
				
			||||||
	void testLanguageInBadgeClass() {
 | 
						void testLanguageInBadgeClass() {
 | 
				
			||||||
		assertDoesNotThrow(()->{
 | 
							assertDoesNotThrow(()->{
 | 
				
			||||||
 | 
				
			|||||||
@ -85,6 +85,10 @@ public class Samples {
 | 
				
			|||||||
			public final static Sample BASIC_WITH_LANGUAGE_JSON = new Sample("ob20/basic-assertion-with-language.json", true);
 | 
								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
 | 
								// 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 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 {
 | 
							public static final class PNG {
 | 
				
			||||||
 | 
				
			|||||||
@ -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"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -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"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user