Skip to content

Commit

Permalink
KOGITO-9855: Avoid create protobuf folder with root privileges. Fix p… (
Browse files Browse the repository at this point in the history
#1891)

* KOGITO-9855: Avoid create protobuf folder with root privileges. Fix postgresql Dataindex addons integration test reusing testcontainers

* review suggestion applied
  • Loading branch information
nmirasch authored Oct 30, 2023
1 parent 6b3d59b commit 6c3029d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
package org.kie.kogito.index.test.containers;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.kie.kogito.test.resources.TestResource;
import org.kie.kogito.testcontainers.KogitoGenericContainer;
Expand Down Expand Up @@ -48,9 +53,20 @@ public void setKafkaURL(String kafkaURL) {
public void addProtoFileFolder() {
String pathStr = "target/classes/META-INF/resources/persistence/protobuf/";
String absolutePath = new File(pathStr).getAbsolutePath();
createIfNotExists(absolutePath);
withFileSystemBind(absolutePath, "/home/kogito/data/protobufs/", BindMode.READ_ONLY);
}

public Path createIfNotExists(String absolutePath) {
Path path = Paths.get(absolutePath);
try {
Files.createDirectories(path);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return path;
}

@Override
public int getMappedPort() {
return getMappedPort(PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class PostgreSQLQuarkusAddonDataIndexPersistenceIT {

@Test
void testDataIndexAddon() {
String processDefId = "hello";
given().contentType(ContentType.JSON)
.baseUri(dataIndex)
.body("{ \"query\" : \"{ ProcessDefinitions{ id, name, version, endpoint, addons, source, nodes { id, name, type, uniqueId, metadata { UniqueId } } } }\" }")
.body("{ \"query\" : \"{ ProcessDefinitions (where: { id: {equal: \\\"" + processDefId
+ "\\\"}}){ id, name, version, endpoint, addons, source, nodes { id, name, type, uniqueId, metadata { UniqueId } } } }\" }")
.when().post("/graphql")
.then().log().ifValidationFails().statusCode(200)
.body("data.ProcessDefinitions[0].id", is("hello"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ class PostgreSQLQuarkusAddonDataIndexPersistenceIT {

@Test
void testDataIndexAddon() {
String processDefId = "greet";
String source = given().contentType(ContentType.JSON)
.baseUri(dataIndex)
.body("{ \"query\" : \"{ ProcessDefinitions{ id, name, version, endpoint, addons, source, nodes { id, name, type, uniqueId, metadata { UniqueId } } } }\" }")
.body("{ \"query\" : \"{ ProcessDefinitions(where: { id: {equal: \\\"" + processDefId
+ "\\\"}}){ id, name, version, endpoint, addons, source, nodes { id, name, type, uniqueId, metadata { UniqueId } } } }\" }")
.when().post("/graphql")
.then().log().ifValidationFails().statusCode(200)
.body("data.ProcessDefinitions[0].id", is("greet"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class PostgreSQLQuarkusAddonDataIndexIT {

@Test
void testDataIndexAddon() {
given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions{ id, version, name } }\" }")
String processDefId = "hello";
given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions(where: { id: {equal: \\\"" + processDefId +
"\\\"}}){ id, version, name } }\" }")
.when().post("/graphql")
.then().statusCode(200)
.body("data.ProcessDefinitions.size()", is(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class PostgreSQLQuarkusAddonDataIndexIT {

@Test
void testDataIndexAddon() {
given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions{ id, version, name } }\" }")
String processDefId = "greet";
given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions(where: { id: {equal: \\\"" + processDefId +
"\\\"}}){ id, version, name } }\" }")
.when().post("/graphql")
.then().statusCode(200)
.body("data.ProcessDefinitions.size()", is(1))
Expand Down

0 comments on commit 6c3029d

Please sign in to comment.