Skip to content

Commit

Permalink
current state
Browse files Browse the repository at this point in the history
  • Loading branch information
karolina-telicent committed Oct 30, 2024
1 parent 0b21ab4 commit 8620094
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
25 changes: 25 additions & 0 deletions scg-system/src/test/files/yaml/config-abac-labels.yaml
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 19 additions & 12 deletions scg-system/src/test/java/io/telicent/TestYamlConfigParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -238,9 +234,10 @@ void yaml_config_abac_labels_store() {
List<String> 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 {
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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<String> 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);

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8620094

Please # to comment.