mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-01 05:36:58 +00:00
Backend: Users api throws error in Postgres for isBot flag (#6470)
This commit is contained in:
parent
a7fffc778c
commit
cdcc51d05c
@ -2014,7 +2014,7 @@ public interface CollectionDAO {
|
|||||||
mySqlCondition);
|
mySqlCondition);
|
||||||
postgresCondition =
|
postgresCondition =
|
||||||
String.format(
|
String.format(
|
||||||
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ) ", postgresCondition);
|
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ", postgresCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (team == null && isAdmin == null && isBot == null) {
|
if (team == null && isAdmin == null && isBot == null) {
|
||||||
@ -2061,7 +2061,7 @@ public interface CollectionDAO {
|
|||||||
mySqlCondition);
|
mySqlCondition);
|
||||||
postgresCondition =
|
postgresCondition =
|
||||||
String.format(
|
String.format(
|
||||||
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ) ", postgresCondition);
|
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ", postgresCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (team == null && isAdmin == null && isBot == null) {
|
if (team == null && isAdmin == null && isBot == null) {
|
||||||
@ -2115,7 +2115,7 @@ public interface CollectionDAO {
|
|||||||
mySqlCondition);
|
mySqlCondition);
|
||||||
postgresCondition =
|
postgresCondition =
|
||||||
String.format(
|
String.format(
|
||||||
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ) ", postgresCondition);
|
"%s AND ue.json#>'{isBot}' IS NULL OR ((ue.json#>'{isBot}')::boolean) = FALSE ", postgresCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (team == null && isAdmin == null && isBot == null) {
|
if (team == null && isAdmin == null && isBot == null) {
|
||||||
|
@ -35,7 +35,6 @@ import static org.openmetadata.catalog.util.TestUtils.TEST_AUTH_HEADERS;
|
|||||||
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
import static org.openmetadata.catalog.util.TestUtils.TEST_USER_NAME;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.UpdateType.MINOR_UPDATE;
|
import static org.openmetadata.catalog.util.TestUtils.UpdateType.MINOR_UPDATE;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertDeleted;
|
import static org.openmetadata.catalog.util.TestUtils.assertDeleted;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertEntityReferences;
|
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertListNotNull;
|
import static org.openmetadata.catalog.util.TestUtils.assertListNotNull;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertListNull;
|
import static org.openmetadata.catalog.util.TestUtils.assertListNull;
|
||||||
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
import static org.openmetadata.catalog.util.TestUtils.assertResponse;
|
||||||
@ -452,6 +451,46 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
assertTrue(users.getData().stream().anyMatch(isUser2));
|
assertTrue(users.getData().stream().anyMatch(isUser2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void get_listUsersWithBotFilter_200_ok(TestInfo test) throws IOException {
|
||||||
|
ResultList<User> users = listEntities(null, 100_000, null, null, ADMIN_AUTH_HEADERS);
|
||||||
|
int initialUserCount = users.getPaging().getTotal();
|
||||||
|
Map<String, String> botQueryParams = new HashMap<>();
|
||||||
|
botQueryParams.put("isBot", "true");
|
||||||
|
ResultList<User> bots = listEntities(botQueryParams, 100_000, null, null, ADMIN_AUTH_HEADERS);
|
||||||
|
int initialBotCount = bots.getPaging().getTotal();
|
||||||
|
|
||||||
|
// Create 3 bot users
|
||||||
|
CreateUser create = createRequest(test, 0).withIsBot(true);
|
||||||
|
User bot0 = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
|
create = createRequest(test, 1).withIsBot(true);
|
||||||
|
User bot1 = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
|
create = createRequest(test, 2).withIsBot(true);
|
||||||
|
User bot2 = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||||
|
|
||||||
|
Predicate<User> isBot0 = u -> u.getId().equals(bot0.getId());
|
||||||
|
Predicate<User> isBot1 = u -> u.getId().equals(bot1.getId());
|
||||||
|
Predicate<User> isBot2 = u -> u.getId().equals(bot2.getId());
|
||||||
|
|
||||||
|
users = listEntities(null, 100_000, null, null, ADMIN_AUTH_HEADERS);
|
||||||
|
assertEquals(initialUserCount + 3, users.getPaging().getTotal());
|
||||||
|
|
||||||
|
// list bot users
|
||||||
|
bots = listEntities(botQueryParams, 100_000, null, null, ADMIN_AUTH_HEADERS);
|
||||||
|
assertEquals(initialBotCount + 3, bots.getData().size());
|
||||||
|
assertEquals(initialBotCount + 3, bots.getPaging().getTotal());
|
||||||
|
assertTrue(bots.getData().stream().anyMatch(isBot0));
|
||||||
|
assertTrue(bots.getData().stream().anyMatch(isBot1));
|
||||||
|
assertTrue(bots.getData().stream().anyMatch(isBot2));
|
||||||
|
|
||||||
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put("isBot", "false");
|
||||||
|
|
||||||
|
// list users (not bots)
|
||||||
|
users = listEntities(queryParams, 100_000, null, null, ADMIN_AUTH_HEADERS);
|
||||||
|
assertEquals(initialUserCount - initialBotCount, users.getPaging().getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void get_listUsersWithTeamsPagination(TestInfo test) throws IOException {
|
void get_listUsersWithTeamsPagination(TestInfo test) throws IOException {
|
||||||
TeamResourceTest teamResourceTest = new TeamResourceTest();
|
TeamResourceTest teamResourceTest = new TeamResourceTest();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user