@Override protected Function<Object, IterableWithMarker<Tenant>> markerToNextForCallingArg0(final String ignored) { final TenantApi tenantApi = api.getTenantApi().get(); return new Function<Object, IterableWithMarker<Tenant>>() { @SuppressWarnings("unchecked") @Override public IterableWithMarker<Tenant> apply(Object input) { return IterableWithMarker.class.cast(tenantApi.list(marker(input.toString()))); } @Override public String toString() { return "listTenants()"; } }; }
public void testTenants() { TenantApi tenantApi = api.getTenantApi().get(); Set<? extends Tenant> result = tenantApi.list().concat().toSet(); assertNotNull(result); assertFalse(result.isEmpty()); for (Tenant tenant : result) { assertNotNull(tenant.getId()); Tenant aTenant = tenantApi.get(tenant.getId()); assertNotNull(aTenant, "get returned null for tenant: " + tenant); assertEquals(aTenant, tenant); } }
public void testTenants() { TenantApi tenantApi = api.getTenantApi().get(); Set<? extends Tenant> result = tenantApi.list().concat().toSet(); assertNotNull(result); assertFalse(result.isEmpty()); for (Tenant tenant : result) { assertNotNull(tenant.getId()); Tenant aTenant = tenantApi.get(tenant.getId()); assertNotNull(aTenant, "get returned null for tenant: " + tenant); assertEquals(aTenant, tenant); } }
public void testTenantsByName() { TenantApi tenantApi = api.getTenantApi().get(); for (Tenant tenant : tenantApi.list().concat()) { Tenant aTenant = tenantApi.getByName(tenant.getName()); assertNotNull(aTenant, "get returned null for tenant: " + tenant); assertEquals(aTenant, tenant); } } }
@BeforeClass(groups = { "integration", "live" }) @Override public void setup() { super.setup(); tenantAdminOption = api.getTenantAdminApi(); if (!tenantAdminOption.isPresent()) { throw new SkipException( "The tests are skipped since OS-KSADM extension is not exposed through the Keystone API"); } tenantApi = api.getTenantApi(); }
public void testTenantsByName() { TenantApi tenantApi = api.getTenantApi().get(); for (Tenant tenant : tenantApi.list().concat()) { Tenant aTenant = tenantApi.getByName(tenant.getName()); assertNotNull(aTenant, "get returned null for tenant: " + tenant); assertEquals(aTenant, tenant); } } }
@Test(expectedExceptions = AuthorizationException.class) public void testListTenantsFailNotAuthorized() { TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), HttpResponse.builder().statusCode(401).build()).getTenantApi().get(); api.get("013ba41150a14830bec85ffe93353bcc"); }
@Test(enabled = false) public void testListTenantsFailNotFound() { TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(404).build()) .getTenantApi().get(); assertTrue(api.list().isEmpty()); }
public void testGetTenantByNameFailNotFound() { TenantApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants?name=admin").build(), HttpResponse.builder().statusCode(404).build()).getTenantApi().get(); assertNull(api.getByName("admin")); }
public void testListTenantsPage() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Set<? extends Tenant> tenants = api.list(new PaginationOptions()).toSet(); assertNotNull(tenants); assertFalse(tenants.isEmpty()); assertEquals(tenants, expectedTenants); }
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 testListTenantsPage() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Set<? extends Tenant> tenants = api.list(new PaginationOptions()).toSet(); assertNotNull(tenants); assertFalse(tenants.isEmpty()); assertEquals(tenants, expectedTenants); }
public void testListTenants() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) .getTenantApi().get(); assertEquals(api.list().concat().toSet(), expectedTenants); }
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(enabled = false) public void testListTenantsATT() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list_att.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Set<Tenant> expected = ImmutableSet.of(Tenant.builder().name("this-is-a-test").id("14").description("None").build()); assertEquals(api.list().concat().toSet(), expected); }
public void testListTenants() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) .getTenantApi().get(); assertEquals(api.list().concat().toSet(), expectedTenants); }
@Test(enabled = false) public void testListTenantsATT() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_list_att.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Set<Tenant> expected = ImmutableSet.of(Tenant.builder().name("this-is-a-test").id("14").description("None").build()); assertEquals(api.list().concat().toSet(), expected); }
public void testGetTenantByName() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants?name=admin").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Tenant tenant = api.getByName("admin"); assertNotNull(tenant); assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); }
public void testGetTenant() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Tenant tenant = api.get("013ba41150a14830bec85ffe93353bcc"); assertNotNull(tenant); assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); }
public void testGetTenantByName() { TenantApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, authenticatedGET().endpoint(endpoint + "/v2.0/tenants?name=admin").build(), HttpResponse.builder().statusCode(200).payload( payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) .getTenantApi().get(); Tenant tenant = api.getByName("admin"); assertNotNull(tenant); assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").enabled(true). build()); }