From 2508e60fe96cd8148ccfc471d7b6d004c72a0985 Mon Sep 17 00:00:00 2001 From: Stephan Strate Date: Tue, 16 Jan 2024 13:52:03 +0100 Subject: [PATCH] Make subject configurable in OidcWiremockTestResource --- .../oidc/server/OidcWiremockTestResource.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test-framework/oidc-server/src/main/java/io/quarkus/test/oidc/server/OidcWiremockTestResource.java b/test-framework/oidc-server/src/main/java/io/quarkus/test/oidc/server/OidcWiremockTestResource.java index 8c1533edc2430..fbdc8faa8d49d 100644 --- a/test-framework/oidc-server/src/main/java/io/quarkus/test/oidc/server/OidcWiremockTestResource.java +++ b/test-framework/oidc-server/src/main/java/io/quarkus/test/oidc/server/OidcWiremockTestResource.java @@ -333,11 +333,15 @@ private void defineCodeFlowAuthorizationMockEncryptedTokenStub() { } public static String getEncryptedIdToken(String userName, Set groups) { + return getEncryptedIdToken(userName, groups, "123456"); + } + + public static String getEncryptedIdToken(String userName, Set groups, String sub) { return Jwt.preferredUserName(userName) .groups(groups) .issuer(TOKEN_ISSUER) .audience(TOKEN_AUDIENCE) - .subject("123456") + .subject(sub) .jws() .keyId("1") .innerSign("privateKey.jwk").encrypt("publicKey.jwk"); @@ -368,26 +372,23 @@ public static String getIdToken(String userName, Set groups) { } public static String generateJwtToken(String userName, Set groups) { + return generateJwtToken(userName, groups, "123456"); + } + + public static String generateJwtToken(String userName, Set groups, String sub) { return Jwt.preferredUserName(userName) .groups(groups) .issuer(TOKEN_ISSUER) .audience(TOKEN_AUDIENCE) .claim("sid", "session-id") - .subject("123456") + .subject(sub) .jws() .keyId("1") .sign("privateKey.jwk"); } public static String getLogoutToken() { - return Jwt.issuer(TOKEN_ISSUER) - .audience(TOKEN_AUDIENCE) - .subject("123456") - .claim("events", createEventsClaim()) - .claim("sid", "session-id") - .jws() - .keyId("1") - .sign("privateKey.jwk"); + return getLogoutToken("123456"); } public static String getLogoutToken(String sub) {