Redirect warning in compaction
This commit is contained in:
parent
0ba347d8f0
commit
a629fc8372
@ -41,19 +41,12 @@ public class JsonLDCompactionProve extends Probe<Credential> {
|
|||||||
compactApi.options(new JsonLdOptions(new CachingDocumentLoader(localDomains)));
|
compactApi.options(new JsonLdOptions(new CachingDocumentLoader(localDomains)));
|
||||||
JsonObject compactedObject = compactApi.get();
|
JsonObject compactedObject = compactApi.get();
|
||||||
|
|
||||||
// TODO: Handle mismatch between URL node source and declared ID.
|
// Handle mismatch between URL node source and declared ID.
|
||||||
if (compactedObject.get("id") != null && crd.getResource().getID() != null
|
if (compactedObject.get("id") != null && crd.getResource().getID() != null
|
||||||
&& !compactedObject.get("id").toString().equals(crd.getResource().getID())) {
|
&& !compactedObject.get("id").toString().equals(crd.getResource().getID())) {
|
||||||
|
return warning("Node fetched from source " + crd.getResource().getID() + " declared its id as " + compactedObject.get("id").toString(), ctx);
|
||||||
// TODO: warning!!
|
|
||||||
// report_message(
|
|
||||||
// "Node fetched from source {} declared its id as {}".format(
|
|
||||||
// task_meta['node_id'], node_id), MESSAGE_LEVEL_WARNING, success=False
|
|
||||||
// ),
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return success(this, ctx);
|
return success(this, ctx);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return fatal("Error while parsing credential: " + e.getMessage(), ctx);
|
return fatal("Error while parsing credential: " + e.getMessage(), ctx);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,13 @@ package org.oneedtech.inspect.vc;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.oneedtech.inspect.test.Assertions.assertValid;
|
import static org.oneedtech.inspect.test.Assertions.assertValid;
|
||||||
|
import static org.oneedtech.inspect.test.Assertions.assertWarning;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.oneedtech.inspect.core.Inspector.Behavior;
|
import org.oneedtech.inspect.core.Inspector.Behavior;
|
||||||
import org.oneedtech.inspect.core.report.Report;
|
import org.oneedtech.inspect.core.report.Report;
|
||||||
@ -22,7 +24,7 @@ public class OB20Tests {
|
|||||||
validator = new TestBuilder()
|
validator = new TestBuilder()
|
||||||
.add(new URI("https://www.example.org/"), "ob20/assets")
|
.add(new URI("https://www.example.org/"), "ob20/assets")
|
||||||
.set(Behavior.TEST_INCLUDE_SUCCESS, true)
|
.set(Behavior.TEST_INCLUDE_SUCCESS, true)
|
||||||
.set(Behavior.TEST_INCLUDE_WARNINGS, true)
|
.set(Behavior.TEST_INCLUDE_WARNINGS, false)
|
||||||
.set(Behavior.VALIDATOR_FAIL_FAST, true)
|
.set(Behavior.VALIDATOR_FAIL_FAST, true)
|
||||||
.set(OB20Inspector.Behavior.ALLOW_LOCAL_REDIRECTION, true)
|
.set(OB20Inspector.Behavior.ALLOW_LOCAL_REDIRECTION, true)
|
||||||
.build();
|
.build();
|
||||||
@ -36,4 +38,27 @@ public class OB20Tests {
|
|||||||
assertValid(report);
|
assertValid(report);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
static class WarningTests {
|
||||||
|
@BeforeAll
|
||||||
|
static void setup() throws URISyntaxException {
|
||||||
|
validator = new TestBuilder()
|
||||||
|
.add(new URI("https://www.example.org/"), "ob20/assets")
|
||||||
|
.set(Behavior.TEST_INCLUDE_SUCCESS, true)
|
||||||
|
.set(Behavior.TEST_INCLUDE_WARNINGS, true)
|
||||||
|
.set(Behavior.VALIDATOR_FAIL_FAST, true)
|
||||||
|
.set(OB20Inspector.Behavior.ALLOW_LOCAL_REDIRECTION, true)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testWarningRedirectionJsonValid() {
|
||||||
|
assertDoesNotThrow(()->{
|
||||||
|
Report report = validator.run(Samples.OB20.JSON.WARNING_REDIRECTION_ASSERTION_JSON.asFileResource());
|
||||||
|
if(verbose) PrintHelper.print(report, true);
|
||||||
|
assertWarning(report);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user