[keycloak-dev] Ability to run tests from within Keycloak server added
Stian Thorgersen
sthorger at redhat.com
Fri Jan 27 07:50:55 EST 2017
I've added the option to run pieces of a test from within the Keycloak
server. This is useful when you need some details that is only internally
available or if you need to execute something on the server.
It's pretty simply all you need is to add an Arquillian deployment. This is
required to add classes for the code you want to run.
An example is added to:
https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/runonserver/RunOnServerTest.java
You can run stuff on the server, fetch stuff from the server and even do
assertions on the server which is sent back to the client side.
Finally there's some helpers in:
https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/runonserver/RunHelpers.java
These makes it easy to fetch internal realm and component settings. We can
add more here as needed. Take a look at RealmTest for an example on how to
use these.
Finally it's pretty nice to use remote WildFly container when writing tests
like these. To do that:
* Build including dist (mvn clean install -Pdistribution)
* Run
"testsuite/integration-arquillian/servers/auth-server/jboss/wildfly/target/unpacked/keycloak-3.0.0.CR1-SNAPSHOT/bin/standalone.sh
-Djboss.socket.binding.port-offset=100"
* In IntelliJ select view -> Tool Windows -> Maven
* In the open window expand profiles and select auth-server-remote
Now you can run the test and it will use the remote container rather than
embedded Undertow.
More information about the keycloak-dev
mailing list