<div dir="ltr">Hi guys,<div><br></div><div>just a quick question about <a href="https://issues.jboss.org/browse/KEYCLOAK-425">https://issues.jboss.org/browse/KEYCLOAK-425</a> (keycloak-wildfly-adapter-dist-1.0-alpha-3.zip not in JBoss Maven Repository). Would you agree that this should be fixed/ the adapter should be in the maven repo, or should I just create the keycloak wildfly adapter myself with the maven dependency plugin in the build of my integration test project?</div>
<div><br></div><div>If you are planning to fix it, can you give an estimate when it will be available?</div><div><br></div><div>Cheers,</div><div>Nils</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 1:12 PM, Nils Preusker <span dir="ltr">&lt;<a href="mailto:n.preusker@gmail.com" target="_blank">n.preusker@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Great, thanks for the link Stian!<br>
<br>
--<br>
Blog: <a href="http://www.nilspreusker.de" target="_blank">www.nilspreusker.de</a><br>
<div class="HOEnZb"><div class="h5"><br>
&gt; On Apr 23, 2014, at 12:58, Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; In the future we may move our testsuite to Arquillian, as this makes it possible for us to test the actual distribution of Keycloak (on WildFly) rather than a &quot;custom&quot; server.<br>
&gt;<br>
&gt; For testing bearer-only services, you&#39;re right the simplest solution would be to just create tokens manually. Have a look at <a href="https://github.com/liveoak-io/liveoak/blob/master/modules/keycloak/src/test/java/io/liveoak/keycloak/TokenUtil.java" target="_blank">https://github.com/liveoak-io/liveoak/blob/master/modules/keycloak/src/test/java/io/liveoak/keycloak/TokenUtil.java</a>, which does exactly that.<br>

&gt;<br>
&gt; ----- Original Message -----<br>
&gt;&gt; From: &quot;Nils Preusker&quot; &lt;<a href="mailto:n.preusker@gmail.com">n.preusker@gmail.com</a>&gt;<br>
&gt;&gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt;&gt; Sent: Wednesday, 23 April, 2014 11:43:56 AM<br>
&gt;&gt; Subject: Re: [keycloak-user] bootstrapping of keycloak for integration    testing<br>
&gt;&gt;<br>
&gt;&gt; Another question regarding keycloak artifacts in maven, shouldn&#39;t<br>
&gt;&gt; &quot;keycloak-wildfly-adapter-dist&quot; also be available? At least this would make<br>
&gt;&gt; it much easier to create a maven configuration that bootstraps a Wildfly<br>
&gt;&gt; instance with the keycloak adapter.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve looked at the integration test suite and find the approach quite nice.<br>
&gt;&gt; However, in order to re-use it I would currently have to duplicate most of<br>
&gt;&gt; the code (KeycloakServer, AbstractKeycloakRule etc.) since it is in the test<br>
&gt;&gt; directory of the keycloak-testsuite-integration module.<br>
&gt;&gt;<br>
&gt;&gt; So I thought I&#39;d do the following:<br>
&gt;&gt;<br>
&gt;&gt; * create an integration-test module<br>
&gt;&gt; * bootstrap Wildfly with the wildfly adapter installed with the<br>
&gt;&gt; maven-dependency-plugin and maven-resources-plugin (currently struggling<br>
&gt;&gt; with the missing artifacts in the repo here so I installed it locally for<br>
&gt;&gt; now...)<br>
&gt;&gt; * deploy the auth-server.war/ keycloak-server.war and the archives I want to<br>
&gt;&gt; test in an arquillian test case (@Deploy...)<br>
&gt;&gt;<br>
&gt;&gt; That&#39;s where I&#39;m at right now. I guess the next step would be to get the<br>
&gt;&gt; KeycloakSessionFactory in order to add a test realm programmatically.<br>
&gt;&gt;<br>
&gt;&gt; However, I just realized that it might be better (and easier) to just<br>
&gt;&gt; bootstrap an embedded Keycloak instance (no server, just the core services)<br>
&gt;&gt; and use it to create a test realm and create tokens that can be used in the<br>
&gt;&gt; test cases. After all, I just need a way to generate bearer tokens to make<br>
&gt;&gt; HTTP requests to the wars I would like to test. Any thoughts on how I could<br>
&gt;&gt; best accomplish that?<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Nils<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Apr 23, 2014 at 11:25 AM, Nils Preusker &lt; <a href="mailto:n.preusker@gmail.com">n.preusker@gmail.com</a> &gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Thanks Marek, I&#39;ve created a JIRA issue about the missing war in the maven<br>
&gt;&gt; repo: <a href="https://issues.jboss.org/browse/KEYCLOAK-424" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-424</a><br>
&gt;&gt;<br>
&gt;&gt; I&#39;ll have a look at the integration test suite and let you know what I came<br>
&gt;&gt; up with.<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Nils<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Apr 23, 2014 at 9:25 AM, Marek Posolda &lt; <a href="mailto:mposolda@redhat.com">mposolda@redhat.com</a> &gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi Nils,<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 22.4.2014 12:55, Nils Preusker wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi guys,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m just setting up an integration test project for our application and I&#39;m<br>
&gt;&gt; wondering what&#39;s the best way to bootstrap keycloak within it.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m using arquillian for testing and I&#39;m using the maven-dependency-plugin<br>
&gt;&gt; and maven-resources-plugin to put together a wildfly instance with the<br>
&gt;&gt; keycloak-wildfly-adapter.<br>
&gt;&gt;<br>
&gt;&gt; So far, that approach works nicely. However, I&#39;m not quite sure yet how to go<br>
&gt;&gt; about<br>
&gt;&gt;<br>
&gt;&gt; * importing a realm and<br>
&gt;&gt; * creating a bearer/ access token to use in the test cases<br>
&gt;&gt;<br>
&gt;&gt; One approach would be to deploy the auth-server.war (is there a mvn<br>
&gt;&gt; repository to pull it from?), POST the realm to the respective URL of the<br>
&gt;&gt; admin console and do the authentication the same way (POST<br>
&gt;&gt; <a href="http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access" target="_blank">http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access</a> ).<br>
&gt;&gt; Looks like it&#39;s not. The WAR is here just for Alpha1<br>
&gt;&gt; <a href="https://repository.jboss.org/nexus/content/groups/public/org/keycloak/keycloak-server/1.0-alpha-1-12062013/" target="_blank">https://repository.jboss.org/nexus/content/groups/public/org/keycloak/keycloak-server/1.0-alpha-1-12062013/</a><br>

&gt;&gt; but not for later releases, which looks like a bug IMO. Can you create JIRA<br>
&gt;&gt; for it? I think it won&#39;t be bad if release will include all the artifacts<br>
&gt;&gt; including docs and distribution stuff (like WAR and full Wildfly appliance)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Alternatively, I suppose I could deploy a small helper war or jar that<br>
&gt;&gt; accesses the core services of keycloak to import the realm and create test<br>
&gt;&gt; access tokens (some convenience method like &quot;createLogin()&quot; in a test<br>
&gt;&gt; utility that is deployed with shrink wrap maybe).<br>
&gt;&gt;<br>
&gt;&gt; Which option do you recommend or is there a third one that I&#39;m missing?<br>
&gt;&gt; Maybe it will be interesting for you that we have integration testsuite<br>
&gt;&gt; <a href="https://github.com/keycloak/keycloak/tree/master/testsuite/integration" target="_blank">https://github.com/keycloak/keycloak/tree/master/testsuite/integration</a> .<br>
&gt;&gt; This testsuite is using embedded Undertow server and it programmatically<br>
&gt;&gt; deploys Keycloak server on it. You can take a look at KeycloakServer class<br>
&gt;&gt; and also at individual tests to see how it works. The point is that it&#39;s<br>
&gt;&gt; embedded, so test classes have access to KeycloakSessionFactory inside<br>
&gt;&gt; KeycloakSetup actions and so they can directly use the model API to setup<br>
&gt;&gt; needed things.<br>
&gt;&gt;<br>
&gt;&gt; For example in LoginTest, you can see that there is some setup action, which<br>
&gt;&gt; creates new user with usage of Keycloak model API:<br>
&gt;&gt; <a href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L54" target="_blank">https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L54</a><br>

&gt;&gt; and then there is selenium test, which verifies that this user is able to<br>
&gt;&gt; login:<br>
&gt;&gt; <a href="https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L114" target="_blank">https://github.com/keycloak/keycloak/blob/master/testsuite/integration/src/test/java/org/keycloak/testsuite/forms/LoginTest.java#L114</a><br>

&gt;&gt;<br>
&gt;&gt; Maybe you can reuse some parts of our testsuite and programmaticaly deploy<br>
&gt;&gt; Keycloak server in similar way like it&#39;s done here (not sure if it&#39;s<br>
&gt;&gt; possible with Arquillian+Shrinkwrap+Wildfly, but I assume that yes). If you<br>
&gt;&gt; still don&#39;t have access to Keycloak model API, you can maybe write some<br>
&gt;&gt; selenium utils, which will do needed setup in KC admin console UI...<br>
&gt;&gt;<br>
&gt;&gt; Another alternative might be that you will use 2 servers in your testsuite.<br>
&gt;&gt; Your wildfly server with adapter installed will be on localhost:8080 (you<br>
&gt;&gt; have it already running) and KC server will be on localhost:8081 (You can<br>
&gt;&gt; directly reuse our testsuite for setup this).<br>
&gt;&gt;<br>
&gt;&gt; Good luck and let me know if still having issues. Btw. we don&#39;t have any<br>
&gt;&gt; integration tests for admin console and real AS7 and Wildfly adapters AFAIK.<br>
&gt;&gt; So it would be nice if you can share your work once you have your testsuite<br>
&gt;&gt; up and running :-)<br>
&gt;&gt;<br>
&gt;&gt; Marek<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Nils<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; keycloak-user mailing list <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; keycloak-user mailing list<br>
&gt;&gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</div></div></blockquote></div><br></div>