From 86200945b8adcb56ec113a5e03340b3cbc36f404 Mon Sep 17 00:00:00 2001 From: Karolina Kadzielawa Date: Wed, 30 Oct 2024 10:03:20 +0000 Subject: [PATCH] current state --- .../test/files/yaml/config-abac-labels.yaml | 25 +++++++++++++++ .../io/telicent/TestYamlConfigParser.java | 31 ++++++++++++------- 2 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 scg-system/src/test/files/yaml/config-abac-labels.yaml diff --git a/scg-system/src/test/files/yaml/config-abac-labels.yaml b/scg-system/src/test/files/yaml/config-abac-labels.yaml new file mode 100644 index 0000000..dea4952 --- /dev/null +++ b/scg-system/src/test/files/yaml/config-abac-labels.yaml @@ -0,0 +1,25 @@ +version: "1.0" +prefixes: + - prefix: "authz" + namespace: "http://telicent.io/security#" +server: + name: "Fuseki server simple" +services: + - name: "ds" + endpoints: + - operation: authz:query + settings: + - name: "upload" + operation: authz:upload + database: "abac-db" + +databases: + - name: "abac-db" + dbtype: ABAC + dataset: "dataset-under" + attributes: "attribute-store.ttl" + labels: "labels.ttl" + + - name: "dataset-under" + dbtype: TIM + data: "src/test/files/yaml/data-no-labels.trig" \ No newline at end of file diff --git a/scg-system/src/test/java/io/telicent/TestYamlConfigParser.java b/scg-system/src/test/java/io/telicent/TestYamlConfigParser.java index b50406d..12e47a0 100644 --- a/scg-system/src/test/java/io/telicent/TestYamlConfigParser.java +++ b/scg-system/src/test/java/io/telicent/TestYamlConfigParser.java @@ -65,7 +65,6 @@ class TestYamlConfigParser { private static final String DIR = "src/test/files"; - private static String STATE_DIR = "target/state"; private FusekiServer server; private static MockKafka mock; @@ -161,14 +160,13 @@ public static void before() { mock.createTopic("RDF0"); } - - @BeforeEach void setUp() throws Exception { FusekiLogging.setLogging(); SysFusekiABAC.init(); LibTestsSCG.teardownAuthentication(); LibTestsSCG.disableInitialCompaction(); + expectedRSR.reset(); } @AfterEach @@ -216,7 +214,6 @@ void yaml_config_abac() { RowSetRewindable actualResponseRSR; load(server); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); assertTrue(equals); } @@ -228,7 +225,6 @@ void yaml_config_abac_tim() { RowSetRewindable actualResponseRSR; load(server); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); assertTrue(equals); } @@ -238,9 +234,10 @@ void yaml_config_abac_labels_store() { List arguments = List.of("--conf",DIR + "/yaml/config-abac-labels-store.yaml"); server = construct(arguments.toArray(new String[0])).start(); - // it only works if it's target/labels, so it's probably working thanks to some other test - // that's why it fails after clean - // but the data does get uploaded both to the labels and the database + // it only works if the labels store is at target/labels, same location as in yaml_config_custom_prefix + // that's why it would fail after clean, but pass otherwise + // the data does get uploaded both to the labels store and the database + // all existing users return empty, non-existing 403 Forbidden as expected Dataset dataset = TDB2Factory.connectDataset("target/labels-test"); dataset.begin(org.apache.jena.query.ReadWrite.WRITE); try { @@ -259,7 +256,6 @@ void yaml_config_abac_labels_store() { String uploadURL = URL + "/upload"; load(uploadURL, DIR + "/yaml/data-no-labels.trig"); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); assertTrue(equals); } @@ -275,7 +271,6 @@ void yaml_config_abac_attributes_store() { RowSetRewindable actualResponseRSR; load(server); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); assertTrue(equals); } @@ -289,15 +284,28 @@ void yaml_config_abac_triple_default_labels() { String uploadURL = URL + "/upload"; load(uploadURL, DIR + "/yaml/data-no-labels.trig"); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSRtdl, actualResponseRSR); assertTrue(equals); } + @Test + void yaml_config_abac_labels() { + List arguments = List.of("--conf",DIR + "/yaml/config-abac-labels.yaml"); + server = construct(arguments.toArray(new String[0])).start(); + RowSetRewindable actualResponseRSR; + String URL = "http://localhost:" + server.getPort() + serviceName; + String uploadURL = URL + "/upload"; + load(uploadURL, DIR + "/yaml/data-no-labels.trig"); + actualResponseRSR = query(server, "u1"); + boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); + assertTrue(equals); + } + @Test void yaml_config_kafka_connector() { String TOPIC = "RDF0"; + String STATE_DIR = "target/state"; FileOps.ensureDir(STATE_DIR); FileOps.clearDirectory(STATE_DIR); @@ -329,7 +337,6 @@ void yaml_config_custom_prefix() { RowSetRewindable actualResponseRSR; load(server); actualResponseRSR = query(server, "u1"); - expectedRSR.reset(); boolean equals = ResultSetCompare.isomorphic(expectedRSR, actualResponseRSR); assertTrue(equals); }