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 f6f695e0c490c..7b4ffff14d1f6 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 @@ -4,6 +4,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.matching; +import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; @@ -12,7 +13,6 @@ import java.security.cert.X509Certificate; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -25,10 +25,6 @@ import org.jose4j.keys.X509Util; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.core.WireMockConfiguration; -import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; -import com.github.tomakehurst.wiremock.extension.responsetemplating.TemplateEngine; import com.google.common.collect.ImmutableSet; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; @@ -55,11 +51,7 @@ public class OidcWiremockTestResource implements QuarkusTestResourceLifecycleMan @Override public Map start() { - WireMockConfiguration wireMockConfiguration = wireMockConfig(); - server = new WireMockServer(wireMockConfiguration - .extensions(new ResponseTemplateTransformer(TemplateEngine.defaultTemplateEngine(), false, - wireMockConfiguration.filesRoot(), Collections.emptyList())) - .dynamicPort()); + server = new WireMockServer(wireMockConfig().dynamicPort()); server.start(); server.stubFor( @@ -245,10 +237,9 @@ private void defineUserInfoStubForJwt() { private void defineValidIntrospectionMockTokenStubForUserWithRoles(String user, Set roles) { long exp = now() + 300; - server.stubFor(WireMock.post("/auth/realms/quarkus/protocol/openid-connect/token/introspect") + server.stubFor(post("/auth/realms/quarkus/protocol/openid-connect/token/introspect") .withRequestBody(matching("token=" + user + "&token_type_hint=access_token")) - .willReturn(WireMock - .aResponse() + .willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody( "{\"active\":true,\"scope\":\"" + roles.stream().collect(joining(" ")) + "\",\"username\":\"" @@ -262,10 +253,9 @@ private static final long now() { } private void defineInvalidIntrospectionMockTokenStubForUserWithRoles(String user, Set roles) { - server.stubFor(WireMock.post("/auth/realms/quarkus/protocol/openid-connect/token/introspect") + server.stubFor(post("/auth/realms/quarkus/protocol/openid-connect/token/introspect") .withRequestBody(matching("token=" + user + "&token_type_hint=access_token")) - .willReturn(WireMock - .aResponse() + .willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody( "{\"active\":true,\"scope\":\"" + roles.stream().collect(joining(" ")) + "\",\"username\":\"" @@ -274,14 +264,14 @@ private void defineInvalidIntrospectionMockTokenStubForUserWithRoles(String user } private void defineJwtBearerGrantTokenStub() { - server.stubFor(WireMock.post("/auth/realms/quarkus/jwt-bearer-token") + server.stubFor(post("/auth/realms/quarkus/jwt-bearer-token") .withRequestBody(containing("client_id=quarkus-app")) .withRequestBody(containing("client_secret=secret")) .withRequestBody(containing("grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer")) .withRequestBody(containing("scope=https%3A%2F%2Fgraph.microsoft.com%2Fuser.read+offline_access")) .withRequestBody(containing("requested_token_use=on_behalf_of")) .withRequestBody(containing("assertion")) - .willReturn(WireMock.aResponse() + .willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody("{\n" + " \"access_token\": \"" @@ -290,9 +280,9 @@ private void defineJwtBearerGrantTokenStub() { } private void defineCodeFlowAuthorizationMockTokenStub() { - server.stubFor(WireMock.post("/auth/realms/quarkus/token") + server.stubFor(post("/auth/realms/quarkus/token") .withRequestBody(containing("authorization_code")) - .willReturn(WireMock.aResponse() + .willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody("{\n" + " \"access_token\": \"" @@ -304,9 +294,9 @@ private void defineCodeFlowAuthorizationMockTokenStub() { } private void defineCodeFlowAuthorizationMockEncryptedTokenStub() { - server.stubFor(WireMock.post("/auth/realms/quarkus/encrypted-id-token") + server.stubFor(post("/auth/realms/quarkus/encrypted-id-token") .withRequestBody(containing("authorization_code")) - .willReturn(WireMock.aResponse() + .willReturn(aResponse() .withHeader("Content-Type", "application/json") .withBody("{\n" + " \"access_token\": \""