From 45734fa9d41ded1d6ec8e9b031e2c0c80b2e85fd Mon Sep 17 00:00:00 2001 From: "Andy Miller (IMS)" <48326098+amiller-ims@users.noreply.github.com> Date: Mon, 22 May 2023 10:30:29 +0900 Subject: [PATCH] Add `credentialStatus` test This uses the wellspring2022-portal app. If it ever breaks, the data was probably changed in the app. --- .../inspect/vc/probe/RevocationListProbe.java | 2 +- .../org/oneedtech/inspect/vc/OB30Tests.java | 13 +++++ .../org/oneedtech/inspect/vc/Samples.java | 1 + .../ob30/credential-status-revoked.json | 56 +++++++++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 inspector-vc/src/test/resources/ob30/credential-status-revoked.json diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java index 7d2ae55..5ab100d 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/RevocationListProbe.java @@ -59,7 +59,7 @@ public class RevocationListProbe extends Probe { JsonNode crdID = crd.getJson().get("id"); //TODO these != checks sb removed (trigger warning) if(crdID != null) { - List list = JsonNodeUtil.asNodeList(revocList.get("revokedCredentials")); + List list = JsonNodeUtil.asNodeList(revocList.get("revokedCredential")); if(list != null) { for(JsonNode item : list) { JsonNode revID = item.get("id"); diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java index 1ad10dc..4e316b6 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/OB30Tests.java @@ -16,6 +16,7 @@ import org.oneedtech.inspect.vc.probe.ExpirationProbe; import org.oneedtech.inspect.vc.probe.InlineJsonSchemaProbe; import org.oneedtech.inspect.vc.probe.IssuanceProbe; import org.oneedtech.inspect.vc.probe.IssuerProbe; +import org.oneedtech.inspect.vc.probe.RevocationListProbe; import org.oneedtech.inspect.vc.probe.EmbeddedProofProbe; import org.oneedtech.inspect.vc.probe.EvidenceProbe; import org.oneedtech.inspect.vc.probe.TypePropertyProbe; @@ -366,4 +367,16 @@ public class OB30Tests { }); } + @Test + void testCredentialStatusRevoked() { + // the credential is valid, but credentialStatus reveals it is revoked + assertDoesNotThrow(()->{ + Report report = validator.run(Samples.OB30.JSON.CREDENTIAL_STATUS_REVOKED.asFileResource()); + if(verbose) PrintHelper.print(report, true); + assertInvalid(report); + assertErrorCount(report, 0); + assertFatalCount(report, 1); + assertHasProbeID(report, RevocationListProbe.ID, true); + }); + } } 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 b0f2607..ab68d9a 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 @@ -38,6 +38,7 @@ public class Samples { public final static Sample ENDORSEMENT_VALID = new Sample("ob30/endorsement-valid.json", false); public final static Sample SIMPLE_JSON_ALIAS_CONTEXT = new Sample("ob30/simple-context-alias.json", true); public final static Sample SIMPLE_JSON_VERSION_CONTEXT = new Sample("ob30/simple-context-version.json", true); + public final static Sample CREDENTIAL_STATUS_REVOKED = new Sample("ob30/credential-status-revoked.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/credential-status-revoked.json b/inspector-vc/src/test/resources/ob30/credential-status-revoked.json new file mode 100644 index 0000000..c233d38 --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/credential-status-revoked.json @@ -0,0 +1,56 @@ +{ + "@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" : "https://dc.1edtech.org/wellspring2022/wellspring-portal/credential/54418d3f-ec01-4652-800a-861c890a51a1", + "type" : [ "VerifiableCredential", "AchievementCredential" ], + "issuer" : { + "id" : "did:web:dc.1edtech.org:wellspring2022:wellspring-portal:org:da1e96e9-afcc-4eed-b9a2-2ddf7353214c", + "type" : "Profile", + "address" : { + "type" : "Address", + "addressCountry" : "Japan" + }, + "name" : "1EdTech Testing" + }, + "awardedDate" : "2023-05-22T10:21:00Z", + "issuanceDate" : "2023-05-22T01:25:28Z", + "name" : "credential-status-revoked", + "description" : "This achievement credential is used in ims-inspector OB30Tests.", + "credentialSubject" : { + "id" : "did:web:dc.1edtech.org:wellspring2022:wellspring-portal:learner:6896f98f-6b42-4c75-98ec-8befd0dc0b29", + "type" : "AchievementSubject", + "achievement" : { + "id" : "https://dc.1edtech.org/wellspring2022/wellspring-portal/achievement/45badd38-e201-4cf3-927f-be55bc7eb414", + "type" : "Achievement", + "achievementType" : "Achievement", + "criteria" : { + "narrative" : "Passes tests" + }, + "description" : "Test achievement 1", + "name" : "Achievement 1" + }, + "source" : { + "id" : "did:web:dc.1edtech.org:wellspring2022:wellspring-portal:org:da1e96e9-afcc-4eed-b9a2-2ddf7353214c", + "type" : "Profile", + "address" : { + "type" : "Address", + "addressCountry" : "Japan" + }, + "name" : "1EdTech Testing" + } + }, + "credentialStatus" : { + "id" : "https://dc.1edtech.org/wellspring2022/wellspring-portal/api/revocations/da1e96e9-afcc-4eed-b9a2-2ddf7353214c", + "type" : "1EdTechRevocationList" + }, + "refreshService" : { + "id" : "https://dc.1edtech.org/wellspring2022/wellspring-portal/api/refresh/54418d3f-ec01-4652-800a-861c890a51a1", + "type" : "1EdTechCredentialRefresh" + }, + "proof" : { + "type" : "Ed25519Signature2020", + "created" : "2023-05-22T01:25:28Z", + "proofPurpose" : "assertionMethod", + "verificationMethod" : "did:web:dc.1edtech.org:wellspring2022:wellspring-portal:org:da1e96e9-afcc-4eed-b9a2-2ddf7353214c#key-0", + "proofValue" : "zXx8gzfqZT6snD9ZkJfMmRDVm1qoKt5gRoSnev6rTeQ4tCLPivv4ocpDEFpKwxyXakAqa76duAhfNcqUeWfnBasp" + } +} \ No newline at end of file