Added basic language test
This commit is contained in:
parent
a4d8a1692f
commit
48a3de0968
@ -21,6 +21,7 @@ import org.oneedtech.inspect.util.json.ObjectMapperCache;
|
||||
import org.oneedtech.inspect.util.resource.Resource;
|
||||
import org.oneedtech.inspect.util.resource.ResourceType;
|
||||
import org.oneedtech.inspect.util.spec.Specification;
|
||||
import org.oneedtech.inspect.vc.Assertion.Type;
|
||||
import org.oneedtech.inspect.vc.Credential.CredentialEnum;
|
||||
import org.oneedtech.inspect.vc.jsonld.JsonLdGeneratedObject;
|
||||
import org.oneedtech.inspect.vc.jsonld.probe.GraphFetcherProbe;
|
||||
@ -151,18 +152,20 @@ public class OB20Inspector extends Inspector {
|
||||
}
|
||||
|
||||
// verification and revocation
|
||||
for(Probe<JsonLdGeneratedObject> probe : List.of(new VerificationDependenciesProbe(assertion.getId()),
|
||||
new AssertionRevocationListProbe(assertion.getId()))) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(jsonLdGeneratedObject, ctx));
|
||||
if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
|
||||
}
|
||||
if (assertion.getCredentialType() == Type.Assertion) {
|
||||
for(Probe<JsonLdGeneratedObject> probe : List.of(new VerificationDependenciesProbe(assertion.getId()),
|
||||
new AssertionRevocationListProbe(assertion.getId()))) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(jsonLdGeneratedObject, ctx));
|
||||
if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
|
||||
}
|
||||
|
||||
// JWS verification
|
||||
if (assertion.getJwt().isPresent()) {
|
||||
probeCount++;
|
||||
accumulator.add(new VerificationJWTProbe(assertion.getJwt().get()).run(jsonLdGeneratedObject, ctx));
|
||||
if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
|
||||
// JWS verification
|
||||
if (assertion.getJwt().isPresent()) {
|
||||
probeCount++;
|
||||
accumulator.add(new VerificationJWTProbe(assertion.getJwt().get()).run(jsonLdGeneratedObject, ctx));
|
||||
if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,6 +98,16 @@ public class OB20Tests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLanguageInBadgeClass() {
|
||||
assertDoesNotThrow(()->{
|
||||
Report report = validator.run(Samples.OB20.JSON.SIMPLE_LANGUAGE_BADGECLASS.asFileResource());
|
||||
if(verbose) PrintHelper.print(report, true);
|
||||
assertValid(report);
|
||||
// check than
|
||||
});
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class WarningTests {
|
||||
@BeforeAll
|
||||
|
@ -53,6 +53,8 @@ public class Samples {
|
||||
public final static Sample WARNING_ISSUER_NON_HTTPS_JSON = new Sample("ob20/warning-issuer-non-http.json", true);
|
||||
// original: test_validation: test_can_input_badgeclass
|
||||
public final static Sample SIMPLE_BADGECLASS = new Sample("ob20/assets/badgeclass1.json", true);
|
||||
// original: validate_language: validate_language_prop_basic
|
||||
public final static Sample SIMPLE_LANGUAGE_BADGECLASS = new Sample("ob20/badge-class-with-language.json", true);
|
||||
}
|
||||
|
||||
public static final class PNG {
|
||||
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"@context": "https://w3id.org/openbadges/v2",
|
||||
"id": "http://example.org/badgeclass",
|
||||
"@language": "en-US",
|
||||
"name": "Example Badge",
|
||||
"description": "An example",
|
||||
"criteria": "http://example.com/badgecriteria.json",
|
||||
"issuer": "http://example.org/issuer1.json",
|
||||
"type": "BadgeClass"
|
||||
}
|
Loading…
Reference in New Issue
Block a user