Hi guys,

I'm just setting up an integration test project for our application and I'm wondering what's the best way to bootstrap keycloak within it. 

I'm using arquillian for testing and I'm using the maven-dependency-plugin and maven-resources-plugin to put together a wildfly instance with the keycloak-wildfly-adapter.

So far, that approach works nicely. However, I'm not quite sure yet how to go about 

* importing a realm and 
* creating a bearer/ access token to use in the test cases

One approach would be to deploy the auth-server.war (is there a mvn repository to pull it from?), POST the realm to the respective URL of the admin console and do the authentication the same way (POST http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access).

Alternatively, I suppose I could deploy a small helper war or jar that accesses the core services of keycloak to import the realm and create test access tokens (some convenience method like "createLogin()" in a test utility that is deployed with shrink wrap maybe).

Which option do you recommend or is there a third one that I'm missing?

Cheers,
Nils