* Note Keycloak Quarkus and Keycloak WildFly images are initialized differently. * By default, Dev Services for Keycloak will assume it is a Keycloak Quarkus image if the image version does not end with a @@ -36,7 +36,7 @@ public class DevServicesConfig { * string. * Set 'quarkus.keycloak.devservices.keycloak-x-image' to override this check. */ - @ConfigItem(defaultValue = "quay.io/keycloak/keycloak:18.0.1") + @ConfigItem(defaultValue = "quay.io/keycloak/keycloak:18.0.2") public String imageName; /** diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customexceptions/SecurityExceptionMapperWithResourceInfoTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customexceptions/SecurityExceptionMapperWithResourceInfoTest.java new file mode 100644 index 0000000000000..0eb03f18d6ea0 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/customexceptions/SecurityExceptionMapperWithResourceInfoTest.java @@ -0,0 +1,57 @@ +package io.quarkus.resteasy.reactive.server.test.customexceptions; + +import static org.hamcrest.Matchers.is; + +import java.util.function.Supplier; + +import javax.annotation.security.DenyAll; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ResourceInfo; +import javax.ws.rs.core.Response; + +import org.jboss.resteasy.reactive.server.ServerExceptionMapper; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; + +public class SecurityExceptionMapperWithResourceInfoTest { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .setArchiveProducer(new Supplier<>() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(Resource.class); + } + }); + + @Test + void test() { + RestAssured.get("/test/denied") + .then().statusCode(403).body(is(Resource.class.getName())); + } + + @Path("test") + public static class Resource { + @GET + @Path("denied") + @Produces("text/plain") + @DenyAll + public String denied() { + return "denied"; + } + + @ServerExceptionMapper(SecurityException.class) + Response handle(SecurityException t, ResourceInfo resourceInfo) { + return Response.status(403).entity(resourceInfo.getResourceClass().getName()).build(); + } + } + +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/security/EagerSecurityHandler.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/security/EagerSecurityHandler.java index 21078343d3390..17d9126e8a08a 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/security/EagerSecurityHandler.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/security/EagerSecurityHandler.java @@ -91,7 +91,7 @@ public void onItem(Object item) { @Override public void onFailure(Throwable failure) { - requestContext.resume(failure); + requestContext.resume(failure, true); } }); } diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/AbstractResteasyReactiveContext.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/AbstractResteasyReactiveContext.java index a0529d63f83b9..29d5efa755abd 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/AbstractResteasyReactiveContext.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/core/AbstractResteasyReactiveContext.java @@ -51,8 +51,7 @@ public void resume() { } public synchronized void resume(Throwable throwable) { - handleException(throwable); - resume((Executor) null); + resume(throwable, false); } public synchronized void resume(Throwable throwable, boolean keepTarget) { @@ -303,13 +302,7 @@ public H[] getHandlers() { * a response result and switch to the abort chain */ public void handleException(Throwable t) { - if (abortHandlerChainStarted) { - handleUnrecoverableError(unwrapException(t)); - } else { - this.throwable = unwrapException(t); - abortHandlerChainStarted = true; - restart(abortHandlerChain); - } + handleException(t, false); } public void handleException(Throwable t, boolean keepSameTarget) { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java index 76c9d1f1d12d3..70edcdce96b52 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java @@ -51,7 +51,12 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(h -> "Deployment".equals(h.getKind())).allSatisfy(h -> { Deployment deployment = (Deployment) h; - assertThat(deployment.getSpec().getTemplate().getSpec().getServiceAccountName()).isEqualTo(APPLICATION_NAME); + String serviceAccountName = deployment.getSpec().getTemplate().getSpec().getServiceAccountName(); + if (h.getMetadata().getName().equals(APPLICATION_NAME)) { + assertThat(serviceAccountName).isEqualTo(APPLICATION_NAME); + } else { + assertThat(serviceAccountName).isNull(); + } }); assertThat(kubernetesList).filteredOn(h -> "ServiceAccount".equals(h.getKind())).singleElement().satisfies(h -> { diff --git a/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestNestedPerClassLifecycleTestCase.java b/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestNestedPerClassLifecycleTestCase.java index 19fc04c59aeb2..06085de5f96c7 100644 --- a/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestNestedPerClassLifecycleTestCase.java +++ b/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestNestedPerClassLifecycleTestCase.java @@ -4,6 +4,7 @@ import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Tag; @@ -27,7 +28,16 @@ public class QuarkusTestNestedPerClassLifecycleTestCase { private final AtomicInteger counter = new AtomicInteger(0); @BeforeAll - public void increment() { + public void incrementInBeforeAll() { + counter.incrementAndGet(); + } + + /** + * We're doing nothing with this code, but we want to keep it to verify the methods annotated + * with `@AfterAll` work for nested tests. + */ + @AfterAll + public void incrementInAfterAll() { counter.incrementAndGet(); } diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java index b9ef9bfbbd014..62270cec1b3e9 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java @@ -15,8 +15,10 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.AbstractMap; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; +import java.util.Deque; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -121,7 +123,7 @@ public class QuarkusTestExtension extends AbstractJvmQuarkusTestExtension private static Class> actualTestClass; private static Object actualTestInstance; // needed for @Nested - private static List