use of won.shacl2java.Shacl2JavaInstanceFactory in project webofneeds by researchstudio-sat.
the class SocketAuthorizationTest method testAddTargetAuth.
@Test
public void testAddTargetAuth() throws IOException {
Shacl2JavaInstanceFactory factory = AuthUtils.instanceFactory();
SocketAclAlgorithms socketAclAlgos = new SocketAclAlgorithms();
String folder = "addTargetAuth";
for (Resource socketGraphResource : getInputs(folder)) {
String baseName = getTestBaseName(socketGraphResource.getFilename());
String testIdentifier = folder + "/" + baseName;
logger.debug("running test {}", testIdentifier);
Graph expectedResult = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-after.ttl"));
Graph aclBefore = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-before.ttl"));
Shacl2JavaInstanceFactory.Accessor ac = factory.accessor(loadGraph(socketGraphResource));
Set<SocketDefinition> sockets = ac.getInstancesOfType(SocketDefinition.class);
for (SocketDefinition socket : sockets) {
Graph actualResult = socketAclAlgos.addAuthorizationsForSocket(aclBefore, socket.getTargetAuths(), OWN_SOCKET1, TARGET_ATOM);
assertIsomorphicGraphs(expectedResult, actualResult, testIdentifier);
}
}
}
use of won.shacl2java.Shacl2JavaInstanceFactory in project webofneeds by researchstudio-sat.
the class SocketAuthorizationTest method testAddLocalAuth.
@Test
public void testAddLocalAuth() throws IOException {
Shacl2JavaInstanceFactory factory = AuthUtils.instanceFactory();
SocketAclAlgorithms socketAclAlgos = new SocketAclAlgorithms();
String folder = "addLocalAuth";
for (Resource socketGraphResource : getInputs(folder)) {
String baseName = getTestBaseName(socketGraphResource.getFilename());
String testIdentifier = folder + "/" + baseName;
logger.debug("running test {}", testIdentifier);
Graph expectedResult = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-after.ttl"));
Graph aclBefore = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-before.ttl"));
Shacl2JavaInstanceFactory.Accessor ac = factory.accessor(loadGraph(socketGraphResource));
Set<SocketDefinition> sockets = ac.getInstancesOfType(SocketDefinition.class);
for (SocketDefinition socket : sockets) {
Graph actualResult = socketAclAlgos.addAuthorizationsForSocket(aclBefore, socket.getLocalAuths(), OWN_SOCKET1, OWN_ATOM);
assertIsomorphicGraphs(expectedResult, actualResult, testIdentifier);
}
}
}
use of won.shacl2java.Shacl2JavaInstanceFactory in project webofneeds by researchstudio-sat.
the class SocketAuthorizationTest method testRemoveTargetAuthRemoveSocket.
@Test
public void testRemoveTargetAuthRemoveSocket() throws IOException {
Shacl2JavaInstanceFactory factory = AuthUtils.instanceFactory();
SocketAclAlgorithms socketAclAlgos = new SocketAclAlgorithms();
String folder = "removeTargetAuthRemoveSocket";
for (Resource socketGraphResource : getInputs(folder)) {
String baseName = getTestBaseName(socketGraphResource.getFilename());
String testIdentifier = folder + "/" + baseName;
logger.debug("running test {}", testIdentifier);
Graph expectedResult = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-after.ttl"));
Graph aclBefore = loadGraph(new ClassPathResource("/won/socket/" + folder + "/" + baseName + "-acl-before.ttl"));
Shacl2JavaInstanceFactory.Accessor ac = factory.accessor(loadGraph(socketGraphResource));
Set<SocketDefinition> sockets = ac.getInstancesOfType(SocketDefinition.class);
for (SocketDefinition socket : sockets) {
Graph actualResult = socketAclAlgos.removeAuthorizationsForSocket(aclBefore, OWN_SOCKET1, TARGET_ATOM, true);
assertIsomorphicGraphs(expectedResult, actualResult, testIdentifier);
}
}
}
Aggregations