Search in sources :

Example 1 with UsersApi

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);
    }
}
Also used : UsersApi(com.walmartlabs.concord.client.UsersApi) CreateUserRequest(com.walmartlabs.concord.client.CreateUserRequest) ApiException(com.walmartlabs.concord.ApiException) Test(org.junit.jupiter.api.Test)

Aggregations

ApiException (com.walmartlabs.concord.ApiException)1 CreateUserRequest (com.walmartlabs.concord.client.CreateUserRequest)1 UsersApi (com.walmartlabs.concord.client.UsersApi)1 Test (org.junit.jupiter.api.Test)1