Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand All @@ -32,8 +33,8 @@

public class OpaTestResource implements QuarkusTestResourceLifecycleManager {
private static GenericContainer<?> opa;
private int mappedPort;

@SuppressWarnings({"resource", "HttpUrlsUsage"})
@Override
public Map<String, String> start() {
try {
Expand All @@ -55,7 +56,7 @@ public Map<String, String> start() {
opa.start();
}

mappedPort = opa.getMappedPort(8181);
int mappedPort = opa.getMappedPort(8181);
String containerHost = opa.getHost();
String baseUrl = "http://" + containerHost + ":" + mappedPort;

Expand Down Expand Up @@ -92,7 +93,7 @@ public Map<String, String> start() {
private void loadRegoPolicy(String baseUrl, String policyName, String regoPolicy) {
// Hardcode the policy directly instead of loading through QuarkusTestProfile
try {
URL url = new URL(baseUrl + "/v1/policies/" + policyName);
URL url = URI.create(baseUrl + "/v1/policies/" + policyName).toURL();
System.out.println("Uploading policy to: " + url);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
Expand Down Expand Up @@ -125,7 +126,7 @@ private void loadRegoPolicy(String baseUrl, String policyName, String regoPolicy

@Override
public void stop() {
// Don't stop the container to allow reuse across tests
// Container will be cleaned up when the JVM exits
// Quarkus takes care of reusing the test resource across tests
opa.stop();
}
}