use of won.auth.model.AseRoot in project webofneeds by researchstudio-sat.
the class GrantedOperationsTest method testSet1.
@Test
public void testSet1() throws IOException {
Shacl2JavaInstanceFactory factory = AuthUtils.instanceFactory();
Shapes atomDataShapes = loadShapes(atomDataShapesDef);
ModelBasedConnectionTargetCheckEvaluator targetAtomChecker = new ModelBasedConnectionTargetCheckEvaluator(atomDataShapes, "won.auth.test.model");
ModelBasedAtomNodeChecker atomNodeChecker = new ModelBasedAtomNodeChecker(atomDataShapes, "won.auth.test.model");
String folder = "set1";
for (Resource socketGraphResource : getInputs(folder)) {
String baseName = getTestBaseName(socketGraphResource.getFilename());
Graph inputGraph = loadGraph(socketGraphResource);
String testIdentifier = folder + "/" + baseName;
logger.debug("running test {}", testIdentifier);
validateTestData(atomDataShapes, inputGraph, true, testIdentifier);
validateTestData(AuthUtils.shapes(), inputGraph, true, testIdentifier);
Shacl2JavaInstanceFactory.Accessor ac = factory.accessor(inputGraph);
targetAtomChecker.loadData(inputGraph);
atomNodeChecker.loadData(inputGraph);
Set<OperationRequest> operationRequestSet = ac.getInstancesOfType(OperationRequest.class);
if (operationRequestSet.size() > 1) {
Assert.fail("only one operationRequest allowed per file");
}
OperationRequest operationRequest = operationRequestSet.stream().findFirst().get();
setValidTokenExpiryDate(operationRequest);
WonAclEvaluatorTestFactory evaluatorFactory = new WonAclEvaluatorTestFactory(targetAtomChecker, atomNodeChecker, null);
evaluatorFactory.load(inputGraph);
WonAclEvaluator evaluator = evaluatorFactory.create(false);
Optional<AseRoot> grantedOperations = evaluator.getGrants(operationRequest);
Graph actualResult = RdfOutput.toGraph(grantedOperations.get(), false);
actualResult = new Difference(actualResult, AuthUtils.shapes().getGraph());
Graph expectedResult = loadGraph(new ClassPathResource("/won/grantedOps/" + folder + "/" + baseName + "-expected.ttl"));
assertIsomorphicGraphs(expectedResult, actualResult, testIdentifier);
}
}
Aggregations