From 43b1700b8ad1c28996ca86c30bd21b759d7fb6e7 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 | 7 ++++--- 2 files changed, 13 insertions(+), 5 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 4f20e3cff332c8..301407e748ce96 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 5e00beb9416f91..d3388df9dfb36b 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 @@ -1,7 +1,6 @@ package io.quarkus.it.bouncycastle; import static org.awaitility.Awaitility.given; -import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; @@ -46,13 +45,15 @@ protected void doTestListProviders() { .setKeyStore("client-keystore.jks", "password") .setTrustStore("client-truststore.jks", "password") .build(); - RestAssured.given() + String response = RestAssured.given() .spec(spec) .when() .get("/jsse/listProviders") .then() .statusCode(200) - .body(containsString("BC,BCJSSE,SunJSSE")); + .extract().asString(); + assertTrue(response.startsWith("Identity: CN=client")); + assertTrue(response.contains("BC,BCJSSE,SunJSSE")); } protected void checkLog(boolean serverOnly) {