Add endorsement test
This commit is contained in:
		
							parent
							
								
									043f4b6a25
								
							
						
					
					
						commit
						df646b502b
					
				@ -52,4 +52,6 @@ public class CredentialParseProbe extends Probe<Resource> {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static final String ID = CredentialParseProbe.class.getSimpleName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					package org.oneedtech.inspect.vc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 | 
				
			||||||
 | 
					import static org.oneedtech.inspect.test.Assertions.assertFatalCount;
 | 
				
			||||||
 | 
					import static org.oneedtech.inspect.test.Assertions.assertHasProbeID;
 | 
				
			||||||
 | 
					import static org.oneedtech.inspect.test.Assertions.assertInvalid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.BeforeAll;
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.Test;
 | 
				
			||||||
 | 
					import org.oneedtech.inspect.core.Inspector.Behavior;
 | 
				
			||||||
 | 
					import org.oneedtech.inspect.core.probe.json.JsonSchemaProbe;
 | 
				
			||||||
 | 
					import org.oneedtech.inspect.core.report.Report;
 | 
				
			||||||
 | 
					import org.oneedtech.inspect.test.PrintHelper;
 | 
				
			||||||
 | 
					import org.oneedtech.inspect.vc.probe.CredentialParseProbe;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Endorsement30Tests {
 | 
				
			||||||
 | 
					    private static EndorsementInspector validator; 
 | 
				
			||||||
 | 
						private static boolean verbose = false;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@BeforeAll 
 | 
				
			||||||
 | 
						static void setup() {		
 | 
				
			||||||
 | 
							validator = new EndorsementInspector.Builder()				
 | 
				
			||||||
 | 
									.set(Behavior.TEST_INCLUDE_SUCCESS, true)	
 | 
				
			||||||
 | 
									.set(Behavior.VALIDATOR_FAIL_FAST, false)
 | 
				
			||||||
 | 
									.build();	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test
 | 
				
			||||||
 | 
						void testEndorsementWithErrors() {
 | 
				
			||||||
 | 
							assertDoesNotThrow(()->{
 | 
				
			||||||
 | 
								Report report = validator.run(Samples.OB30.JSON.ENDORSEMENT_ERR_SCHEMA_STATUS_REFRESH.asFileResource());
 | 
				
			||||||
 | 
								if(verbose) PrintHelper.print(report, true);
 | 
				
			||||||
 | 
								assertInvalid(report);
 | 
				
			||||||
 | 
								assertFatalCount(report, 1);
 | 
				
			||||||
 | 
								// Parse probe fails because refresh points to invalid URL so nothing to parse
 | 
				
			||||||
 | 
								assertHasProbeID(report, CredentialParseProbe.ID, true);
 | 
				
			||||||
 | 
							});	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -23,6 +23,7 @@ public class Samples {
 | 
				
			|||||||
			public final static Sample SIMPLE_JSON_ISSUED = new Sample("ob30/simple-err-issued.json", false);
 | 
								public final static Sample SIMPLE_JSON_ISSUED = new Sample("ob30/simple-err-issued.json", false);
 | 
				
			||||||
			public final static Sample SIMPLE_JSON_ISSUER = new Sample("ob30/simple-err-issuer.json", false);
 | 
								public final static Sample SIMPLE_JSON_ISSUER = new Sample("ob30/simple-err-issuer.json", false);
 | 
				
			||||||
			public final static Sample SIMPLE_JSON_ERR_CONTEXT = new Sample("ob30/simple-err-context.json", false);
 | 
								public final static Sample SIMPLE_JSON_ERR_CONTEXT = new Sample("ob30/simple-err-context.json", false);
 | 
				
			||||||
 | 
								public final static Sample ENDORSEMENT_ERR_SCHEMA_STATUS_REFRESH = new Sample("ob30/endorsement-err-schema-status-refresh.json", false);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		public static final class PNG {
 | 
							public static final class PNG {
 | 
				
			||||||
			public final static Sample SIMPLE_JWT_PNG = new Sample("ob30/simple-jwt.png", true);
 | 
								public final static Sample SIMPLE_JWT_PNG = new Sample("ob30/simple-jwt.png", true);
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "@context": [
 | 
				
			||||||
 | 
					      "https://www.w3.org/2018/credentials/v1",
 | 
				
			||||||
 | 
					      "https://purl.imsglobal.org/spec/ob/v3p0/context.json",
 | 
				
			||||||
 | 
					      "https://purl.imsglobal.org/spec/ob/v3p0/extensions.json",
 | 
				
			||||||
 | 
					      "https://w3id.org/security/suites/ed25519-2020/v1"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "id": "http://1edtech.edu/endorsementcredential/3732",
 | 
				
			||||||
 | 
					    "type": [
 | 
				
			||||||
 | 
					      "VerifiableCredential",
 | 
				
			||||||
 | 
					      "EndorsementCredential"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "issuer": {
 | 
				
			||||||
 | 
					      "id": "https://state.gov/issuers/565049",
 | 
				
			||||||
 | 
					      "type": "Profile",
 | 
				
			||||||
 | 
					      "name": "State Department of Education"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "issuanceDate": "2010-01-01T00:00:00Z",
 | 
				
			||||||
 | 
					    "expirationDate": "2030-01-01T00:00:00Z",
 | 
				
			||||||
 | 
					    "credentialSubject": {
 | 
				
			||||||
 | 
					      "id": "https://1edtech.edu/issuers/565049",
 | 
				
			||||||
 | 
					      "type": "EndorsementSubject",
 | 
				
			||||||
 | 
					      "endorsementComment": "1EdTech University is in good standing"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "credentialSchema": [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "id": "https://purl.imsglobal.org/spec/ob/v3p0/schema/json/ob_v3p0_endorsementcredential_schema.json",
 | 
				
			||||||
 | 
					        "type": "1EdTechJsonSchemaValidator2019"
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "id": "https://state.gov/schema/endorsementcredential.json",
 | 
				
			||||||
 | 
					        "type": "1EdTechJsonSchemaValidator2019"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "credentialStatus": {
 | 
				
			||||||
 | 
					      "id": "https://state.gov/credentials/3732/revocations",
 | 
				
			||||||
 | 
					      "type": "1EdTechRevocationList"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "refreshService": {
 | 
				
			||||||
 | 
					      "id": "http://state.gov/credentials/3732",
 | 
				
			||||||
 | 
					      "type": "1EdTechCredentialRefresh"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "proof": [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        "type": "Ed25519Signature2020",
 | 
				
			||||||
 | 
					        "created": "2022-12-15T16:53:56Z",
 | 
				
			||||||
 | 
					        "verificationMethod": "https://state.gov/issuers/565049#z6MkmQ49FhpMN7V11B7Qzc6WC6Q3ymVW4xmHUsHBR2MWMMo1",
 | 
				
			||||||
 | 
					        "proofPurpose": "assertionMethod",
 | 
				
			||||||
 | 
					        "proofValue": "z36uHeAeKagDGaXMSqQX1eyKg4rFsWHzYLHxXfypkysPsvTtwN3Z8VZQtn7VQovX2GjkEWgGaW7hQ3UkNKbR84nUn"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user