From eb5cd6598521bb7160f584ca5565123b6bf9d31d Mon Sep 17 00:00:00 2001 From: "Andy Miller (IMS)" <48326098+amiller-ims@users.noreply.github.com> Date: Tue, 20 Dec 2022 13:00:26 -0800 Subject: [PATCH] Add valid endorsement test --- .../inspect/vc/Endorsement30Tests.java | 11 +++++- .../org/oneedtech/inspect/vc/Samples.java | 1 + .../resources/ob30/endorsement-valid.json | 38 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 inspector-vc/src/test/resources/ob30/endorsement-valid.json diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Endorsement30Tests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Endorsement30Tests.java index 7f2493d..de3ed98 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Endorsement30Tests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Endorsement30Tests.java @@ -4,11 +4,11 @@ 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 static org.oneedtech.inspect.test.Assertions.assertValid; 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; @@ -25,6 +25,15 @@ public class Endorsement30Tests { .build(); } + @Test + void testEndorsementWithoutErrors() { + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB30.JSON.ENDORSEMENT_VALID.asFileResource()); + if(verbose) PrintHelper.print(report, true); + assertValid(report); + }); + } + @Test void testEndorsementWithErrors() { assertDoesNotThrow(()->{ diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java index c2a79ea..2efd81c 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/Samples.java @@ -24,6 +24,7 @@ public class Samples { 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 ENDORSEMENT_ERR_SCHEMA_STATUS_REFRESH = new Sample("ob30/endorsement-err-schema-status-refresh.json", false); + public final static Sample ENDORSEMENT_VALID = new Sample("ob30/endorsement-valid.json", false); } public static final class PNG { public final static Sample SIMPLE_JWT_PNG = new Sample("ob30/simple-jwt.png", true); diff --git a/inspector-vc/src/test/resources/ob30/endorsement-valid.json b/inspector-vc/src/test/resources/ob30/endorsement-valid.json new file mode 100644 index 0000000..7c813dc --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/endorsement-valid.json @@ -0,0 +1,38 @@ +{ + "@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" + } + ], + "proof": { + "type": "Ed25519Signature2020", + "created": "2022-12-20T20:56:10Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "did:key:z6MkgG59UvkBM1Lfv2D9JBu6yHn7aKurbwQgs1h5NCYJEk35", + "proofValue": "zLJF9oRBcpVQ9HUt8BRfPevvEGwL74bSyBKDpGzjNpb3KtMQ8JhQDPq3C4sqojneNz74YFWkjLSntC93iZGVscta" + } +} \ No newline at end of file