public void testGetQuotasForCurrentTenant() { if (apiOption.isPresent()) { Quota quota = apiOption.get().getByTenant(tenant); assertQuotasIsValid(quota); } }
public void testGetDefaultQuotasForCurrentTenant() { if (apiOption.isPresent()) { Quota quota = apiOption.get().getDefaultsForTenant(tenant); assertQuotasIsValid(quota); } }
public void testUpdateQuotasOfCurrentTenantThenReset() { if (apiOption.isPresent()) { QuotaApi api = apiOption.get(); Quota before = api.getByTenant(tenant); assertQuotasIsValid(before); Quota modified = before.toBuilder() .cores(before.getCores() - 1) .instances(before.getInstances() - 1) .metadataItems(before.getMetadatas() - 1) .ram(before.getRam() - 1) .volumes(before.getVolumes() - 1) .build(); assertTrue(api.updateQuotaOfTenant(modified, tenant)); assertEquals(api.getByTenant(tenant), modified); assertTrue(api.updateQuotaOfTenant(before, tenant)); assertEquals(api.getByTenant(tenant), before); } }
@Test(expectedExceptions = ResourceNotFoundException.class) public void testUpdateQuotasFailsNotFound() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().endpoint(endpoint).method("PUT") .addHeader("X-Auth-Token", authToken) .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON)) .build(), HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); api.updateQuotaOfTenant(getTestQuotas(), "demo"); }
public void testUpdateQuotasOfCurrentTenantThenReset() { if (apiOption.isPresent()) { QuotaApi api = apiOption.get(); Quota before = api.getByTenant(tenant); assertQuotasIsValid(before); Quota modified = before.toBuilder() .cores(before.getCores() - 1) .instances(before.getInstances() - 1) .metadataItems(before.getMetadatas() - 1) .ram(before.getRam() - 1) .volumes(before.getVolumes() - 1) .build(); assertTrue(api.updateQuotaOfTenant(modified, tenant)); assertEquals(api.getByTenant(tenant), modified); assertTrue(api.updateQuotaOfTenant(before, tenant)); assertEquals(api.getByTenant(tenant), before); } }
public void testUpdateQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().endpoint(endpoint).method("PUT") .addHeader("X-Auth-Token", authToken) .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON)) .build(), HttpResponse.builder().statusCode(200).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo")); }
public void testGetDefaultQuotasForCurrentTenant() { if (apiOption.isPresent()) { Quota quota = apiOption.get().getDefaultsForTenant(tenant); assertQuotasIsValid(quota); } }
public void testGetQuotasForCurrentTenant() { if (apiOption.isPresent()) { Quota quota = apiOption.get().getByTenant(tenant); assertQuotasIsValid(quota); } }
public void testUpdateQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().endpoint(endpoint).method("PUT") .addHeader("X-Auth-Token", authToken) .addHeader("Accept", "application/json") .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON)) .build(), HttpResponse.builder().statusCode(200).build()).getQuotaApi("az-1.region-a.geo-1").get(); assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo")); }
public void testGetDefaultQuotasFailsTenantNotFound() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); assertNull(api.getDefaultsForTenant("demo")); }
public void testGetQuotasFailsTenantNotFound() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); assertNull(api.getByTenant("demo")); }
public void testGetDefaultQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo/defaults"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaApi("az-1.region-a.geo-1").get(); assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas()); }
public void testGetQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.getByTenant("demo"), getTestQuotas()); }
public void testGetDefaultQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas()); }
public void testGetQuotas() throws Exception { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaApi("az-1.region-a.geo-1").get(); assertEquals(api.getByTenant("demo"), getTestQuotas()); }