Added basic language test

This commit is contained in:
Xavi Aracil 2022-12-12 09:39:12 +01:00
parent a4d8a1692f
commit 48a3de0968
4 changed files with 36 additions and 11 deletions

View File

@ -21,6 +21,7 @@ import org.oneedtech.inspect.util.json.ObjectMapperCache;
import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.Resource;
import org.oneedtech.inspect.util.resource.ResourceType; import org.oneedtech.inspect.util.resource.ResourceType;
import org.oneedtech.inspect.util.spec.Specification; 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.Credential.CredentialEnum;
import org.oneedtech.inspect.vc.jsonld.JsonLdGeneratedObject; import org.oneedtech.inspect.vc.jsonld.JsonLdGeneratedObject;
import org.oneedtech.inspect.vc.jsonld.probe.GraphFetcherProbe; import org.oneedtech.inspect.vc.jsonld.probe.GraphFetcherProbe;
@ -151,6 +152,7 @@ public class OB20Inspector extends Inspector {
} }
// verification and revocation // verification and revocation
if (assertion.getCredentialType() == Type.Assertion) {
for(Probe<JsonLdGeneratedObject> probe : List.of(new VerificationDependenciesProbe(assertion.getId()), for(Probe<JsonLdGeneratedObject> probe : List.of(new VerificationDependenciesProbe(assertion.getId()),
new AssertionRevocationListProbe(assertion.getId()))) { new AssertionRevocationListProbe(assertion.getId()))) {
probeCount++; probeCount++;
@ -164,6 +166,7 @@ public class OB20Inspector extends Inspector {
accumulator.add(new VerificationJWTProbe(assertion.getJwt().get()).run(jsonLdGeneratedObject, ctx)); accumulator.add(new VerificationJWTProbe(assertion.getJwt().get()).run(jsonLdGeneratedObject, ctx));
if(broken(accumulator)) return abort(ctx, accumulator, probeCount); if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
} }
}
} catch (Exception e) { } catch (Exception e) {

View File

@ -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 @Nested
static class WarningTests { static class WarningTests {
@BeforeAll @BeforeAll

View File

@ -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); 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 // original: test_validation: test_can_input_badgeclass
public final static Sample SIMPLE_BADGECLASS = new Sample("ob20/assets/badgeclass1.json", true); 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 { public static final class PNG {

View File

@ -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"
}