@SuppressWarnings("unchecked") @Override public IterableWithMarker<User> apply(Object input) { PaginationOptions paginationOptions = PaginationOptions.class.cast(input); return IterableWithMarker.class.cast(userApi.list(paginationOptions)); }
public void testListRolesOfUser() { UserApi userApi = api.getUserApi().get(); for (User user : userApi.list().concat()) { Set<? extends Role> roles = userApi.listRolesOfUser(user.getId()); for (Role role : roles) { assertNotNull(role.getId()); } } }
public void testUserRolesOnTenant() { UserApi userApi = api.getUserApi().get(); Set<? extends Tenant> tenants = api.getTenantApi().get().list().concat().toSet(); for (User user : userApi.list().concat()) { for (Tenant tenant : tenants) { Set<? extends Role> roles = userApi.listRolesOfUserOnTenant(user.getId(), tenant.getId()); for (Role role : roles) { assertNotNull(role.getId()); } } } }
@Test(expectedExceptions = HttpResponseException.class) public void testListRolesOfUserFailNotImplemented() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(), HttpResponse.builder().statusCode(501).build()).getUserApi().get(); assertTrue(api.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); }
public boolean apply(UserApi userApi) { return userApi.get(userId) == null; } }, 5 * 1000L).apply(userApi.get()));
public void testGetUserByNameFailNotFound() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users?name=fred").build(), HttpResponse.builder().statusCode(404).build()).getUserApi().get(); assertNull(api.getByName("fred")); }
public void testListRolesOfUser() { UserApi userApi = api.getUserApi().get(); for (User user : userApi.list().concat()) { Set<? extends Role> roles = userApi.listRolesOfUser(user.getId()); for (Role role : roles) { assertNotNull(role.getId()); } } }
public void testUserRolesOnTenant() { UserApi userApi = api.getUserApi().get(); Set<? extends Tenant> tenants = api.getTenantApi().get().list().concat().toSet(); for (User user : userApi.list().concat()) { for (Tenant tenant : tenants) { Set<? extends Role> roles = userApi.listRolesOfUserOnTenant(user.getId(), tenant.getId()); for (Role role : roles) { assertNotNull(role.getId()); } } } }
public void testListRolesOfUserFailNotFound() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(), HttpResponse.builder().statusCode(404).build()).getUserApi().get(); assertTrue(api.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); }
public boolean apply(UserApi userApi) { return userApi.get(testUser.getId()) != null; } }, 180 * 1000L).apply(userApi.get()));
public void testGetUserByName() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users?name=nova").build(), HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) .getUserApi().get(); User user = api.getByName("nova"); assertNotNull(user); assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build()); }
@SuppressWarnings("unchecked") @Override public IterableWithMarker<User> apply(Object input) { PaginationOptions paginationOptions = PaginationOptions.class.cast(input); return IterableWithMarker.class.cast(userApi.list(paginationOptions)); }
@Test(expectedExceptions = HttpResponseException.class) public void testListRolesOfUserFailNotImplemented() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(), HttpResponse.builder().statusCode(501).build()).getUserApi().get(); assertTrue(api.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); }
@Test public void testCreateUser() { testUser = userAdminOption.get().create("jclouds-test-user", "jclouds-test-password", CreateUserOptions.Builder.email("jclouds-test@jclouds.org").enabled(true)); assertTrue(retry(new Predicate<UserApi>() { public boolean apply(UserApi userApi) { return userApi.get(testUser.getId()) != null; } }, 180 * 1000L).apply(userApi.get())); assertEquals(userApi.get().get(testUser.getId()).getName(), "jclouds-test-user"); assertEquals(userApi.get().get(testUser.getId()).getEmail(), "jclouds-test@jclouds.org"); assertEquals(userApi.get().get(testUser.getId()).isEnabled(), true); }
public void testGetUserByName() { UserApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/users?name=nova").build(), HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) .getUserApi().get(); User user = api.getByName("nova"); assertNotNull(user); assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").email("nova@example.com").enabled(true). tenantId("ab1da202f5774cceb5da2aeff1f0aa87").build()); }
@SuppressWarnings("unchecked") @Override public IterableWithMarker<User> apply(Object input) { PaginationOptions paginationOptions = PaginationOptions.class.cast(input); return IterableWithMarker.class.cast(userApi.list(paginationOptions)); }