<div dir="ltr">Hi,<div><br></div><div>any news on <a href="https://issues.jboss.org/browse/KEYCLOAK-425" target="_blank" style="font-size:13px;font-family:arial,sans-serif"><span class="">KEYCLOAK</span>-425</a><font face="arial, sans-serif">?</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Cheers,</font></div><div><font face="arial, sans-serif">Nils</font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Apr 24, 2014 at 5:05 PM, Nils Preusker <span dir="ltr"><<a href="mailto:n.preusker@gmail.com" target="_blank">n.preusker@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi guys,<div><br></div><div>just a quick question about <a href="https://issues.jboss.org/browse/KEYCLOAK-425" target="_blank">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="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 1:12 PM, Nils Preusker <span dir="ltr"><<a href="mailto:n.preusker@gmail.com" target="_blank">n.preusker@gmail.com</a>></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><div><br>
> On Apr 23, 2014, at 12:58, Stian Thorgersen <<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>> wrote:<br>
><br>
> 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 "custom" server.<br>
><br>
> For testing bearer-only services, you'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>
><br>
> ----- Original Message -----<br>
>> From: "Nils Preusker" <<a href="mailto:n.preusker@gmail.com" target="_blank">n.preusker@gmail.com</a>><br>
>> To: <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
>> Sent: Wednesday, 23 April, 2014 11:43:56 AM<br>
>> Subject: Re: [keycloak-user] bootstrapping of keycloak for integration testing<br>
>><br>
>> Another question regarding keycloak artifacts in maven, shouldn't<br>
>> "keycloak-wildfly-adapter-dist" also be available? At least this would make<br>
>> it much easier to create a maven configuration that bootstraps a Wildfly<br>
>> instance with the keycloak adapter.<br>
>><br>
>> I've looked at the integration test suite and find the approach quite nice.<br>
>> However, in order to re-use it I would currently have to duplicate most of<br>
>> the code (KeycloakServer, AbstractKeycloakRule etc.) since it is in the test<br>
>> directory of the keycloak-testsuite-integration module.<br>
>><br>
>> So I thought I'd do the following:<br>
>><br>
>> * create an integration-test module<br>
>> * bootstrap Wildfly with the wildfly adapter installed with the<br>
>> maven-dependency-plugin and maven-resources-plugin (currently struggling<br>
>> with the missing artifacts in the repo here so I installed it locally for<br>
>> now...)<br>
>> * deploy the auth-server.war/ keycloak-server.war and the archives I want to<br>
>> test in an arquillian test case (@Deploy...)<br>
>><br>
>> That's where I'm at right now. I guess the next step would be to get the<br>
>> KeycloakSessionFactory in order to add a test realm programmatically.<br>
>><br>
>> However, I just realized that it might be better (and easier) to just<br>
>> bootstrap an embedded Keycloak instance (no server, just the core services)<br>
>> and use it to create a test realm and create tokens that can be used in the<br>
>> test cases. After all, I just need a way to generate bearer tokens to make<br>
>> HTTP requests to the wars I would like to test. Any thoughts on how I could<br>
>> best accomplish that?<br>
>><br>
>> Cheers,<br>
>> Nils<br>
>><br>
>><br>
>><br>
>><br>
>> On Wed, Apr 23, 2014 at 11:25 AM, Nils Preusker < <a href="mailto:n.preusker@gmail.com" target="_blank">n.preusker@gmail.com</a> ><br>
>> wrote:<br>
>><br>
>><br>
>><br>
>> Thanks Marek, I've created a JIRA issue about the missing war in the maven<br>
>> repo: <a href="https://issues.jboss.org/browse/KEYCLOAK-424" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-424</a><br>
>><br>
>> I'll have a look at the integration test suite and let you know what I came<br>
>> up with.<br>
>><br>
>> Cheers,<br>
>> Nils<br>
>><br>
>><br>
>> On Wed, Apr 23, 2014 at 9:25 AM, Marek Posolda < <a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a> > wrote:<br>
>><br>
>><br>
>><br>
>> Hi Nils,<br>
>><br>
>><br>
>> On 22.4.2014 12:55, Nils Preusker wrote:<br>
>><br>
>><br>
>><br>
>> Hi guys,<br>
>><br>
>> I'm just setting up an integration test project for our application and I'm<br>
>> wondering what's the best way to bootstrap keycloak within it.<br>
>><br>
>> I'm using arquillian for testing and I'm using the maven-dependency-plugin<br>
>> and maven-resources-plugin to put together a wildfly instance with the<br>
>> keycloak-wildfly-adapter.<br>
>><br>
>> So far, that approach works nicely. However, I'm not quite sure yet how to go<br>
>> about<br>
>><br>
>> * importing a realm and<br>
>> * creating a bearer/ access token to use in the test cases<br>
>><br>
>> One approach would be to deploy the auth-server.war (is there a mvn<br>
>> repository to pull it from?), POST the realm to the respective URL of the<br>
>> admin console and do the authentication the same way (POST<br>
>> <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>
>> Looks like it's not. The WAR is here just for Alpha1<br>
>> <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>
>> but not for later releases, which looks like a bug IMO. Can you create JIRA<br>
>> for it? I think it won't be bad if release will include all the artifacts<br>
>> including docs and distribution stuff (like WAR and full Wildfly appliance)<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Alternatively, I suppose I could deploy a small helper war or jar that<br>
>> accesses the core services of keycloak to import the realm and create test<br>
>> access tokens (some convenience method like "createLogin()" in a test<br>
>> utility that is deployed with shrink wrap maybe).<br>
>><br>
>> Which option do you recommend or is there a third one that I'm missing?<br>
>> Maybe it will be interesting for you that we have integration testsuite<br>
>> <a href="https://github.com/keycloak/keycloak/tree/master/testsuite/integration" target="_blank">https://github.com/keycloak/keycloak/tree/master/testsuite/integration</a> .<br>
>> This testsuite is using embedded Undertow server and it programmatically<br>
>> deploys Keycloak server on it. You can take a look at KeycloakServer class<br>
>> and also at individual tests to see how it works. The point is that it's<br>
>> embedded, so test classes have access to KeycloakSessionFactory inside<br>
>> KeycloakSetup actions and so they can directly use the model API to setup<br>
>> needed things.<br>
>><br>
>> For example in LoginTest, you can see that there is some setup action, which<br>
>> creates new user with usage of Keycloak model API:<br>
>> <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>
>> and then there is selenium test, which verifies that this user is able to<br>
>> login:<br>
>> <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>
>><br>
>> Maybe you can reuse some parts of our testsuite and programmaticaly deploy<br>
>> Keycloak server in similar way like it's done here (not sure if it's<br>
>> possible with Arquillian+Shrinkwrap+Wildfly, but I assume that yes). If you<br>
>> still don't have access to Keycloak model API, you can maybe write some<br>
>> 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.<br>
>> Your wildfly server with adapter installed will be on localhost:8080 (you<br>
>> have it already running) and KC server will be on localhost:8081 (You can<br>
>> 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<br>
>> integration tests for admin console and real AS7 and Wildfly adapters AFAIK.<br>
>> So it would be nice if you can share your work once you have your testsuite<br>
>> up and running :-)<br>
>><br>
>> Marek<br>
>><br>
>><br>
>><br>
>><br>
>> Cheers,<br>
>> Nils<br>
>><br>
>><br>
>> _______________________________________________<br>
>> keycloak-user mailing list <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
>><br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> keycloak-user mailing list<br>
>> <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
>> <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>
</div></div></blockquote></div><br></div>