<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Nils,<br>
<br>
On 22.4.2014 12:55, Nils Preusker wrote:<br>
</div>
<blockquote
cite="mid:CA+HCLu97wJ+JZ_F9YH+SFeppCrS1ANDX8mt62RtRKeFcWSJt+A@mail.gmail.com"
type="cite">
<div dir="ltr">Hi guys,
<div><br>
</div>
<div>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. </div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>So far, that approach works nicely. However, I'm not quite
sure yet how to go about </div>
<div><br>
</div>
<div>* importing a realm and </div>
<div>* creating a bearer/ access token to use in the test cases</div>
<div><br>
</div>
<div>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 <a moz-do-not-send="true"
href="http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access">http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access</a>).</div>
</div>
</blockquote>
Looks like it's not. The WAR is here just for Alpha1
<a class="moz-txt-link-freetext" href="https://repository.jboss.org/nexus/content/groups/public/org/keycloak/keycloak-server/1.0-alpha-1-12062013/">https://repository.jboss.org/nexus/content/groups/public/org/keycloak/keycloak-server/1.0-alpha-1-12062013/</a>
but not for later releases, which looks like a bug IMO. Can you
create JIRA for it? I think it won't be bad if release will include
all the artifacts including docs and distribution stuff (like WAR
and full Wildfly appliance)<br>
<blockquote
cite="mid:CA+HCLu97wJ+JZ_F9YH+SFeppCrS1ANDX8mt62RtRKeFcWSJt+A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>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).</div>
<div><br>
</div>
<div>Which option do you recommend or is there a third one that
I'm missing?</div>
</div>
</blockquote>
Maybe it will be interesting for you that we have integration
testsuite
<a class="moz-txt-link-freetext" href="https://github.com/keycloak/keycloak/tree/master/testsuite/integration">https://github.com/keycloak/keycloak/tree/master/testsuite/integration</a>
. This testsuite is using embedded Undertow server and it
programmatically deploys Keycloak server on it. You can take a look
at KeycloakServer class and also at individual tests to see how it
works. The point is that it's embedded, so test classes have access
to KeycloakSessionFactory inside KeycloakSetup actions and so they
can directly use the model API to setup needed things. <br>
<br>
For example in LoginTest, you can see that there is some setup
action, which creates new user with usage of Keycloak model API:
<a class="moz-txt-link-freetext" href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L54">https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L54</a>
and then there is selenium test, which verifies that this user is
able to login:
<a class="moz-txt-link-freetext" href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L114">https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L114</a><br>
<br>
Maybe you can reuse some parts of our testsuite and programmaticaly
deploy Keycloak server in similar way like it's done here (not sure
if it's possible with Arquillian+Shrinkwrap+Wildfly, but I assume
that yes). If you still don't have access to Keycloak model API, you
can maybe write some selenium utils, which will do needed setup in
KC admin console UI...<br>
<br>
Another alternative might be that you will use 2 servers in your
testsuite. Your wildfly server with adapter installed will be on
localhost:8080 (you have it already running) and KC server will be
on localhost:8081 (You can directly reuse our testsuite for setup
this).<br>
<br>
Good luck and let me know if still having issues. Btw. we don't have
any integration tests for admin console and real AS7 and Wildfly
adapters AFAIK. So it would be nice if you can share your work once
you have your testsuite up and running<span class="moz-smiley-s1"><span>
:-) </span></span><br>
<br>
Marek<br>
<blockquote
cite="mid:CA+HCLu97wJ+JZ_F9YH+SFeppCrS1ANDX8mt62RtRKeFcWSJt+A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Cheers,</div>
<div>Nils</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
keycloak-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/keycloak-user">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
</blockquote>
<br>
</body>
</html>