From 7c7d2835304b4d48a7821f7a77fc1e376dd6f26d Mon Sep 17 00:00:00 2001 From: Markus Gylling Date: Wed, 31 Aug 2022 15:04:32 +0200 Subject: [PATCH] clean up filenames --- .../oneedtech/inspect/vc/OB30Inspector.java | 7 +- .../org/oneedtech/inspect/vc/IronTests.java | 64 +++++++++++++++++++ .../org/oneedtech/inspect/vc/Samples.java | 12 ++-- ...e-expired.json => simple-err-expired.json} | 0 ...ple-issued.json => simple-err-issued.json} | 0 ...ple-issuer.json => simple-err-issuer.json} | 0 ...proof-error.json => simple-err-proof.json} | 0 ...unknown-type.json => simple-err-type.json} | 0 .../test/resources/ob30/simple-noproof.json | 27 ++++++++ 9 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 inspector-vc/src/test/java/org/oneedtech/inspect/vc/IronTests.java rename inspector-vc/src/test/resources/ob30/{simple-expired.json => simple-err-expired.json} (100%) rename inspector-vc/src/test/resources/ob30/{simple-issued.json => simple-err-issued.json} (100%) rename inspector-vc/src/test/resources/ob30/{simple-issuer.json => simple-err-issuer.json} (100%) rename inspector-vc/src/test/resources/ob30/{simple-proof-error.json => simple-err-proof.json} (100%) rename inspector-vc/src/test/resources/ob30/{simple-unknown-type.json => simple-err-type.json} (100%) create mode 100644 inspector-vc/src/test/resources/ob30/simple-noproof.json diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java index 75b7a74..13e58ac 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java @@ -39,7 +39,6 @@ import org.oneedtech.inspect.vc.probe.RevocationListProbe; import org.oneedtech.inspect.vc.probe.SignatureVerifierProbe; import org.oneedtech.inspect.vc.probe.TypePropertyProbe; import org.oneedtech.inspect.vc.util.CachingDocumentLoader; -import org.oneedtech.inspect.vc.util.JsonNodeUtil; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -90,7 +89,11 @@ public class OB30Inspector extends VCInspector { //we expect the above to place a generated object in the context Credential crd = ctx.getGeneratedObject(Credential.ID); - + + //TODO check context IRIs? the schema doesnt do this + + //TODO new check: that subject @id or IdentityObject is available (at least one is the req) + //type property probeCount++; accumulator.add(new TypePropertyProbe(OpenBadgeCredential).run(crd.getJson(), ctx)); diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/IronTests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/IronTests.java new file mode 100644 index 0000000..89db3e0 --- /dev/null +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/IronTests.java @@ -0,0 +1,64 @@ +package org.oneedtech.inspect.vc; + +import java.net.URI; +import java.time.Instant; +import java.time.temporal.ChronoUnit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.apicatalog.ld.signature.ed25519.Ed25519Proof2020Adapter; +import com.apicatalog.ld.signature.key.KeyPair; +import com.apicatalog.ld.signature.proof.ProofOptions; +import com.apicatalog.ld.signature.proof.VerificationMethod; +import com.apicatalog.vc.Vc; +import com.apicatalog.vc.processor.Issuer; + +import jakarta.json.JsonObject; + +public class IronTests { + + @Disabled + @Test + void testOb_01() { + Assertions.assertDoesNotThrow(()->{ + URI unsigned = Samples.OB30.JSON.SIMPLE_JSON_NOPROOF.asURL().toURI(); + KeyPair kp = Vc.generateKeys("https://w3id.org/security#Ed25519Signature2020").get(URI.create("urn:1"), 256); + ProofOptions options = ProofOptions.create( + Ed25519Proof2020Adapter.TYPE, + new VerificationMethod(URI.create("did:key:z6MkkUD3J14nkYzn46QeuaVSnp7dF85QJKwKvJvfsjx79aXj")), + URI.create("https://w3id.org/security#assertionMethod")).created(Instant.now().truncatedTo(ChronoUnit.SECONDS)); + + Issuer issuer = Vc.sign(unsigned, kp, options); + JsonObject signed = issuer.getCompacted(); + JsonObject proof = signed.getJsonObject("sec:proof"); + + Assertions.assertNotNull(proof); + + System.err.println (issuer.getCompacted().toString()); + + Vc.verify(issuer.getCompacted()).isValid(); + }); + } + + @Disabled + @Test + void testClr_01() { + Assertions.assertDoesNotThrow(()->{ + URI unsigned = Samples.CLR20.JSON.SIMPLE_JSON_NOPROOF.asURL().toURI(); + KeyPair kp = Vc.generateKeys("https://w3id.org/security#Ed25519Signature2020").get(URI.create("urn:1"), 256); + ProofOptions options = ProofOptions.create( + Ed25519Proof2020Adapter.TYPE, + new VerificationMethod(URI.create("did:key:z6MkkUD3J14nkYzn46QeuaVSnp7dF85QJKwKvJvfsjx79aXj")), + URI.create("https://w3id.org/security#assertionMethod")); + + Issuer issuer = Vc.sign(unsigned, kp, options); + JsonObject job = issuer.getCompacted().getJsonObject("sec:proof"); + + //System.err.println (issuer.getCompacted().toString()); + Assertions.assertNotNull(job); + Vc.verify(issuer.getCompacted()).isValid(); + }); + } +} 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 6b6df50..0da143e 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 @@ -11,11 +11,12 @@ public class Samples { public static final class JSON { public final static Sample COMPLETE_JSON = new Sample("ob30/complete.json", false); public final static Sample SIMPLE_JSON = new Sample("ob30/simple.json", true); - public final static Sample SIMPLE_JSON_UNKNOWN_TYPE = new Sample("ob30/simple-unknown-type.json", false); - public final static Sample SIMPLE_JSON_PROOF_ERROR = new Sample("ob30/simple-proof-error.json", false); - public final static Sample SIMPLE_JSON_EXPIRED = new Sample("ob30/simple-expired.json", false); - public final static Sample SIMPLE_JSON_ISSUED = new Sample("ob30/simple-issued.json", false); - public final static Sample SIMPLE_JSON_ISSUER = new Sample("ob30/simple-issuer.json", false); + public final static Sample SIMPLE_JSON_NOPROOF = new Sample("ob30/simple-noproof.json", false); + public final static Sample SIMPLE_JSON_UNKNOWN_TYPE = new Sample("ob30/simple-err-type.json", false); + public final static Sample SIMPLE_JSON_PROOF_ERROR = new Sample("ob30/simple-err-proof.json", false); + public final static Sample SIMPLE_JSON_EXPIRED = new Sample("ob30/simple-err-expired.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 static final class PNG { public final static Sample SIMPLE_JWT_PNG = new Sample("ob30/simple-jwt.png", true); @@ -29,6 +30,7 @@ public class Samples { public static final class CLR20 { public static final class JSON { public final static Sample SIMPLE_JSON = new Sample("clr20/simple.json", true); + public final static Sample SIMPLE_JSON_NOPROOF = new Sample("clr20/simple-noproof.json", true); public final static Sample SIMPLE_JWT = new Sample("clr20/simple.jwt", true); } } diff --git a/inspector-vc/src/test/resources/ob30/simple-expired.json b/inspector-vc/src/test/resources/ob30/simple-err-expired.json similarity index 100% rename from inspector-vc/src/test/resources/ob30/simple-expired.json rename to inspector-vc/src/test/resources/ob30/simple-err-expired.json diff --git a/inspector-vc/src/test/resources/ob30/simple-issued.json b/inspector-vc/src/test/resources/ob30/simple-err-issued.json similarity index 100% rename from inspector-vc/src/test/resources/ob30/simple-issued.json rename to inspector-vc/src/test/resources/ob30/simple-err-issued.json diff --git a/inspector-vc/src/test/resources/ob30/simple-issuer.json b/inspector-vc/src/test/resources/ob30/simple-err-issuer.json similarity index 100% rename from inspector-vc/src/test/resources/ob30/simple-issuer.json rename to inspector-vc/src/test/resources/ob30/simple-err-issuer.json diff --git a/inspector-vc/src/test/resources/ob30/simple-proof-error.json b/inspector-vc/src/test/resources/ob30/simple-err-proof.json similarity index 100% rename from inspector-vc/src/test/resources/ob30/simple-proof-error.json rename to inspector-vc/src/test/resources/ob30/simple-err-proof.json diff --git a/inspector-vc/src/test/resources/ob30/simple-unknown-type.json b/inspector-vc/src/test/resources/ob30/simple-err-type.json similarity index 100% rename from inspector-vc/src/test/resources/ob30/simple-unknown-type.json rename to inspector-vc/src/test/resources/ob30/simple-err-type.json diff --git a/inspector-vc/src/test/resources/ob30/simple-noproof.json b/inspector-vc/src/test/resources/ob30/simple-noproof.json new file mode 100644 index 0000000..0496844 --- /dev/null +++ b/inspector-vc/src/test/resources/ob30/simple-noproof.json @@ -0,0 +1,27 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://imsglobal.github.io/openbadges-specification/context.json", + "https://w3id.org/security/suites/ed25519-2020/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "OpenBadgeCredential" + ], + "issuer": { + "id": "https://example.edu/issuers/565049", + "type": [ + "Profile" + ], + "name": "Example University" + }, + "issuanceDate": "2010-01-01T00:00:00Z", + "name": "Example University Degree", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "type": [ + "AchievementSubject" + ] + } +} \ No newline at end of file