Search in sources :

Example 11 with Shacl2JavaInstanceFactory

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);
        }
    }
}
Also used : Graph(org.apache.jena.graph.Graph) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) SocketAclAlgorithms(won.auth.socket.support.SocketAclAlgorithms) ClassPathResource(org.springframework.core.io.ClassPathResource) Shacl2JavaInstanceFactory(won.shacl2java.Shacl2JavaInstanceFactory) SocketDefinition(won.auth.model.SocketDefinition) Test(org.junit.Test)

Example 12 with Shacl2JavaInstanceFactory

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);
        }
    }
}
Also used : Graph(org.apache.jena.graph.Graph) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) SocketAclAlgorithms(won.auth.socket.support.SocketAclAlgorithms) ClassPathResource(org.springframework.core.io.ClassPathResource) Shacl2JavaInstanceFactory(won.shacl2java.Shacl2JavaInstanceFactory) SocketDefinition(won.auth.model.SocketDefinition) Test(org.junit.Test)

Example 13 with Shacl2JavaInstanceFactory

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);
        }
    }
}
Also used : Graph(org.apache.jena.graph.Graph) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) SocketAclAlgorithms(won.auth.socket.support.SocketAclAlgorithms) ClassPathResource(org.springframework.core.io.ClassPathResource) Shacl2JavaInstanceFactory(won.shacl2java.Shacl2JavaInstanceFactory) SocketDefinition(won.auth.model.SocketDefinition) Test(org.junit.Test)

Aggregations

Shacl2JavaInstanceFactory (won.shacl2java.Shacl2JavaInstanceFactory)13 Test (org.junit.Test)11 Graph (org.apache.jena.graph.Graph)10 ClassPathResource (org.springframework.core.io.ClassPathResource)7 Resource (org.springframework.core.io.Resource)7 SocketDefinition (won.auth.model.SocketDefinition)7 SocketAclAlgorithms (won.auth.socket.support.SocketAclAlgorithms)6 URI (java.net.URI)3 HashSet (java.util.HashSet)3 Optional (java.util.Optional)3 Set (java.util.Set)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Dataset (org.apache.jena.query.Dataset)3 Shapes (org.apache.jena.shacl.Shapes)3 won.auth.model (won.auth.model)3 MethodHandles (java.lang.invoke.MethodHandles)2 Iterator (java.util.Iterator)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Difference (org.apache.jena.graph.compose.Difference)2