integration.admin-client: Add exact search for all dedicated user attributes (#13361)
Closes #13360
This commit is contained in:
parent
c98a760beb
commit
7f999a4629
2 changed files with 43 additions and 0 deletions
|
@ -127,6 +127,22 @@ public interface UsersResource {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
List<UserRepresentation> search(@QueryParam("username") String username, @QueryParam("exact") Boolean exact);
|
List<UserRepresentation> search(@QueryParam("username") String username, @QueryParam("exact") Boolean exact);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
List<UserRepresentation> searchByUsername(@QueryParam("username") String username, @QueryParam("exact") Boolean exact);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
List<UserRepresentation> searchByEmail(@QueryParam("email") String email, @QueryParam("exact") Boolean exact);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
List<UserRepresentation> searchByFirstName(@QueryParam("firstName") String email, @QueryParam("exact") Boolean exact);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
List<UserRepresentation> searchByLastName(@QueryParam("lastName") String email, @QueryParam("exact") Boolean exact);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for users whose username or email matches the value provided by {@code search}. The {@code search}
|
* Search for users whose username or email matches the value provided by {@code search}. The {@code search}
|
||||||
* argument also allows finding users by specific attributes as follows:
|
* argument also allows finding users by specific attributes as follows:
|
||||||
|
|
|
@ -678,6 +678,16 @@ public class UserTest extends AbstractAdminTest {
|
||||||
assertEquals(9, users.size());
|
assertEquals(9, users.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchByEmailExactMatch() {
|
||||||
|
createUsers();
|
||||||
|
List<UserRepresentation> users = realm.users().searchByEmail("user1@localhost", true);
|
||||||
|
assertEquals(1, users.size());
|
||||||
|
|
||||||
|
users = realm.users().search("@localhost", true);
|
||||||
|
assertEquals(0, users.size());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchByUsername() {
|
public void searchByUsername() {
|
||||||
createUsers();
|
createUsers();
|
||||||
|
@ -750,10 +760,27 @@ public class UserTest extends AbstractAdminTest {
|
||||||
List<UserRepresentation> users = realm.users().search("username1", true);
|
List<UserRepresentation> users = realm.users().search("username1", true);
|
||||||
assertEquals(1, users.size());
|
assertEquals(1, users.size());
|
||||||
|
|
||||||
|
users = realm.users().searchByUsername("username1", true);
|
||||||
|
assertEquals(1, users.size());
|
||||||
|
|
||||||
users = realm.users().search("user", true);
|
users = realm.users().search("user", true);
|
||||||
assertEquals(0, users.size());
|
assertEquals(0, users.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchByFirstNameExact() {
|
||||||
|
createUsers();
|
||||||
|
List<UserRepresentation> users = realm.users().searchByFirstName("First1", true);
|
||||||
|
assertEquals(1, users.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchByLastNameExact() {
|
||||||
|
createUsers();
|
||||||
|
List<UserRepresentation> users = realm.users().searchByLastName("Last1", true);
|
||||||
|
assertEquals(1, users.size());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchByFirstNameNullForLastName() {
|
public void searchByFirstNameNullForLastName() {
|
||||||
UserRepresentation user = new UserRepresentation();
|
UserRepresentation user = new UserRepresentation();
|
||||||
|
|
Loading…
Reference in a new issue