diff --git a/integration-tests/opentelemetry-reactive/pom.xml b/integration-tests/opentelemetry-reactive/pom.xml index c213fc02432ba..460516176fcd3 100644 --- a/integration-tests/opentelemetry-reactive/pom.xml +++ b/integration-tests/opentelemetry-reactive/pom.xml @@ -41,6 +41,12 @@ opentelemetry-sdk-testing + + + io.quarkus + quarkus-elytron-security-properties-file + + io.quarkus @@ -121,6 +127,19 @@ + + io.quarkus + quarkus-elytron-security-properties-file-deployment + ${project.version} + pom + test + + + * + * + + + diff --git a/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/SecuredResource.java b/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/SecuredResource.java new file mode 100644 index 0000000000000..126184518bf61 --- /dev/null +++ b/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/SecuredResource.java @@ -0,0 +1,15 @@ +package io.quarkus.it.opentelemetry.reactive; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestPath; + +@Path("secured") +public class SecuredResource { + @GET + @Path("item/{value}") + public String get(@RestPath String value) { + return "Received: " + value; + } +} diff --git a/integration-tests/opentelemetry-reactive/src/main/resources/application.properties b/integration-tests/opentelemetry-reactive/src/main/resources/application.properties index 7485ece03853e..4b779b476294f 100644 --- a/integration-tests/opentelemetry-reactive/src/main/resources/application.properties +++ b/integration-tests/opentelemetry-reactive/src/main/resources/application.properties @@ -2,3 +2,12 @@ quarkus.rest-client.client.url=${test.url quarkus.otel.bsp.schedule.delay=100 quarkus.otel.bsp.export.timeout=5s + +quarkus.security.users.embedded.enabled=true +quarkus.security.users.embedded.plain-text=true +quarkus.security.users.embedded.users.scott=reader +quarkus.security.users.embedded.users.stuart=writer +quarkus.security.users.embedded.roles.scott=READER +quarkus.security.users.embedded.roles.stuart=READER,WRITER +quarkus.http.auth.permission.secured.policy=authenticated +quarkus.http.auth.permission.secured.paths=/secured/* diff --git a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java index 26bf417e99ca0..5b9ef8c7f9818 100644 --- a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java +++ b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java @@ -10,7 +10,9 @@ import static io.quarkus.it.opentelemetry.reactive.Utils.getSpans; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpansByKindAndParentId; import static io.restassured.RestAssured.given; +import static io.restassured.RestAssured.when; import static java.net.HttpURLConnection.HTTP_OK; +import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toSet; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -21,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -36,7 +37,7 @@ public class OpenTelemetryReactiveTest { @AfterEach void reset() { given().get("/reset").then().statusCode(HTTP_OK); - await().atMost(5, TimeUnit.SECONDS).until(() -> getSpans().size() == 0); + await().atMost(5, SECONDS).until(() -> getSpans().size() == 0); } @Test @@ -49,7 +50,7 @@ void get() { .statusCode(200) .body(equalTo("Hello Naruto")); - await().atMost(5, TimeUnit.SECONDS).until(() -> getSpans().size() == 2); + await().atMost(5, SECONDS).until(() -> getSpans().size() == 2); List> spans = getSpans(); assertEquals(2, spans.size()); assertEquals(spans.get(0).get("traceId"), spans.get(1).get("traceId")); @@ -78,7 +79,7 @@ void reactiveException() { } private static void assertExceptionRecorded() { - await().atMost(5, TimeUnit.SECONDS).until(() -> getExceptionEventData().size() == 1); + await().atMost(5, SECONDS).until(() -> getExceptionEventData().size() == 1); assertThat(getExceptionEventData()).singleElement().satisfies(s -> { assertThat(s).contains("dummy"); }); @@ -94,7 +95,7 @@ void post() { .statusCode(200) .body(equalTo("Hello Naruto")); - await().atMost(5, TimeUnit.SECONDS).until(() -> getSpans().size() == 2); + await().atMost(5, SECONDS).until(() -> getSpans().size() == 2); List> spans = getSpans(); assertEquals(2, spans.size()); assertEquals(spans.get(0).get("traceId"), spans.get(1).get("traceId")); @@ -109,7 +110,7 @@ void multipleUsingChain() { .statusCode(200) .body(equalTo("Hello Naruto and Hello Goku")); - await().atMost(5, TimeUnit.SECONDS).until(() -> getSpans().size() == 7); + await().atMost(5, SECONDS).until(() -> getSpans().size() == 7); List> spans = getSpans(); assertEquals(7, spans.size()); @@ -158,7 +159,7 @@ void multipleUsingCombine() { .statusCode(200) .body(equalTo("Hello Naruto and Hello Goku")); - await().atMost(5, TimeUnit.SECONDS).until(() -> getSpans().size() == 7); + await().atMost(5, SECONDS).until(() -> getSpans().size() == 7); List> spans = getSpans(); assertEquals(7, spans.size()); @@ -197,4 +198,28 @@ void multipleUsingCombine() { Map gokuInternal = getSpanByKindAndParentId(spans, INTERNAL, gokuServer.get("spanId")); assertEquals("helloGet", gokuInternal.get("name")); } + + @Test + public void securedInvalidCredential() { + given().auth().preemptive().basic("scott", "reader2").when().get("/secured/item/something") + .then() + .statusCode(401); + + await().atMost(5, SECONDS).until(() -> getSpans().size() == 1); + assertThat(getSpans()).singleElement().satisfies(m -> { + assertThat(m).extractingByKey("name").isEqualTo("GET /secured/item/{value}"); + }); + } + + @Test + public void securedProperCredentials() { + given().auth().preemptive().basic("scott", "reader").when().get("/secured/item/something") + .then() + .statusCode(200); + + await().atMost(5, SECONDS).until(() -> getSpans().size() == 1); + assertThat(getSpans()).singleElement().satisfies(m -> { + assertThat(m).extractingByKey("name").isEqualTo("GET /secured/item/{value}"); + }); + } }