Merge pull request #3474 from vramik/KEYCLOAK-3489

KEYCLOAK-3489 migration tests - minor fix
This commit is contained in:
Pavel Drozd 2016-11-08 15:38:14 +01:00 committed by GitHub
commit c05057748f
5 changed files with 55 additions and 39 deletions

View file

@ -83,7 +83,7 @@ public class ApiUtil {
public static ClientResource findClientResourceByName(RealmResource realm, String name) {
for (ClientRepresentation c : realm.clients().findAll()) {
if (c.getName().equals(name)) {
if (name.equals(c.getName())) {
return realm.clients().get(c.getId());
}
}
@ -92,7 +92,7 @@ public class ApiUtil {
public static ClientResource findClientByClientId(RealmResource realm, String clientId) {
for (ClientRepresentation c : realm.clients().findAll()) {
if (c.getClientId().equals(clientId)) {
if (clientId.equals(c.getClientId())) {
return realm.clients().get(c.getId());
}
}

View file

@ -27,6 +27,7 @@ import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.AbstractAuthTest;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.events.EventsListenerProviderFactory;
import org.keycloak.testsuite.util.AdminEventPaths;
@ -70,9 +71,16 @@ public abstract class AbstractClientTest extends AbstractAuthTest {
// returns UserRepresentation retrieved from server, with all fields, including id
protected UserRepresentation getFullUserRep(String userName) {
// the search returns all users who has userName contained in their username.
List<UserRepresentation> results = testRealmResource().users().search(userName, null, null, null, null, null);
if (results.size() != 1) throw new RuntimeException("Did not find single user with username " + userName);
return results.get(0);
UserRepresentation result = null;
for (UserRepresentation user : results) {
if (userName.equals(user.getUsername())) {
result = user;
}
}
Assert.assertNotNull("Did not find user with username " + userName, result);
return result;
}
protected String createOidcClient(String name) {

View file

@ -829,6 +829,7 @@
}, {
"id" : "d89c5b0f-bee6-4a97-86b1-118efa21e508",
"clientId" : "master-test-client",
"name" : "master-test-client",
"surrogateAuthRequired" : false,
"enabled" : true,
"clientAuthenticatorType" : "client-secret",
@ -1898,6 +1899,7 @@
}, {
"id" : "d8262b3f-02e4-409e-97fc-ee5532e0801e",
"clientId" : "migration-test-client",
"name" : "migration-test-client",
"surrogateAuthRequired" : false,
"enabled" : true,
"clientAuthenticatorType" : "client-secret",

View file

@ -933,6 +933,7 @@
}, {
"id" : "6268e266-346b-46ba-8408-fe17b5792b10",
"clientId" : "master-test-client",
"name" : "master-test-client",
"surrogateAuthRequired" : false,
"enabled" : true,
"clientAuthenticatorType" : "client-secret",
@ -2085,6 +2086,7 @@
}, {
"id" : "f66de6ed-4fd8-47b6-a2db-85ab8ed88874",
"clientId" : "migration-test-client",
"name" : "migration-test-client",
"surrogateAuthRequired" : false,
"enabled" : true,
"clientAuthenticatorType" : "client-secret",

View file

@ -458,6 +458,9 @@
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
@ -494,6 +497,7 @@
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>