<div dir="ltr">I created another JIRA issue for <span style="font-family:arial,sans-serif;font-size:13px">keycloak-wildfly-adapter-</span><span style="font-family:arial,sans-serif;font-size:13px">dist:</span> <a href="https://issues.jboss.org/browse/KEYCLOAK-425">https://issues.jboss.org/browse/KEYCLOAK-425</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 12:43 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"><div dir="ltr">Another question regarding keycloak artifacts in maven, shouldn&#39;t &quot;keycloak-wildfly-adapter-dist&quot; also be available? At least this would make it much easier to create a maven configuration that bootstraps a Wildfly instance with the keycloak adapter. <div>

<br></div><div>I&#39;ve looked at the integration test suite and find the approach quite nice. However, in order to re-use it I would currently have to duplicate most of the code (KeycloakServer, AbstractKeycloakRule etc.) since it is in the test directory of the keycloak-testsuite-integration module. </div>

<div><br></div><div>So I thought I&#39;d do the following:</div><div><br></div><div>* create an integration-test module</div><div>* bootstrap Wildfly with the wildfly adapter installed with the maven-dependency-plugin and maven-resources-plugin (currently struggling with the missing artifacts in the repo here so I installed it locally for now...)</div>

<div>* deploy the auth-server.war/ keycloak-server.war and the archives I want to test in an arquillian test case (@Deploy...)</div><div><br></div><div>That&#39;s where I&#39;m at right now. I guess the next step would be to get the KeycloakSessionFactory in order to add a test realm programmatically. </div>

<div><br></div><div>However, I just realized that it might be better (and easier) to just bootstrap an embedded Keycloak instance (no server, just the core services) and use it to create a test realm and create tokens that can be used in the test cases. After all, I just need a way to generate bearer tokens to make HTTP requests to the wars I would like to test. Any thoughts on how I could best accomplish that?</div>

<div><br></div><div>Cheers,</div><div>Nils</div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 23, 2014 at 11:25 AM, 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"><div dir="ltr">Thanks Marek, I&#39;ve created a JIRA issue about the missing war in the maven repo: <a href="https://issues.jboss.org/browse/KEYCLOAK-424" target="_blank">https://issues.jboss.org/browse/KEYCLOAK-424</a><div>

<br></div><div>
I&#39;ll have a look at the integration test suite and let you know what I came up with.</div><div><br></div><div>Cheers,</div><div>Nils</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Apr 23, 2014 at 9:25 AM, Marek Posolda <span dir="ltr">&lt;<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Hi Nils,<div><br>
      <br>
      On 22.4.2014 12:55, Nils Preusker wrote:<br>
    </div></div><div>
    <blockquote type="cite">
      <div dir="ltr">Hi guys,
        <div><br>
        </div>
        <div>I&#39;m just setting up an integration test project for our
          application and I&#39;m wondering what&#39;s the best way to bootstrap
          keycloak within it. </div>
        <div><br>
        </div>
        <div>I&#39;m using arquillian for testing and I&#39;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&#39;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 href="http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access" target="_blank">http://localhost:8080/auth/rest/realms/TestRealm/tokens/grants/access</a>).</div>



      </div>
    </blockquote></div>
    Looks like it&#39;s not. The WAR is here just for Alpha1
    <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>
    but not for later releases, which looks like a bug IMO. Can you
    create JIRA for it? I think it won&#39;t be bad if release will include
    all the artifacts including docs and distribution stuff (like WAR
    and full Wildfly appliance)<div><br>
    <blockquote 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 &quot;createLogin()&quot; 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&#39;m missing?</div>
      </div>
    </blockquote></div>
    Maybe it will be interesting for you that we have integration
    testsuite
    <a href="https://github.com/keycloak/keycloak/tree/master/testsuite/integration" target="_blank">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&#39;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 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>
    and then there is selenium test, which verifies that this user is
    able to login:
<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 Keycloak server in similar way like it&#39;s done here (not sure
    if it&#39;s possible with Arquillian+Shrinkwrap+Wildfly, but I assume
    that yes). If you still don&#39;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&#39;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><span>
        :-) </span></span><br>
    <br>
    Marek<br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>Nils</div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>