You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The preferred approach for integration testing against Keycloak is xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak].
582
+
`Dev Services for Keycloak` will start and initialize a test container.
583
+
Then, it will create a `quarkus` realm and a `quarkus-app` client (`secret` secret) and add `alice` (`admin` and `user` roles) and `bob` (`user` role) users, where all of these properties can be customized.
584
+
585
+
First, add the following dependency, which provides a utility class `io.quarkus.test.keycloak.client.KeycloakTestClient` that you can use in tests for acquiring the access tokens:
Next, prepare your `application.properties` configuration file.
604
+
You can start with an empty `application.properties` file because `Dev Services for Keycloak` registers `quarkus.oidc.auth-server-url` and points it to the running test container, `quarkus.oidc.client-id=quarkus-app`, and `quarkus.oidc.credentials.secret=secret`.
605
+
606
+
However, if you have already configured the required `quarkus-oidc` properties, then you only need to associate `quarkus.oidc.auth-server-url` with the `prod` profile for `Dev Services for Keycloak`to start a container, as shown in the following example:
public class NativeBearerTokenAuthenticationIT extends BearerTokenAuthenticationTest {
667
+
}
668
+
----
669
+
670
+
For more information about initializing and configuring Dev Services for Keycloak, see the xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak] guide.
671
+
672
+
578
673
[[bearer-token-integration-testing-wiremock]]
579
674
==== WireMock
580
675
@@ -697,7 +792,7 @@ public class CustomOidcWireMockStubTest {
697
792
----
698
793
699
794
[[integration-testing-oidc-test-client]]
700
-
=== `OidcTestClient`
795
+
==== `OidcTestClient`
701
796
702
797
If you use SaaS OIDC providers, such as `Auth0`, and want to run tests against the test (development) domain or to run tests against a remote Keycloak test realm, if you already have `quarkus.oidc.auth-server-url` configured, you can use `OidcTestClient`.
703
798
@@ -762,100 +857,6 @@ For a test like this to work, the test `Auth0` application must have the `passwo
762
857
This example code also shows how to pass additional parameters.
763
858
For `Auth0`, these are the `audience` and `scope` parameters.
The preferred approach for integration testing against Keycloak is xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak].
769
-
`Dev Services for Keycloak` will start and initialize a test container.
770
-
Then, it will create a `quarkus` realm and a `quarkus-app` client (`secret` secret) and add `alice` (`admin` and `user` roles) and `bob` (`user` role) users, where all of these properties can be customized.
771
-
772
-
First, add the following dependency, which provides a utility class `io.quarkus.test.keycloak.client.KeycloakTestClient` that you can use in tests for acquiring the access tokens:
Next, prepare your `application.properties` configuration file.
791
-
You can start with an empty `application.properties` file because `Dev Services for Keycloak` registers `quarkus.oidc.auth-server-url` and points it to the running test container, `quarkus.oidc.client-id=quarkus-app`, and `quarkus.oidc.credentials.secret=secret`.
792
-
793
-
However, if you have already configured the required `quarkus-oidc` properties, then you only need to associate `quarkus.oidc.auth-server-url` with the `prod` profile for `Dev Services for Keycloak`to start a container, as shown in the following example:
public class NativeBearerTokenAuthenticationIT extends BearerTokenAuthenticationTest {
854
-
}
855
-
----
856
-
857
-
For more information about initializing and configuring Dev Services for Keycloak, see the xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak] guide.
For integration testing against Keycloak, use xref:security-openid-connect-dev-services.adoc[Dev services for Keycloak].
1817
+
This service initializes a test container, creates a `quarkus` realm, and configures a `quarkus-app` client with the secret `secret`.
1818
+
It also sets up two users: `alice` with `admin` and `user` roles, and `bob` with the `user` role.
1819
+
All these properties are customizable. For details, see xref:security-openid-connect-dev-services.adoc#keycloak-initialization[Keycloak Initialization].
1820
+
1821
+
First, prepare the `application.properties` file.
1822
+
1823
+
If starting from an empty `application.properties` file, `Dev Services for Keycloak` automatically registers the following properties:
1824
+
1825
+
- `quarkus.oidc.auth-server-url`, which points to the running test container.
1826
+
- `quarkus.oidc.client-id=quarkus-app`.
1827
+
- `quarkus.oidc.credentials.secret=secret`.
1828
+
1829
+
If you already have the required `quarkus-oidc` properties configured, associate `quarkus.oidc.auth-server-url` with the `prod` profile.
1830
+
This ensures that `Dev Services for Keycloak` starts the container as expected.
Using xref:security-openid-connect-dev-services.adoc[Dev Services for Keycloak] is recommended for integration testing against Keycloak.
1904
-
`Dev Services for Keycloak` will start and initialize a test container: it will create a `quarkus` realm, a `quarkus-app` client (`secret` secret), and add `alice` (`admin` and `user` roles) and `bob` (`user` role) users, where all of these properties can be customized.
1905
-
1906
-
First, prepare `application.properties`.
1907
-
You can start with a completely empty `application.properties` file as `Dev Services for Keycloak` will register `quarkus.oidc.auth-server-url` pointing to the running test container as well as `quarkus.oidc.client-id=quarkus-app` and `quarkus.oidc.credentials.secret=secret`.
1908
-
1909
-
However, if you already have all the required `quarkus-oidc` properties configured, then you only need to associate `quarkus.oidc.auth-server-url` with the `prod` profile for `Dev Services for Keycloak` to start a container.
0 commit comments