KEYCLOAK-2980 Fix admin query for resource path

This commit is contained in:
Stian Thorgersen 2017-01-03 08:42:46 +01:00
parent e0bfb13ed9
commit b7c98ed433
5 changed files with 14 additions and 13 deletions

View file

@ -111,7 +111,7 @@ public class JpaAdminEventQuery implements AdminEventQuery {
@Override
public AdminEventQuery resourcePath(String resourcePath) {
Expression<String> rPath = root.get("resourcePath");
predicates.add(cb.like(rPath, "%"+resourcePath+"%"));
predicates.add(cb.like(rPath, resourcePath.replace('*', '%')));
return this;
}

View file

@ -81,11 +81,11 @@ public interface AdminEventQuery {
AdminEventQuery resourceType(ResourceType ... resourceTypes);
/**
* Search by resource path. Supports wildcards <code>*</code> and <code>**</code>. For example:
* Search by resource path. Supports wildcard <code>*</code>. For example:
* <ul>
* <li><b>*&#47;master</b> - matches 'realms/master'</li>
* <li><b>**&#47;00d4b16f</b> - matches 'realms/master/clients/00d4b16f'</li>
* <li><b>realms&#47;master&#47;**</b> - matches anything under 'realms/master'</li>
* <li><b>realms/master&#47;*&#47;00d4b16f</b> - matches 'realms/master/clients/00d4b16f'</li>
* <li><b>realms&#47;master&#47;*</b> - matches anything under 'realms/master'</li>
* </ul>
*
* @param resourcePath

View file

@ -57,9 +57,9 @@ public class AdminEventTest extends AbstractEventTest {
return testRealmResource().getAdminEvents();
}
private void createUser(String username) {
private String createUser(String username) {
UserRepresentation user = createUserRepresentation(username, username + "@foo.com", "foo", "bar", true);
ApiUtil.createUserWithAdminClient(testRealmResource(), user);
return ApiUtil.createUserWithAdminClient(testRealmResource(), user);
}
private void updateRealm() {

View file

@ -152,12 +152,13 @@ public class AdminEventStoreProviderTest extends AbstractEventsTest {
testing().onAdminEvent(create(oldest, "realmId", OperationType.CREATE, "realmId", "clientId2", "userId", "127.0.0.1", "/admin/realms/master", "error"), false);
testing().onAdminEvent(create("realmId", OperationType.CREATE, "realmId", "clientId", "userId2", "127.0.0.1", "/admin/realms/master", "error"), false);
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/realms", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/realms", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/realms/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/realms/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/*", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/realms/*", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/realms/*", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "*/realms/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/admin/*/master", null, null, null, null).size());
Assert.assertEquals(6, testing().getAdminEvents(null, null, null, null, null, null, "/ad*/*/master", null, null, null, null).size());
}
@Test

View file

@ -821,7 +821,7 @@ resource-types=Resource Types
select-operations.placeholder=Select operations...
select-resource-types.placeholder=Select resource types...
resource-path=Resource Path
resource-path.tooltip=Filter by resource path. Supports wildcards '*' to match a single part of the path and '**' matches multiple parts. For example 'realms/*/clients/asbc' matches client with id asbc in any realm, while or 'realms/master/**' matches anything in the master realm.
resource-path.tooltip=Filter by resource path. Supports wildcard '*' (for example 'users/*').
date-(from)=Date (From)
date-(to)=Date (To)
authentication-details=Authentication Details