use of com.walmartlabs.concord.client.UsersApi in project concord by walmartlabs.
the class ValidationIT method testInvalidUsername.
@Test
public void testInvalidUsername() {
String longUsername = "01234567890123456789012345678901234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
UsersApi usersApi = new UsersApi(getApiClient());
try {
usersApi.findByUsername("test@localhost");
fail("Should fail with a validation error");
} catch (ApiException e) {
assertInvalidRequest(e);
}
try {
usersApi.findByUsername("local\\test");
fail("Should fail with a validation error");
} catch (ApiException e) {
assertInvalidRequest(e);
}
try {
usersApi.findByUsername(longUsername);
fail("Should fail with a validation error");
} catch (ApiException e) {
assertInvalidRequest(e);
}
try {
usersApi.findByUsername("test#" + System.currentTimeMillis());
fail("Random valid username, should fail with 404");
} catch (ApiException e) {
assertInvalidRequest(e);
}
try {
usersApi.createOrUpdate(new CreateUserRequest().setUsername(longUsername).setType(CreateUserRequest.TypeEnum.LOCAL));
fail("Should fail with a validation error");
} catch (ApiException e) {
assertInvalidRequest(e);
}
}
Aggregations