<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 7 January 2016 at 17:27, Juraci Paixão Kröhling <span dir="ltr">&lt;<a href="mailto:juraci@kroehling.de" target="_blank">juraci@kroehling.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;m doing some integration tests for Hawkular and I want to add an user<br>
via this integration test, but I&#39;m having some problems in doing it via<br>
the test itself.<br>
<br>
I&#39;m using the Admin Client from org.keycloak:keycloak-admin-client , and<br>
it look like this:<br>
<br>
Keycloak adminClient = KeycloakBuilder<br>
         .builder()<br>
         .realm(&quot;master&quot;)<br>
         .username(&quot;admin&quot;)<br>
         .password(&quot;admin&quot;)<br>
         .serverUrl(&quot;${baseURI}/auth&quot;)<br>
         .clientId(Constants.ADMIN_CLI_CLIENT_ID)<br>
         .build();<br>
<br>
I then create an UserRepresentation (without credentials), and call:<br>
<br>
adminClient.realm(&quot;hawkular&quot;).users().create(userRepresentation)<br>
<br>
I then try to reset the password (or set it in a List of<br>
CredentialRepresentation to the UserRepresentation above):<br>
<br>
CredentialRepresentation pass = new CredentialRepresentation()<br>
pass.type = &quot;password&quot;<br>
pass.value = password<br>
pass.temporary = false<br>
adminClient.realm(&quot;hawkular&quot;).users().usersResource.get(userId).resetPassword(pass)<br>
<br>
But this password is not set. At this stage, I&#39;m facing two problems:<br>
<br>
1) The first admin request fails, as the admin has a pending action<br>
(reset the password).<br>
<br>
2) The user&#39;s password is never correctly set. By that I mean that I try<br>
to use the password via the UI, and it reports that the password is<br>
invalid. I then login to the admin console, reset the password (setting<br>
the same as I used in the tests). After this, I can correctly login.<br>
<br>
So, my questions:<br>
<br>
- What is the recommended approach for adding users in the context of<br>
integration tests?<br>
<br>
- If Admin Client is the way to go, what&#39;s the correct way to add an<br>
user with a password?<br></blockquote><div><br></div><div>If you want to add users while the server is running then the admin client is the way to go. Looks like there may be an issue with password reset though, so you can create an issue for it.</div><div><br></div><div>In 1.7 the admin password can be set for a server with the add-user script so will no longer have the issue of having to reset admin password first.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Juca.<br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote></div><br></div></div>