<div dir="ltr">Just added a testcase for this and it works fine. Did you set enabled to true in UserRepresentation?</div><div class="gmail_extra"><br><div class="gmail_quote">On 8 January 2016 at 14:08, Stian Thorgersen <span dir="ltr"><<a href="mailto:sthorger@redhat.com" target="_blank">sthorger@redhat.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"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 7 January 2016 at 17:27, Juraci Paixão Kröhling <span dir="ltr"><<a href="mailto:juraci@kroehling.de" target="_blank">juraci@kroehling.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm doing some integration tests for Hawkular and I want to add an user<br>
via this integration test, but I'm having some problems in doing it via<br>
the test itself.<br>
<br>
I'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("master")<br>
.username("admin")<br>
.password("admin")<br>
.serverUrl("${baseURI}/auth")<br>
.clientId(Constants.ADMIN_CLI_CLIENT_ID)<br>
.build();<br>
<br>
I then create an UserRepresentation (without credentials), and call:<br>
<br>
adminClient.realm("hawkular").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 = "password"<br>
pass.value = password<br>
pass.temporary = false<br>
adminClient.realm("hawkular").users().usersResource.get(userId).resetPassword(pass)<br>
<br>
But this password is not set. At this stage, I'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'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's the correct way to add an<br>
user with a password?<br></blockquote><div><br></div></div></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><span class=""><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" target="_blank">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></span></div><br></div></div>
</blockquote></div><br></div>