From 93d70928f85598ffafc495041ca2990aa2c381d6 Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Mon, 25 Apr 2022 13:34:24 +0100 Subject: [PATCH] Update BouncyCastle JSSE mTLS test to check SecurityIdentity --- .../it/bouncycastle/BouncyCastleJsseEndpoint.java | 11 +++++++++-- .../it/bouncycastle/BouncyCastleJsseTestCase.java | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/integration-tests/bouncycastle-jsse/src/main/java/io/quarkus/it/bouncycastle/BouncyCastleJsseEndpoint.java b/integration-tests/bouncycastle-jsse/src/main/java/io/quarkus/it/bouncycastle/BouncyCastleJsseEndpoint.java index 4f20e3cff332c..301407e748ce9 100644 --- a/integration-tests/bouncycastle-jsse/src/main/java/io/quarkus/it/bouncycastle/BouncyCastleJsseEndpoint.java +++ b/integration-tests/bouncycastle-jsse/src/main/java/io/quarkus/it/bouncycastle/BouncyCastleJsseEndpoint.java @@ -4,16 +4,23 @@ import java.util.Arrays; import java.util.stream.Collectors; +import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; +import io.quarkus.security.identity.SecurityIdentity; + @Path("/jsse") public class BouncyCastleJsseEndpoint { + @Inject + SecurityIdentity identity; + @GET @Path("listProviders") public String listProviders() { - return Arrays.asList(Security.getProviders()).stream() - .map(p -> p.getName()).collect(Collectors.joining(",")); + return "Identity: " + identity.getPrincipal().getName() + + ", providers:" + Arrays.asList(Security.getProviders()).stream() + .map(p -> p.getName()).collect(Collectors.joining(",")); } } diff --git a/integration-tests/bouncycastle-jsse/src/test/java/io/quarkus/it/bouncycastle/BouncyCastleJsseTestCase.java b/integration-tests/bouncycastle-jsse/src/test/java/io/quarkus/it/bouncycastle/BouncyCastleJsseTestCase.java index 5e00beb9416f9..13b16316d1b1c 100644 --- a/integration-tests/bouncycastle-jsse/src/test/java/io/quarkus/it/bouncycastle/BouncyCastleJsseTestCase.java +++ b/integration-tests/bouncycastle-jsse/src/test/java/io/quarkus/it/bouncycastle/BouncyCastleJsseTestCase.java @@ -2,6 +2,7 @@ import static org.awaitility.Awaitility.given; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; @@ -52,7 +53,7 @@ protected void doTestListProviders() { .get("/jsse/listProviders") .then() .statusCode(200) - .body(containsString("BC,BCJSSE,SunJSSE")); + .body(startsWith("Identity: CN=client"), containsString("BC,BCJSSE,SunJSSE")); } protected void checkLog(boolean serverOnly) {