mirror of https://github.com/apache/jclouds.git
JCLOUDS-691: Remove 404 fallbacks of PUT and POST calls from OpenStack APIs
This commit is contained in:
parent
0cf13c61ef
commit
d83282ca53
|
@ -16,6 +16,11 @@
|
|||
*/
|
||||
package org.jclouds.openstack.cinder.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.cinder.v1.domain.AvailabilityZone;
|
||||
|
@ -23,13 +28,6 @@ import org.jclouds.openstack.cinder.v1.extensions.AvailabilityZoneApi;
|
|||
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
@Test(groups = "unit", testName = "AvailabilityZoneApiExpectTest")
|
||||
public class AvailabilityZoneApiExpectTest extends BaseCinderApiExpectTest {
|
||||
|
||||
|
@ -49,19 +47,6 @@ public class AvailabilityZoneApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(availabilityZoneActual, availabilityZoneExpected);
|
||||
}
|
||||
|
||||
public void testListAvailabilityZonesFail() throws Exception {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/os-availability-zone");
|
||||
AvailabilityZoneApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getAvailabilityZoneApi("RegionOne");
|
||||
|
||||
Set<? extends AvailabilityZone> availabilityZones = api.list().toSet();
|
||||
assertTrue(availabilityZones.isEmpty());
|
||||
}
|
||||
|
||||
protected AvailabilityZone getTestAvailabilityZone() {
|
||||
return AvailabilityZone.builder()
|
||||
.name("nova")
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.cinder.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -35,8 +33,6 @@ import org.jclouds.openstack.cinder.v1.domain.SnapshotExtendedAttributes;
|
|||
import org.jclouds.openstack.cinder.v1.domain.Volume;
|
||||
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
|
||||
import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -63,19 +59,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
||||
}
|
||||
|
||||
public void testListSnapshotsFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
Set<? extends Snapshot> snapshots = api.list().toSet();
|
||||
assertTrue(snapshots.isEmpty());
|
||||
}
|
||||
|
||||
public void testListSnapshotsInDetail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/detail");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
|
@ -98,19 +81,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(snappy.getSize(), 1);
|
||||
}
|
||||
|
||||
public void testListSnapshotsInDetailFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/detail");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
Set<? extends Snapshot> snapshots = api.listInDetail().toSet();
|
||||
assertTrue(snapshots.isEmpty());
|
||||
}
|
||||
|
||||
public void testGetSnapshot() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
|
@ -124,18 +94,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(snapshot, testSnapshotDetailed());
|
||||
}
|
||||
|
||||
public void testGetSnapshotFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
assertNull(api.get("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||
}
|
||||
|
||||
public void testCreateSnapshot() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
|
@ -157,27 +115,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(snapshot, testSnapshotCreate());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testCreateSnapshotVolumeNotFoundFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||
.name("jclouds-test-snapshot")
|
||||
.description("jclouds test snapshot")
|
||||
.force();
|
||||
|
||||
api.create("ea6f70ef-2784-40b9-9d14-d7f33c507c3f", options);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testCreateSnapshotVolumeIllegalStateFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots");
|
||||
|
@ -204,27 +141,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
api.create("ea6f70ef-2784-40b9-9d14-d7f33c507c3f", options);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testCreateSnapshotFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/snapshot_create.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(401).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
|
||||
.name("jclouds-test-snapshot")
|
||||
.description("jclouds test snapshot")
|
||||
.force();
|
||||
|
||||
api.create("ea6f70ef-2784-40b9-9d14-d7f33c507c3f", options);
|
||||
}
|
||||
|
||||
public void testDeleteSnapshot() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
|
@ -237,31 +153,6 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertTrue(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testDeleteSnapshotFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(401).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
}
|
||||
|
||||
public void testDeleteSnapshotNotFoundFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
SnapshotApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getSnapshotApi("RegionOne");
|
||||
|
||||
assertFalse(api.delete("67d03df1-ce5d-4ba7-adbe-492ceb80170b"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testDeleteSnapshotIllegalStateFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/snapshots/67d03df1-ce5d-4ba7-adbe-492ceb80170b");
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.cinder.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -33,7 +31,6 @@ import org.jclouds.openstack.cinder.v1.domain.Volume;
|
|||
import org.jclouds.openstack.cinder.v1.domain.VolumeAttachment;
|
||||
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
|
||||
import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -59,19 +56,6 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
||||
}
|
||||
|
||||
public void testListVolumesFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("RegionOne");
|
||||
|
||||
Set<? extends Volume> volumes = api.list().toSet();
|
||||
assertTrue(volumes.isEmpty());
|
||||
}
|
||||
|
||||
public void testListVolumesInDetail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -85,19 +69,6 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(volumes, ImmutableSet.of(testVolumeDetailed()));
|
||||
}
|
||||
|
||||
public void testListVolumesInDetailFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("RegionOne");
|
||||
|
||||
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
||||
assertTrue(volumes.isEmpty());
|
||||
}
|
||||
|
||||
public void testCreateVolume() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -117,26 +88,6 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(volume, testVolumeCreate());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testCreateVolumeFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/volume_create.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/volume_create_response.json")).build()
|
||||
).getVolumeApi("RegionOne");
|
||||
|
||||
CreateVolumeOptions options = CreateVolumeOptions.Builder
|
||||
.name("jclouds-test-volume")
|
||||
.description("description of test volume");
|
||||
api.create(1, options);
|
||||
}
|
||||
|
||||
public void testGetVolume() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/60761c60-0f56-4499-b522-ff13e120af10");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -156,18 +107,6 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(Iterables.getOnlyElement(volume.getAttachments()), testAttachment());
|
||||
}
|
||||
|
||||
public void testGetVolumeFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/60761c60-0f56-4499-b522-ff13e120af10");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("RegionOne");
|
||||
|
||||
assertNull(api.get("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||
}
|
||||
|
||||
public void testDeleteVolume() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/60761c60-0f56-4499-b522-ff13e120af10");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -180,18 +119,6 @@ public class VolumeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertTrue(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||
}
|
||||
|
||||
public void testDeleteVolumeFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/volumes/60761c60-0f56-4499-b522-ff13e120af10");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("RegionOne");
|
||||
|
||||
assertFalse(api.delete("60761c60-0f56-4499-b522-ff13e120af10"));
|
||||
}
|
||||
|
||||
protected Volume testVolumeCreate() {
|
||||
return Volume.builder()
|
||||
.id("60761c60-0f56-4499-b522-ff13e120af10")
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jclouds.openstack.cinder.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
@ -65,18 +64,6 @@ public class VolumeTypeApiExpectTest extends BaseCinderApiExpectTest {
|
|||
assertEquals(type, testVolumeType());
|
||||
}
|
||||
|
||||
public void testGetVolumeTypeFailNotFound() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/50cdb4c60374463198695d9f798fa34d/types/X");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("RegionOne");
|
||||
|
||||
assertNull(api.get("X"));
|
||||
}
|
||||
|
||||
public VolumeType testVolumeType() {
|
||||
return VolumeType.builder()
|
||||
.id("1")
|
||||
|
|
|
@ -75,7 +75,6 @@ public interface RoleAdminApi {
|
|||
@SelectJson("role")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@WrapWith("role")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Role create(@PayloadParam("name") String name);
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@ public interface ServiceAdminApi {
|
|||
@POST
|
||||
@SelectJson("OS-KSADM:service")
|
||||
@WrapWith("OS-KSADM:service")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Service create(@PayloadParam("name") String name, @PayloadParam("type") String type,
|
||||
@PayloadParam("description") String description);
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||
|
@ -62,7 +61,6 @@ public interface TenantAdminApi {
|
|||
@POST
|
||||
@SelectJson("tenant")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Tenant create(@PayloadParam("name") String name);
|
||||
|
||||
|
@ -75,7 +73,6 @@ public interface TenantAdminApi {
|
|||
@POST
|
||||
@SelectJson("tenant")
|
||||
@MapBinder(CreateTenantOptions.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Tenant create(@PayloadParam("name") String name, CreateTenantOptions options);
|
||||
|
||||
|
@ -100,20 +97,16 @@ public interface TenantAdminApi {
|
|||
@Path("/{id}")
|
||||
@SelectJson("tenant")
|
||||
@MapBinder(UpdateTenantOptions.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Tenant update(@PathParam("id") String id, UpdateTenantOptions options);
|
||||
|
||||
/**
|
||||
* Adds role to a user on a tenant
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
@Named("tenant:addRoleOnTenant")
|
||||
@PUT
|
||||
@Path("/{id}/users/{userId}/roles/OS-KSADM/{roleId}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean addRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userId,
|
||||
void addRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userId,
|
||||
@PathParam("roleId") String roleId);
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,6 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||
|
@ -60,7 +59,6 @@ public interface UserAdminApi {
|
|||
@Named("user:create")
|
||||
@POST
|
||||
@SelectJson("user")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
User create(@PayloadParam("name") String name, @PayloadParam("password") String password);
|
||||
|
||||
|
@ -73,7 +71,6 @@ public interface UserAdminApi {
|
|||
@POST
|
||||
@SelectJson("user")
|
||||
@MapBinder(CreateUserOptions.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
User create(@PayloadParam("name") String name,
|
||||
@PayloadParam("password") String password, CreateUserOptions options);
|
||||
|
@ -99,7 +96,6 @@ public interface UserAdminApi {
|
|||
@Path("/{id}")
|
||||
@SelectJson("user")
|
||||
@MapBinder(UpdateUserOptions.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
User update(@PathParam("id") String id, UpdateUserOptions options);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.openstack.keystone.v2_0;
|
|||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -42,13 +41,5 @@ public class KeystoneApiExpectTest extends BaseKeystoneRestApiExpectTest<Keyston
|
|||
assertEquals(metadata, new ParseRackspaceApiMetadataTest().expected());
|
||||
}
|
||||
|
||||
public void testGetApiMetaDataFailNotFound() {
|
||||
KeystoneApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
HttpRequest.builder().method("GET").endpoint(endpoint + "/v2.0/").addHeader("Accept", APPLICATION_JSON).build(),
|
||||
HttpResponse.builder().statusCode(404).build());
|
||||
assertNull(api.getApiMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
package org.jclouds.openstack.keystone.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -30,7 +28,6 @@ import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
|
@ -73,32 +70,6 @@ public class RoleAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void listZeroRoles() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
RoleAdminApi roleAdminApi = keystoneApi.getRoleAdminApi().get();
|
||||
FluentIterable<? extends Role> roles = roleAdminApi.list();
|
||||
|
||||
ImmutableList<? extends Role> roleList = roles.toList();
|
||||
|
||||
assertTrue(roleList.isEmpty());
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateRoleRequest = server.takeRequest();
|
||||
assertEquals(updateRoleRequest.getRequestLine(), "GET /OS-KSADM/roles HTTP/1.1");
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void createRole() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -125,31 +96,6 @@ public class RoleAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void createRoleFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404).setBody(
|
||||
stringFromResource("/role_create_response.json"))));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
RoleAdminApi roleAdminApi = keystoneApi.getRoleAdminApi().get();
|
||||
Role testRole = roleAdminApi.create("jclouds-role");
|
||||
|
||||
assertNull(testRole);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest createRoleRequest = server.takeRequest();
|
||||
assertEquals(createRoleRequest.getRequestLine(), "POST /OS-KSADM/roles HTTP/1.1");
|
||||
assertEquals(new String(createRoleRequest.getBody()), "{\"role\":{\"name\":\"jclouds-role\"}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void getRole() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -178,29 +124,6 @@ public class RoleAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void getRoleFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
RoleAdminApi roleAdminApi = keystoneApi.getRoleAdminApi().get();
|
||||
Role role = roleAdminApi.get("r1000");
|
||||
|
||||
assertNull(role);
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateRoleRequest = server.takeRequest();
|
||||
assertEquals(updateRoleRequest.getRequestLine(), "GET /OS-KSADM/roles/r1000 HTTP/1.1");
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRole() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -223,25 +146,4 @@ public class RoleAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteRoleFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
RoleAdminApi roleAdminApi = keystoneApi.getRoleAdminApi().get();
|
||||
boolean success = roleAdminApi.delete("r1000");
|
||||
|
||||
assertFalse(success);
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateRoleRequest = server.takeRequest();
|
||||
assertEquals(updateRoleRequest.getRequestLine(), "DELETE /OS-KSADM/roles/r1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
package org.jclouds.openstack.keystone.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -32,7 +29,6 @@ import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
|
|||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
|
@ -76,31 +72,6 @@ public class ServiceAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi>
|
|||
}
|
||||
}
|
||||
|
||||
public void listZeroServices() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
ServiceAdminApi serviceAdminApi = keystoneApi.getServiceAdminApi().get();
|
||||
PagedIterable<? extends Service> services = serviceAdminApi.list();
|
||||
|
||||
ImmutableList<? extends Service> servicesList = services.concat().toList();
|
||||
assertTrue(servicesList.isEmpty());
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateServiceRequest = server.takeRequest();
|
||||
assertEquals(updateServiceRequest.getRequestLine(), "GET /OS-KSADM/services HTTP/1.1");
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void listServicesPage() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -157,34 +128,6 @@ public class ServiceAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi>
|
|||
}
|
||||
}
|
||||
|
||||
public void createServiceFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
ServiceAdminApi serviceAdminApi = keystoneApi.getServiceAdminApi().get();
|
||||
Service testService = serviceAdminApi.create("jclouds-service-test", "jclouds-service-type",
|
||||
"jclouds-service-description");
|
||||
|
||||
assertNull(testService);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest createServiceRequest = server.takeRequest();
|
||||
assertEquals(createServiceRequest.getRequestLine(), "POST /OS-KSADM/services HTTP/1.1");
|
||||
String bodyRequest = new String(createServiceRequest.getBody());
|
||||
assertEquals(
|
||||
bodyRequest,
|
||||
"{\"OS-KSADM:service\":{\"name\":\"jclouds-service-test\",\"type\":\"jclouds-service-type\",\"description\":\"jclouds-service-description\"}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void getService() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -213,30 +156,6 @@ public class ServiceAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi>
|
|||
}
|
||||
}
|
||||
|
||||
public void getServiceFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
ServiceAdminApi serviceAdminApi = keystoneApi.getServiceAdminApi().get();
|
||||
Service service = serviceAdminApi.get("s1000");
|
||||
|
||||
assertNull(service);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateServiceRequest = server.takeRequest();
|
||||
assertEquals(updateServiceRequest.getRequestLine(), "GET /OS-KSADM/services/s1000 HTTP/1.1");
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteService() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -258,26 +177,4 @@ public class ServiceAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi>
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteServiceFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
ServiceAdminApi serviceAdminApi = keystoneApi.getServiceAdminApi().get();
|
||||
boolean success = serviceAdminApi.delete("s1000");
|
||||
|
||||
assertFalse(success);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateServiceRequest = server.takeRequest();
|
||||
assertEquals(updateServiceRequest.getRequestLine(), "DELETE /OS-KSADM/services/s1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
package org.jclouds.openstack.keystone.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||
|
@ -67,33 +65,6 @@ public class TenantAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void createTenantFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
TenantAdminApi tenantAdminApi = keystoneApi.getTenantAdminApi().get();
|
||||
CreateTenantOptions createTenantOptions = CreateTenantOptions.Builder.description("jclouds-description")
|
||||
.enabled(true);
|
||||
Tenant testTenant = tenantAdminApi.create("jclouds-tenant", createTenantOptions);
|
||||
|
||||
assertNull(testTenant);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest createTenantRequest = server.takeRequest();
|
||||
assertEquals(createTenantRequest.getRequestLine(), "POST /tenants HTTP/1.1");
|
||||
assertEquals(new String(createTenantRequest.getBody()),
|
||||
"{\"tenant\":{\"name\":\"jclouds-tenant\",\"description\":\"jclouds-description\",\"enabled\":true}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTenant() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -124,34 +95,6 @@ public class TenantAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateTenantFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
TenantAdminApi tenantAdminApi = keystoneApi.getTenantAdminApi().get();
|
||||
UpdateTenantOptions updateTenantOptions = UpdateTenantOptions.Builder
|
||||
.description("jclouds-description-modified").enabled(false).name("jclouds-tenant-modified");
|
||||
Tenant updatedTenant = tenantAdminApi.update("t1000", updateTenantOptions);
|
||||
|
||||
assertNull(updatedTenant);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateTenantRequest = server.takeRequest();
|
||||
assertEquals(updateTenantRequest.getRequestLine(), "PUT /tenants/t1000 HTTP/1.1");
|
||||
assertEquals(
|
||||
new String(updateTenantRequest.getBody()),
|
||||
"{\"tenant\":{\"name\":\"jclouds-tenant-modified\",\"description\":\"jclouds-description-modified\",\"enabled\":false}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTenant() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -173,29 +116,6 @@ public class TenantAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteTenantFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
TenantAdminApi tenantAdminApi = keystoneApi.getTenantAdminApi().get();
|
||||
boolean success = tenantAdminApi.delete("t1000");
|
||||
|
||||
assertFalse(success);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateTenantRequest = server.takeRequest();
|
||||
assertEquals(updateTenantRequest.getRequestLine(), "DELETE /tenants/t1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void addRoleOnTenant() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -218,30 +138,6 @@ public class TenantAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void addRoleOnTenantFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
TenantAdminApi tenantAdminApi = keystoneApi.getTenantAdminApi().get();
|
||||
boolean success = tenantAdminApi.addRoleOnTenant("u1000", "t1000", "r1000");
|
||||
|
||||
assertFalse(success);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateTenantRequest = server.takeRequest();
|
||||
assertEquals(updateTenantRequest.getRequestLine(),
|
||||
"PUT /tenants/u1000/users/t1000/roles/OS-KSADM/r1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteRoleOnTenant() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -264,27 +160,4 @@ public class TenantAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteRoleOnTenantFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
TenantAdminApi tenantAdminApi = keystoneApi.getTenantAdminApi().get();
|
||||
boolean success = tenantAdminApi.deleteRoleOnTenant("t1000", "u1000", "r1000");
|
||||
|
||||
assertFalse(success);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateTenantRequest = server.takeRequest();
|
||||
assertEquals(updateTenantRequest.getRequestLine(),
|
||||
"DELETE /tenants/t1000/users/u1000/roles/OS-KSADM/r1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
package org.jclouds.openstack.keystone.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||
|
@ -68,33 +66,6 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void createUserFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
UserAdminApi userAdminApi = keystoneApi.getUserAdminApi().get();
|
||||
CreateUserOptions createUserOptions = CreateUserOptions.Builder.email("john.smith@example.org").enabled(true);
|
||||
User testUser = userAdminApi.create("jqsmith", "jclouds-password", createUserOptions);
|
||||
|
||||
assertNull(testUser);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest createUserRequest = server.takeRequest();
|
||||
assertEquals(createUserRequest.getRequestLine(), "POST /users HTTP/1.1");
|
||||
assertEquals(
|
||||
new String(createUserRequest.getBody()),
|
||||
"{\"user\":{\"name\":\"jqsmith\",\"password\":\"jclouds-password\",\"email\":\"john.smith@example.org\",\"enabled\":true}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUser() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -125,34 +96,6 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateUserFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
UserAdminApi userAdminApi = keystoneApi.getUserAdminApi().get();
|
||||
UpdateUserOptions updateUserOptions = UpdateUserOptions.Builder.email("john.smith.renamed@example.org")
|
||||
.enabled(false).name("jqsmith-renamed").password("jclouds-password");
|
||||
User updatedUser = userAdminApi.update("u1000", updateUserOptions);
|
||||
|
||||
assertNull(updatedUser);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateUserRequest = server.takeRequest();
|
||||
assertEquals(updateUserRequest.getRequestLine(), "PUT /users/u1000 HTTP/1.1");
|
||||
assertEquals(
|
||||
new String(updateUserRequest.getBody()),
|
||||
"{\"user\":{\"name\":\"jqsmith-renamed\",\"email\":\"john.smith.renamed@example.org\",\"password\":\"jclouds-password\",\"enabled\":false}}");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteUser() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
|
@ -174,26 +117,4 @@ public class UserAdminApiMockTest extends BaseOpenStackMockTest<KeystoneApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteUserFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access_version_uids.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/admin_extensions.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
KeystoneApi keystoneApi = api(server.getUrl("/").toString(), "openstack-keystone");
|
||||
UserAdminApi userAdminApi = keystoneApi.getUserAdminApi().get();
|
||||
boolean success = userAdminApi.delete("u1000");
|
||||
|
||||
assertFalse(success);
|
||||
|
||||
assertEquals(server.getRequestCount(), 3);
|
||||
assertAuthentication(server);
|
||||
assertExtensions(server);
|
||||
RecordedRequest updateUserRequest = server.takeRequest();
|
||||
assertEquals(updateUserRequest.getRequestLine(), "DELETE /users/u1000 HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -57,10 +56,4 @@ public class ServiceApiExpectTest extends BaseKeystoneRestApiExpectTest<Keystone
|
|||
assertEquals(tenants, expected);
|
||||
}
|
||||
|
||||
public void testListTenantsFailNotFound() {
|
||||
ServiceApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/tenants").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getServiceApi();
|
||||
assertTrue(api.listTenants().isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -30,7 +28,6 @@ import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
|||
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
|
||||
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest;
|
||||
import org.jclouds.openstack.v2_0.options.PaginationOptions;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -93,16 +90,6 @@ public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneA
|
|||
assertEquals(api.list().concat().toSet(), expected);
|
||||
}
|
||||
|
||||
// this is not a compatible format of json per:
|
||||
// http://docs.openstack.org/api/openstack-identity-service/2.0/content/Paginated_Collections-d1e325.html
|
||||
@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 testGetTenant() {
|
||||
TenantApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
|
@ -117,14 +104,6 @@ public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneA
|
|||
build());
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
public void testGetTenantByName() {
|
||||
TenantApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
|
@ -139,11 +118,4 @@ public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneA
|
|||
build());
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@ package org.jclouds.openstack.keystone.v2_0.features;
|
|||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -30,7 +28,6 @@ import org.jclouds.date.DateService;
|
|||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Role;
|
||||
|
@ -67,24 +64,6 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
|
|||
.tenant(Tenant.builder().id("4cea93f5464b4f1c921fb3e0461d72b5").name("demo").enabled(true).build()).build());
|
||||
}
|
||||
|
||||
public void testGetTokenFailNotFound() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||
HttpResponse.builder().statusCode(404).build())
|
||||
.getTokenApi().get();
|
||||
assertNull(api.get("sometokenorother"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = HttpResponseException.class)
|
||||
public void testGetTokenFail500() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||
HttpResponse.builder().statusCode(500).build()).getTokenApi().get();
|
||||
api.get("sometokenorother");
|
||||
}
|
||||
|
||||
public void testGetUserOfToken() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
|
@ -98,14 +77,6 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
|
|||
.build());
|
||||
}
|
||||
|
||||
public void testGetUserOfTokenFailNotFound() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getTokenApi().get();
|
||||
assertNull(api.getUserOfToken("sometokenorother"));
|
||||
}
|
||||
|
||||
public void testCheckTokenIsValid() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
|
@ -119,18 +90,6 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
|
|||
assertTrue(api.isValid("sometokenorother"));
|
||||
}
|
||||
|
||||
public void testCheckTokenIsValidFailNotValid() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
HttpRequest.builder().method("HEAD")
|
||||
.endpoint(endpoint + "/v2.0/tokens/sometokenorother")
|
||||
.addHeader("Accept", APPLICATION_JSON)
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getTokenApi().get();
|
||||
assertFalse(api.isValid("sometokenorother"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndpointsForToken() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
|
@ -147,15 +106,4 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
|
|||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndpointsForTokenFailNotFound() {
|
||||
TokenApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
|
||||
HttpResponse.builder().statusCode(404).build())
|
||||
.getTokenApi().get();
|
||||
assertTrue(api.listEndpointsForToken("XXXXXX").isEmpty());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -82,14 +81,6 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
|
|||
assertEquals(users.toSet(), expectedUsers);
|
||||
}
|
||||
|
||||
public void testListUsersNotFound() {
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/users").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
|
||||
assertEquals( api.list(new PaginationOptions()).size(), 0);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testListUsersFailNotAuth() {
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -111,14 +102,6 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
|
|||
tenantId("ab1da202f5774cceb5da2aeff1f0aa87").build());
|
||||
}
|
||||
|
||||
public void testGetUserFailNotFound() {
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
|
||||
assertNull(api.get("f021dfd758eb44a89f1c57c8ef3be8e2"));
|
||||
}
|
||||
|
||||
public void testGetUserByName() {
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
|
@ -131,14 +114,6 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
|
|||
tenantId("ab1da202f5774cceb5da2aeff1f0aa87").build());
|
||||
}
|
||||
|
||||
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 api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
|
@ -153,14 +128,6 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
|
|||
));
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = HttpResponseException.class)
|
||||
public void testListRolesOfUserFailNotImplemented() {
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -185,12 +152,4 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
|
|||
Role.builder().id("6ea17ddd37a6447794cb0e164d4db894").name("KeystoneAdmin").build()));
|
||||
}
|
||||
|
||||
public void testListRolesOfUserInTenantFailNotFound() {
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getUserApi().get();
|
||||
assertTrue(api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.jclouds.ec2.domain.KeyPair;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestApiExpectTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class NovaEC2KeyPairApiExpectTest extends BaseNovaEC2RestApiExpectTest {
|
||||
|
@ -43,21 +42,6 @@ public class NovaEC2KeyPairApiExpectTest extends BaseNovaEC2RestApiExpectTest {
|
|||
assertEquals(result.getSha1OfPrivateKey(), "e3:fd:de:f6:4c:36:7d:9b:8f:2f:4c:20:f8:ae:b0:ea");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testImportKeyPairFailsNotFound() {
|
||||
NovaEC2KeyPairApi client = requestsSendResponses(
|
||||
describeAvailabilityZonesRequest,
|
||||
describeAvailabilityZonesResponse,
|
||||
HttpRequest.builder().method("POST")
|
||||
.endpoint("http://localhost:8773/services/Cloud/")
|
||||
.addHeader("Host", "localhost:8773")
|
||||
.payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getKeyPairApi().get();
|
||||
|
||||
client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testImportKeyPairFailsAlreadyExists() {
|
||||
NovaEC2KeyPairApi client = requestsSendResponses(
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.jclouds.openstack.nova.v2_0.compute.functions;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -38,6 +39,7 @@ import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
|
|||
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
|
||||
import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
|
||||
import org.jclouds.rest.InsufficientResourcesException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -114,8 +116,9 @@ public class AllocateAndAddFloatingIpToNode implements
|
|||
try {
|
||||
logger.debug(">> allocating floating IP from pool %s for node(%s)", poolName, nodeID);
|
||||
ip = floatingIpApi.allocateFromPool(poolName);
|
||||
if (ip != null)
|
||||
return Optional.of(ip);
|
||||
return Optional.of(ip);
|
||||
} catch (ResourceNotFoundException ex) {
|
||||
logger.trace("<< [%s] failed to allocate floating IP from pool %s for node(%s)", ex.getMessage(), poolName, nodeID);
|
||||
} catch (InsufficientResourcesException ire) {
|
||||
logger.trace("<< [%s] failed to allocate floating IP from pool %s for node(%s)", ire.getMessage(), poolName, nodeID);
|
||||
}
|
||||
|
@ -126,8 +129,9 @@ public class AllocateAndAddFloatingIpToNode implements
|
|||
try {
|
||||
logger.debug(">> creating floating IP for node(%s)", nodeID);
|
||||
ip = floatingIpApi.create();
|
||||
if (ip != null)
|
||||
return Optional.of(ip);
|
||||
return Optional.of(ip);
|
||||
} catch (ResourceNotFoundException ex) {
|
||||
logger.trace("<< [%s] failed to create floating IP for node(%s)", ex.getMessage(), nodeID);
|
||||
} catch (InsufficientResourcesException ire) {
|
||||
logger.trace("<< [%s] failed to create floating IP for node(%s)", ire.getMessage(), nodeID);
|
||||
}
|
||||
|
|
|
@ -81,15 +81,14 @@ public interface FlavorExtraSpecsApi {
|
|||
@Path("/{id}/os-extra_specs")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean updateMetadata(@PathParam("id") String flavorId,
|
||||
void updateMetadata(@PathParam("id") String flavorId,
|
||||
@PayloadParam("extra_specs") Map<String, String> specs);
|
||||
|
||||
/**
|
||||
* Return a single extra spec value
|
||||
*
|
||||
* @param id the id of the flavor to modify
|
||||
* @param key the extra spec key to retrieve
|
||||
* @param flavorId the id of the flavor to modify
|
||||
* @param key the extra spec key to retrieve
|
||||
*/
|
||||
@Named("flavorExtraSpecs:getMetadataKey")
|
||||
@GET
|
||||
|
@ -102,29 +101,28 @@ public interface FlavorExtraSpecsApi {
|
|||
/**
|
||||
* Creates or updates a single extra spec value
|
||||
*
|
||||
* @param id the id of the flavor to modify
|
||||
* @param key the extra spec key (when creating ensure this does not include whitespace or
|
||||
* other difficult characters)
|
||||
* @param value the value to associate with the key
|
||||
* @param flavorId the id of the flavor to modify
|
||||
* @param key the extra spec key (when creating ensure this does not include whitespace or
|
||||
* other difficult characters)
|
||||
* @param value the value to associate with the key
|
||||
*/
|
||||
@Named("flavorExtraSpecs:updateMetadataEntry")
|
||||
@PUT
|
||||
@Path("/{id}/os-extra_specs/{key}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"{key}\":\"{value}\"%7D")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean updateMetadataEntry(@PathParam("id") String flavorId,
|
||||
void updateMetadataEntry(@PathParam("id") String flavorId,
|
||||
@PathParam("key") @PayloadParam("key") String key, @PayloadParam("value") String value);
|
||||
|
||||
/**
|
||||
* Deletes an extra spec
|
||||
*
|
||||
* @param id the id of the flavor to modify
|
||||
* @param key the extra spec key to delete
|
||||
* @param flavorId the id of the flavor to modify
|
||||
* @param key the extra spec key to delete
|
||||
*/
|
||||
@Named("flavorExtraSpecs:deleteMetadataKey")
|
||||
@DELETE
|
||||
@Path("/{id}/os-extra_specs/{key}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean deleteMetadataKey(@PathParam("id") String flavorId, @PathParam("key") String key);
|
||||
boolean deleteMetadataKey(@PathParam("id") String flavorId, @PathParam("key") String key);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ public interface FloatingIPApi {
|
|||
@SelectJson("floating_ip")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{}")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
FloatingIP create();
|
||||
|
||||
|
@ -103,7 +102,6 @@ public interface FloatingIPApi {
|
|||
@SelectJson("floating_ip")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"pool\":\"{pool}\"%7D")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
FloatingIP allocateFromPool(@PayloadParam("pool") String pool);
|
||||
|
||||
|
@ -121,7 +119,7 @@ public interface FloatingIPApi {
|
|||
/**
|
||||
* Adds a Floating IP address to a Server
|
||||
*
|
||||
* @param id
|
||||
* @param serverId
|
||||
* the server id
|
||||
* @param address
|
||||
* the IP address to add
|
||||
|
@ -138,7 +136,7 @@ public interface FloatingIPApi {
|
|||
/**
|
||||
* Removes a Floating IP address from a Server
|
||||
*
|
||||
* @param id
|
||||
* @param serverId
|
||||
* the server id
|
||||
* @param address
|
||||
* the IP address to remove
|
||||
|
|
|
@ -91,7 +91,6 @@ public interface SecurityGroupApi {
|
|||
@SelectJson("security_group")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
SecurityGroup createWithDescription(@PayloadParam("name") String name,
|
||||
@PayloadParam("description") String description);
|
||||
|
@ -118,7 +117,6 @@ public interface SecurityGroupApi {
|
|||
@SelectJson("security_group_rule")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindSecurityGroupRuleToJsonPayload.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
SecurityGroupRule createRuleAllowingCidrBlock(
|
||||
@PayloadParam("parent_group_id") String parentGroup, Ingress ip_protocol,
|
||||
|
@ -135,7 +133,6 @@ public interface SecurityGroupApi {
|
|||
@SelectJson("security_group_rule")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindSecurityGroupRuleToJsonPayload.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
SecurityGroupRule createRuleAllowingSecurityGroupId(
|
||||
@PayloadParam("parent_group_id") String parentGroup, Ingress ip_protocol,
|
||||
|
|
|
@ -24,7 +24,6 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.BackupType;
|
||||
|
@ -64,8 +63,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"suspend\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean suspend(@PathParam("id") String id);
|
||||
void suspend(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Resume a server.
|
||||
|
@ -76,8 +74,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"resume\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean resume(@PathParam("id") String id);
|
||||
void resume(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Migrate a server.
|
||||
|
@ -88,8 +85,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"migrate\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean migrate(@PathParam("id") String id);
|
||||
void migrate(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Lock a server.
|
||||
|
@ -100,8 +96,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"lock\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean lock(@PathParam("id") String id);
|
||||
void lock(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Unlock a server.
|
||||
|
@ -112,8 +107,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"unlock\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean unlock(@PathParam("id") String id);
|
||||
void unlock(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Reset network of a server.
|
||||
|
@ -124,8 +118,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"resetNetwork\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean resetNetwork(@PathParam("id") String id);
|
||||
void resetNetwork(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Create backup of a server.
|
||||
|
@ -156,8 +149,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"pause\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean pause(@PathParam("id") String id);
|
||||
void pause(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Unpause a server.
|
||||
|
@ -168,8 +160,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"unpause\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean unpause(@PathParam("id") String id);
|
||||
void unpause(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* Live migrate a server.
|
||||
|
@ -180,8 +171,7 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@WrapWith("os-migrateLive")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean liveMigrate(@PathParam("id") String id, @PayloadParam("host") String host,
|
||||
void liveMigrate(@PathParam("id") String id, @PayloadParam("host") String host,
|
||||
@PayloadParam("block_migration") boolean blockMigration,
|
||||
@PayloadParam("disk_over_commit") boolean diskOverCommit);
|
||||
|
||||
|
@ -194,6 +184,5 @@ public interface ServerAdminApi {
|
|||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("{\"injectNetworkInfo\":null}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
Boolean injectNetworkInfo(@PathParam("id") String id);
|
||||
void injectNetworkInfo(@PathParam("id") String id);
|
||||
}
|
||||
|
|
|
@ -132,8 +132,7 @@ public interface VolumeTypeApi {
|
|||
@Path("/{id}/extra_specs")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateExtraSpecs(@PathParam("id") String id, @PayloadParam("extra_specs") Map<String, String> specs);
|
||||
void updateExtraSpecs(@PathParam("id") String id, @PayloadParam("extra_specs") Map<String, String> specs);
|
||||
|
||||
/**
|
||||
* Retrieve a single extra spec value
|
||||
|
@ -161,8 +160,7 @@ public interface VolumeTypeApi {
|
|||
@Path("/{id}/extra_specs/{key}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"{key}\":\"{value}\"%7D")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateExtraSpec(@PathParam("id") String id,
|
||||
void updateExtraSpec(@PathParam("id") String id,
|
||||
@PathParam("key") @PayloadParam("key") String key,
|
||||
@PayloadParam("value") String value);
|
||||
|
||||
|
|
|
@ -119,8 +119,6 @@ public interface FlavorApi {
|
|||
@POST
|
||||
@Unwrap
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Flavor create(@WrapWith("flavor") Flavor flavor);
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,9 +117,7 @@ public interface ImageApi {
|
|||
/**
|
||||
* Delete the specified image
|
||||
*
|
||||
* @param id
|
||||
* id of the image
|
||||
* @return server or null if not found
|
||||
* @param id id of the image
|
||||
*/
|
||||
@Named("image:delete")
|
||||
@DELETE
|
||||
|
@ -156,7 +154,6 @@ public interface ImageApi {
|
|||
@SelectJson("metadata")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(EmptyMapOnNotFoundOr404.class)
|
||||
Map<String, String> setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
|
@ -174,7 +171,6 @@ public interface ImageApi {
|
|||
@SelectJson("metadata")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(EmptyMapOnNotFoundOr404.class)
|
||||
Map<String, String> updateMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
|
@ -210,7 +206,6 @@ public interface ImageApi {
|
|||
@Path("/{id}/metadata/{key}")
|
||||
@ResponseParser(OnlyMetadataValueOrNull.class)
|
||||
@MapBinder(BindMetadataToJsonPayload.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
String updateMetadata(@PathParam("id") String id, @PathParam("key") @PayloadParam("key") String key,
|
||||
@PathParam("value") @PayloadParam("value") String value);
|
||||
|
|
|
@ -335,7 +335,6 @@ public interface ServerApi {
|
|||
@Path("/{id}/metadata")
|
||||
@SelectJson("metadata")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Fallback(EmptyMapOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Map<String, String> setMetadata(@PathParam("id") String id,
|
||||
@PayloadParam("metadata") Map<String, String> metadata);
|
||||
|
@ -355,7 +354,6 @@ public interface ServerApi {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("metadata")
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(EmptyMapOnNotFoundOr404.class)
|
||||
Map<String, String> updateMetadata(@PathParam("id") String id,
|
||||
@PayloadParam("metadata") Map<String, String> metadata);
|
||||
|
||||
|
|
|
@ -127,22 +127,6 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
|
|||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||
}
|
||||
|
||||
public void testListServersWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ComputeService apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.listNodes().isEmpty());
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -29,8 +27,6 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.openstack.nova.v2_0.domain.BackupType;
|
||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||
import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -50,31 +46,6 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.suspend("1"));
|
||||
}
|
||||
|
||||
public void testSuspendFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.suspend("1"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testSuspendFailsNotAuthorized() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
|
||||
HttpResponse.builder().statusCode(403).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.suspend("1");
|
||||
}
|
||||
|
||||
|
@ -87,31 +58,6 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.resume("1"));
|
||||
}
|
||||
|
||||
public void testResumeFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.resume("1"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testResumeFailsNotAuthorized() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
|
||||
HttpResponse.builder().statusCode(403).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.resume("1");
|
||||
}
|
||||
|
||||
|
@ -124,19 +70,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.lock("1"));
|
||||
}
|
||||
|
||||
public void testLockFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.lock("1"));
|
||||
api.lock("1");
|
||||
}
|
||||
|
||||
public void testUnlock() {
|
||||
|
@ -148,19 +82,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.unlock("1"));
|
||||
}
|
||||
|
||||
public void testUnlockFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.unlock("1"));
|
||||
api.unlock("1");
|
||||
}
|
||||
|
||||
public void testPause() {
|
||||
|
@ -172,19 +94,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.pause("1"));
|
||||
}
|
||||
|
||||
public void testPauseFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.pause("1"));
|
||||
api.pause("1");
|
||||
}
|
||||
|
||||
public void testUnpause() {
|
||||
|
@ -196,19 +106,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.unpause("1"));
|
||||
}
|
||||
|
||||
public void testUnpauseFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.unpause("1"));
|
||||
api.unpause("1");
|
||||
}
|
||||
|
||||
public void testMigrateServer() {
|
||||
|
@ -220,20 +118,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.migrate("1"));
|
||||
}
|
||||
|
||||
|
||||
public void testMigrateServerFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.migrate("1"));
|
||||
api.migrate("1");
|
||||
}
|
||||
|
||||
public void testResetNetworkOfServer() {
|
||||
|
@ -245,19 +130,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.resetNetwork("1"));
|
||||
}
|
||||
|
||||
public void testResetNetworkOfServerFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.resetNetwork("1"));
|
||||
api.resetNetwork("1");
|
||||
}
|
||||
|
||||
public void testInjectNetworkInfoIntoServer() {
|
||||
|
@ -269,19 +142,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.injectNetworkInfo("1"));
|
||||
}
|
||||
|
||||
public void testInjectNetworkInfoIntoServerFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.injectNetworkInfo("1"));
|
||||
api.injectNetworkInfo("1");
|
||||
}
|
||||
|
||||
public void testBackupServer() {
|
||||
|
@ -297,20 +158,6 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(imageId, "1976b3b3-409a-468d-b16c-a9172c341b46");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testBackupServerFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("POST")
|
||||
.payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
|
||||
}
|
||||
|
||||
public void testLiveMigrateServer() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
|
@ -321,20 +168,7 @@ public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.liveMigrate("1", "bighost", true, false));
|
||||
}
|
||||
|
||||
public void testLiveMigrateServerFailsNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action");
|
||||
ServerAdminApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
|
||||
.payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerAdminApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.liveMigrate("1", "bighost", true, false));
|
||||
api.liveMigrate("1", "bighost", true, false);
|
||||
}
|
||||
|
||||
protected HttpRequest.Builder<?> standardActionRequestBuilderVoidResponse(URI endpoint, String actionName) {
|
||||
|
|
|
@ -106,14 +106,14 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
|||
fail("Resumed an active server!");
|
||||
} catch (HttpResponseException e) {
|
||||
}
|
||||
assertTrue(api.suspend(testServerId));
|
||||
api.suspend(testServerId);
|
||||
blockUntilServerInState(testServerId, serverApi, Status.SUSPENDED);
|
||||
try {
|
||||
api.suspend(testServerId);
|
||||
fail("Suspended an already suspended server!");
|
||||
} catch (HttpResponseException e) {
|
||||
}
|
||||
assertTrue(api.resume(testServerId));
|
||||
api.resume(testServerId);
|
||||
blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
|
||||
try {
|
||||
api.resume(testServerId);
|
||||
|
@ -128,20 +128,20 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
|||
ServerAdminApi api = apiOption.get();
|
||||
|
||||
// TODO should we be able to double-lock (as it were)
|
||||
assertTrue(api.unlock(testServerId));
|
||||
assertTrue(api.unlock(testServerId));
|
||||
assertTrue(api.lock(testServerId));
|
||||
assertTrue(api.lock(testServerId));
|
||||
assertTrue(api.unlock(testServerId));
|
||||
assertTrue(api.unlock(testServerId));
|
||||
api.unlock(testServerId);
|
||||
api.unlock(testServerId);
|
||||
api.lock(testServerId);
|
||||
api.lock(testServerId);
|
||||
api.unlock(testServerId);
|
||||
api.unlock(testServerId);
|
||||
|
||||
}
|
||||
|
||||
public void testResetNetworkAndInjectNetworkInfo() {
|
||||
skipOnAdminExtensionAbsent();
|
||||
ServerAdminApi api = apiOption.get();
|
||||
assertTrue(api.resetNetwork(testServerId));
|
||||
assertTrue(api.injectNetworkInfo(testServerId));
|
||||
api.resetNetwork(testServerId);
|
||||
api.injectNetworkInfo(testServerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -155,14 +155,14 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
|||
fail("Unpaused active server!");
|
||||
} catch (HttpResponseException e) {
|
||||
}
|
||||
assertTrue(api.pause(testServerId));
|
||||
api.pause(testServerId);
|
||||
blockUntilServerInState(testServerId, serverApi, Status.PAUSED);
|
||||
try {
|
||||
api.pause(testServerId);
|
||||
fail("paused a paused server!");
|
||||
} catch (HttpResponseException e) {
|
||||
}
|
||||
assertTrue(api.unpause(testServerId));
|
||||
api.unpause(testServerId);
|
||||
blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
|
||||
try {
|
||||
api.unpause(testServerId);
|
||||
|
|
|
@ -84,21 +84,6 @@ public class AvailabilityZoneApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(zone.get().getState().isAvailable(), "Zone: " + zone.get().getName() + " is not available.");
|
||||
}
|
||||
|
||||
public void testListAvailabilityZonesWhenResponseIs404() throws Exception {
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-availability-zone")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getAvailabilityZoneApi("az-1.region-a.geo-1").get().listAvailabilityZones().isEmpty());
|
||||
}
|
||||
|
||||
public void testListInDetail() throws Exception {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
|
@ -139,18 +124,4 @@ public class AvailabilityZoneApiExpectTest extends BaseNovaApiExpectTest {
|
|||
"Expected Updated time: " + new Date(1436509815000L) + " does match Updated time : " + hostService.getUpdated());
|
||||
}
|
||||
|
||||
public void testListInDetailWhenResponseIs404() throws Exception {
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-availability-zone/detail")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
|
||||
extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getAvailabilityZoneApi("az-1.region-a.geo-1").get().listInDetail().isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.jclouds.openstack.nova.v2_0.extensions;
|
|||
import static com.google.common.collect.Iterables.getFirst;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.Console;
|
||||
|
@ -51,34 +50,18 @@ public class ConsolesApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
|||
getConsole(Console.Type.NOVNC, "/novnc_console.json", new ParseNOVNCConsoleTest().expected());
|
||||
}
|
||||
|
||||
public void getNOVNCConsoleWhenResponseIs404NotFound() throws Exception {
|
||||
getConsoleWhenResponseIs404NotFound(Console.Type.NOVNC);
|
||||
}
|
||||
|
||||
public void getXVPVNCConsole() throws Exception {
|
||||
getConsole(Console.Type.XVPVNC, "/xvpvnc_console.json", new ParseXVPVNCConsoleTest().expected());
|
||||
}
|
||||
|
||||
public void getXVPVNCConsoleWhenResponseIs404NotFound() throws Exception {
|
||||
getConsoleWhenResponseIs404NotFound(Console.Type.XVPVNC);
|
||||
}
|
||||
|
||||
public void getSPICEConsole() throws Exception {
|
||||
getConsole(Console.Type.SPICE_HTML5, "/spice_console.json", new ParseSPICEConsoleTest().expected());
|
||||
}
|
||||
|
||||
public void getSPICEConsoleWhenResponseIs404NotFound() throws Exception {
|
||||
getConsoleWhenResponseIs404NotFound(Console.Type.SPICE_HTML5);
|
||||
}
|
||||
|
||||
public void getRDPConsole() throws Exception {
|
||||
getConsole(Console.Type.RDP_HTML5, "/rdp_console.json", new ParseRDPConsoleTest().expected());
|
||||
}
|
||||
|
||||
public void getRDPConsoleWhenResponseIs404NotFound() throws Exception {
|
||||
getConsoleWhenResponseIs404NotFound(Console.Type.RDP_HTML5);
|
||||
}
|
||||
|
||||
private void getConsole(Console.Type consoleType, String responseResource, Console expected) throws Exception {
|
||||
String serverId = "5f64fca7-879b-4173-bf9c-8fa88330a4dc";
|
||||
|
||||
|
@ -105,40 +88,4 @@ public class ConsolesApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
|||
}
|
||||
}
|
||||
|
||||
private void getConsoleWhenResponseIs404NotFound(Console.Type consoleType) throws Exception {
|
||||
String serverId = "5f64fca7-879b-4173-bf9c-8fa88330a4dc";
|
||||
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse()
|
||||
.setStatus("HTTP/1.1 404 Not Found")
|
||||
.setBody("{\"itemNotFound\":" + "{\"message\":\"Instance " + serverId
|
||||
+ " could not be found.\",\"code\":404}}")
|
||||
.setHeader("Content-Type", "application/json; charset=UTF-8")));
|
||||
|
||||
try {
|
||||
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
||||
|
||||
String regionId = getFirst(novaApi.getConfiguredRegions(), "RegionTwo");
|
||||
|
||||
ConsolesApi consolesApi = novaApi.getConsolesApi(regionId).get();
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
assertEquals(server.takeRequest().getRequestLine(),
|
||||
"GET /v2/da0d12be20394afb851716e10a49e4a7/extensions HTTP/1.1");
|
||||
|
||||
try {
|
||||
consolesApi.getConsole(serverId, consoleType);
|
||||
fail("expected a ResourceNotFoundException");
|
||||
} catch (org.jclouds.rest.ResourceNotFoundException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -49,18 +47,6 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getMetadata("9"), ImmutableMap.of("test", "value1"));
|
||||
}
|
||||
|
||||
public void testGetAllExtraSpecsFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/9/os-extra_specs");
|
||||
FlavorExtraSpecsApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.getMetadata("9").isEmpty());
|
||||
}
|
||||
|
||||
public void testSetAllExtraSpecs() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/9/os-extra_specs");
|
||||
FlavorExtraSpecsApi api = requestsSendResponses(
|
||||
|
@ -72,7 +58,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build()
|
||||
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.updateMetadata("9", ImmutableMap.of("test1", "somevalue")));
|
||||
api.updateMetadata("9", ImmutableMap.of("test1", "somevalue"));
|
||||
}
|
||||
|
||||
public void testSetExtraSpec() {
|
||||
|
@ -86,7 +72,7 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build()
|
||||
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.updateMetadataEntry("5", "test1", "somevalue"));
|
||||
api.updateMetadataEntry("5", "test1", "somevalue");
|
||||
}
|
||||
|
||||
public void testGetExtraSpec() {
|
||||
|
@ -101,18 +87,6 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getMetadataKey("5", "test1"), "another value");
|
||||
}
|
||||
|
||||
public void testGetExtraSpecFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1");
|
||||
FlavorExtraSpecsApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.getMetadataKey("5", "test1"));
|
||||
}
|
||||
|
||||
public void testDeleteExtraSpec() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1");
|
||||
FlavorExtraSpecsApi api = requestsSendResponses(
|
||||
|
@ -125,16 +99,4 @@ public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.deleteMetadataKey("5", "test1"));
|
||||
}
|
||||
|
||||
public void testDeleteExtraSpecFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1");
|
||||
FlavorExtraSpecsApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getFlavorExtraSpecsApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.deleteMetadataKey("5", "test1"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
|||
assertNotNull(before);
|
||||
Map<String, String> specs = Maps.newHashMap(before);
|
||||
specs.putAll(testSpecs);
|
||||
assertTrue(api.updateMetadata(testFlavor.getId(), specs));
|
||||
api.updateMetadata(testFlavor.getId(), specs);
|
||||
assertEquals(api.getMetadata(testFlavor.getId()), specs);
|
||||
for (Map.Entry<String, String> entry : specs.entrySet()) {
|
||||
assertEquals(api.getMetadataKey(testFlavor.getId(), entry.getKey()), entry.getValue());
|
||||
|
@ -104,7 +104,7 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
|||
if (apiOption.isPresent()) {
|
||||
FlavorExtraSpecsApi api = apiOption.get();
|
||||
for (String key : testSpecs.keySet()) {
|
||||
assertTrue(api.updateMetadataEntry(testFlavor.getId(), key, "new value"));
|
||||
api.updateMetadataEntry(testFlavor.getId(), key, "new value");
|
||||
}
|
||||
for (String key : testSpecs.keySet()) {
|
||||
assertEquals(api.getMetadataKey(testFlavor.getId(), key), "new value");
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.openstack.nova.v2_0.extensions;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -89,22 +88,6 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseFloatingIPListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListFloatingIPsWhenResponseIs404() throws Exception {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().list().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
|
@ -123,22 +106,6 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseFloatingIPTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetFloatingIPWhenResponseIs404() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips/1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||
|
||||
assertNull(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().get("1"));
|
||||
}
|
||||
|
||||
public void testAllocateWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createFloatingIP = HttpRequest
|
||||
.builder()
|
||||
|
@ -160,24 +127,6 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
|
|||
|
||||
}
|
||||
|
||||
public void testAllocateWhenResponseIs404() throws Exception {
|
||||
HttpRequest createFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
|
||||
|
||||
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
|
||||
createFloatingIPResponse);
|
||||
|
||||
assertNull(apiWhenNoServersExist.getFloatingIPApi("az-1.region-a.geo-1").get().create());
|
||||
}
|
||||
|
||||
public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createFloatingIP = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -77,19 +77,4 @@ public class FloatingIPPoolApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseFloatingIPPoolListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListFloatingIPsWhenResponseIs404() throws Exception {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ip-pools")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getFloatingIPPoolApi("az-1.region-a.geo-1").get().list().isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.openstack.nova.v2_0.domain.Host;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
|
||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -99,21 +98,6 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.enable("ubuntu"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testEnableHostFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu");
|
||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
HttpRequest.builder().method("PUT")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
|
||||
.endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404)
|
||||
.build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||
api.enable("ubuntu");
|
||||
}
|
||||
|
||||
public void testEnableHostFailNotEnabled() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu");
|
||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
|
@ -187,18 +171,6 @@ public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.startup("ubuntu"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testStartupHostFailNotFound() {
|
||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
HttpRequest.builder().method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getHostAdministrationApi("az-1.region-a.geo-1").get();
|
||||
assertTrue(api.startup("ubuntu"));
|
||||
}
|
||||
|
||||
public void testStartupHostFailWrongActionInProgress() {
|
||||
HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -65,16 +63,6 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.get("1"), exampleHostAggregateWithHost());
|
||||
}
|
||||
|
||||
public void testGetFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1");
|
||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.get("1"));
|
||||
}
|
||||
|
||||
public void testCreateAggregate() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates");
|
||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
|
@ -98,16 +86,6 @@ public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.delete("1"));
|
||||
}
|
||||
|
||||
public void testDeleteAggregateFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1");
|
||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getHostAggregateApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.delete("1"));
|
||||
}
|
||||
|
||||
public void testUpdateName() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1");
|
||||
HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
|
|
|
@ -101,19 +101,6 @@ public class HypervisorApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
|||
assertRequests(server, 3, "/os-hypervisors");
|
||||
}
|
||||
|
||||
public void testListHypervisorWhenResponseIs404(Method method) throws Exception {
|
||||
MockWebServer server = servers.get(method.getName());
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
||||
assertEquals(novaApi.getConfiguredRegions(), ImmutableSet.of("RegionOne", "RegionTwo", "RegionThree"));
|
||||
|
||||
assertTrue(novaApi.getHypervisorApi("RegionOne").get().list().isEmpty());
|
||||
|
||||
assertRequests(server, 3, "/os-hypervisors");
|
||||
}
|
||||
|
||||
public void testListInDetail(Method method) throws Exception {
|
||||
MockWebServer server = servers.get(method.getName());
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json"))));
|
||||
|
@ -163,19 +150,6 @@ public class HypervisorApiMockTest extends BaseOpenStackMockTest<NovaApi> {
|
|||
assertRequests(server, 3, "/os-hypervisors/detail");
|
||||
}
|
||||
|
||||
public void testListInDetailWhenResponseIs404(Method method) throws Exception {
|
||||
MockWebServer server = servers.get(method.getName());
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
|
||||
assertEquals(novaApi.getConfiguredRegions(), ImmutableSet.of("RegionOne", "RegionTwo", "RegionThree"));
|
||||
|
||||
assertTrue(novaApi.getHypervisorApi("RegionOne").get().listInDetail().isEmpty());
|
||||
|
||||
assertRequests(server, 3, "/os-hypervisors/detail");
|
||||
}
|
||||
|
||||
private void assertRequests(MockWebServer server, int requestCount, String requestPath) throws InterruptedException {
|
||||
assertEquals(server.getRequestCount(), requestCount);
|
||||
assertAuthentication(server);
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.openstack.nova.v2_0.extensions;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -57,23 +56,6 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseKeyPairListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListKeyPairsWhenResponseIs404() throws Exception {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getKeyPairApi("az-1.region-a.geo-1").get().list().isEmpty());
|
||||
|
||||
}
|
||||
|
||||
public void testCreateKeyPair() throws Exception {
|
||||
HttpRequest create = HttpRequest
|
||||
.builder()
|
||||
|
@ -157,19 +139,4 @@ public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseKeyPairTest().expected());
|
||||
}
|
||||
|
||||
public void testGetKeyPairWhenResponseIs404() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
|
||||
|
||||
assertNull(apiWhenNoKeyPairExists.getKeyPairApi("az-1.region-a.geo-1").get().get("testkeypair"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -28,7 +27,6 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.Quota;
|
||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -47,15 +45,6 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getByTenant("demo"), getTestQuotas());
|
||||
}
|
||||
|
||||
public void testGetQuotasFailsTenantNotFound() 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(404).build()).getQuotaApi("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,
|
||||
|
@ -66,16 +55,6 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas());
|
||||
}
|
||||
|
||||
public void testGetDefaultQuotasFailsTenantNotFound() 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(404).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||
assertNull(api.getDefaultsForTenant("demo"));
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
|
@ -90,21 +69,6 @@ public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testUpdateQuotasFailsNotFound() 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(404).build()).getQuotaApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.updateQuotaOfTenant(getTestQuotas(), "demo");
|
||||
}
|
||||
|
||||
public static Quota getTestQuotas() {
|
||||
return Quota.builder()
|
||||
.metadataItems(128)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -61,22 +60,6 @@ public class SecurityGroupApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.list().toString(), new ParseSecurityGroupListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listListSecurityGroups = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
|
||||
HttpResponse listListSecurityGroupsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, listListSecurityGroups,
|
||||
listListSecurityGroupsResponse);
|
||||
|
||||
assertTrue(apiWhenNoSecurityGroupsExist.getSecurityGroupApi("az-1.region-a.geo-1").get()
|
||||
.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
|
||||
|
@ -95,23 +78,6 @@ public class SecurityGroupApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.get("0").toString(), new ParseSecurityGroupTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetSecurityGroupWhenResponseIs404() throws Exception {
|
||||
HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/0")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
|
||||
HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, getSecurityGroup,
|
||||
getSecurityGroupResponse);
|
||||
|
||||
assertNull(apiWhenNoSecurityGroupsExist.getSecurityGroupApi("az-1.region-a.geo-1").get()
|
||||
.get("0"));
|
||||
|
||||
}
|
||||
|
||||
public void testCreateSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest create = HttpRequest.builder().method("POST").endpoint(
|
||||
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers(
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -47,15 +46,4 @@ public class ServerWithSecurityGroupsApiExpectTest extends BaseNovaApiExpectTest
|
|||
assertEquals(server.getId(), "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
|
||||
assertEquals(server.getSecurityGroupNames(), ImmutableSet.of("default", "group1"));
|
||||
}
|
||||
|
||||
public void testGetServerWithSecurityGroupsFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
|
||||
ServerWithSecurityGroupsApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getServerWithSecurityGroupsApi("az-1.region-a.geo-1").get();
|
||||
assertNull(api.get("8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -48,15 +47,4 @@ public class VirtualInterfaceApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(vif.getMacAddress(), "fa:16:3e:09:71:34");
|
||||
}
|
||||
|
||||
public void testListVirtualInterfacesFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/os-virtual-interfaces");
|
||||
VirtualInterfaceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVirtualInterfaceApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.listOnServer("1").isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -35,8 +33,6 @@ import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot;
|
|||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
|
||||
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -62,19 +58,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
||||
}
|
||||
|
||||
public void testListVolumesFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
Set<? extends Volume> volumes = api.list().toSet();
|
||||
assertTrue(volumes.isEmpty());
|
||||
}
|
||||
|
||||
public void testListVolumesInDetail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -88,19 +71,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(volumes, ImmutableSet.of(testVolume()));
|
||||
}
|
||||
|
||||
public void testListVolumesInDetailFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
Set<? extends Volume> volumes = api.listInDetail().toSet();
|
||||
assertTrue(volumes.isEmpty());
|
||||
}
|
||||
|
||||
public void testCreateVolume() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -117,23 +87,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(volume, testVolume());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testCreateVolumeFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromStringWithContentType("{\"volume\":{\"display_name\":\"jclouds-test-volume\",\"display_description\":\"description of test volume\",\"size\":1}}", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/volume_details.json")).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.create(1, CreateVolumeOptions.Builder.name("jclouds-test-volume").description("description of test volume"));
|
||||
}
|
||||
|
||||
public void testGetVolume() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -154,18 +107,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(Iterables.getOnlyElement(volume.getAttachments()), testAttachment());
|
||||
}
|
||||
|
||||
public void testGetVolumeFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.get("1"));
|
||||
}
|
||||
|
||||
public void testDeleteVolume() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -178,18 +119,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.delete("1"));
|
||||
}
|
||||
|
||||
public void testDeleteVolumeFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.delete("1"));
|
||||
}
|
||||
|
||||
public void testListSnapshots() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -203,19 +132,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
|
||||
}
|
||||
|
||||
public void testListSnapshotsFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
Set<? extends VolumeSnapshot> snapshots = api.listSnapshots().toSet();
|
||||
assertTrue(snapshots.isEmpty());
|
||||
}
|
||||
|
||||
public void testGetSnapshot() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -229,18 +145,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(snapshot, testSnapshot());
|
||||
}
|
||||
|
||||
public void testGetSnapshotFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.getSnapshot("1"));
|
||||
}
|
||||
|
||||
public void testListSnapshotsInDetail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -263,19 +167,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(snappy.getSize(), 1);
|
||||
}
|
||||
|
||||
public void testListSnapshotsInDetailFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/detail");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
Set<? extends VolumeSnapshot> snapshots = api.listSnapshotsInDetail().toSet();
|
||||
assertTrue(snapshots.isEmpty());
|
||||
}
|
||||
|
||||
public void testCreateSnapshot() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -292,22 +183,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(snapshot, testSnapshot());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testCreateSnapshotFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromStringWithContentType("{\"snapshot\":{\"display_name\":\"jclouds-live-test\",\"volume_id\":\"13\",\"display_description\":\"jclouds live test snapshot\",\"force\":\"true\"}}", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(401).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.createSnapshot("13", CreateVolumeSnapshotOptions.Builder.name("jclouds-live-test").description("jclouds live test snapshot").force());
|
||||
}
|
||||
|
||||
public void testDeleteSnapshot() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
|
@ -320,19 +195,6 @@ public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.deleteSnapshot("1"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testDeleteSnapshotFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1");
|
||||
VolumeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(401).build()
|
||||
).getVolumeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.deleteSnapshot("1");
|
||||
}
|
||||
|
||||
protected Volume testVolume() {
|
||||
return Volume.builder().status(Volume.Status.IN_USE).description("This is a test volume").zone("nova").name("test")
|
||||
.attachments(ImmutableSet.of(testAttachment())).size(1).id("1").created(dateService.iso8601SecondsDateParse("2012-04-23 12:16:45")).build();
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -32,8 +30,6 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.openstack.nova.v2_0.domain.Volume;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
|
||||
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -65,19 +61,6 @@ public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(attachment.getVolumeId(), "1");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testListAttachmentsFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-2/os-volume_attachments");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(401).build()
|
||||
).getVolumeAttachmentApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.listAttachmentsOnServer("instance-2");
|
||||
}
|
||||
|
||||
public void testGetAttachment() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
|
@ -91,18 +74,6 @@ public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(attachment, testAttachment());
|
||||
}
|
||||
|
||||
public void testGetAttachmentFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeAttachmentApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.getAttachmentForVolumeOnServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
public void testAttachVolume() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
|
@ -117,20 +88,6 @@ public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(result, testAttachment());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testAttachVolumeFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("POST")
|
||||
.payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeAttachmentApi("az-1.region-a.geo-1").get();
|
||||
|
||||
api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc");
|
||||
}
|
||||
|
||||
public void testDetachVolume() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
|
@ -143,18 +100,6 @@ public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.detachVolumeFromServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
public void testDetachVolumeFail() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1");
|
||||
VolumeAttachmentApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeAttachmentApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.detachVolumeFromServer("1", "instance-1"));
|
||||
}
|
||||
|
||||
protected Volume testVolume() {
|
||||
return Volume.builder().status(Volume.Status.IN_USE).description("This is a test volume").zone("nova").name("test")
|
||||
.attachments(ImmutableSet.of(testAttachment())).size(1).id("1").created(dateService.iso8601SecondsDateParse("2012-04-23 12:16:45")).build();
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -70,18 +68,6 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(type, testVolumeType());
|
||||
}
|
||||
|
||||
public void testGetVolumeTypeFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.get("8"));
|
||||
}
|
||||
|
||||
public void testCreateVolumeType() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
|
@ -139,18 +125,6 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.delete("8"));
|
||||
}
|
||||
|
||||
public void testDeleteVolumeTypeFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.delete("8"));
|
||||
}
|
||||
|
||||
public void testGetAllExtraSpecs() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
|
@ -163,18 +137,6 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getExtraSpecs("9"), ImmutableMap.of("test", "value1"));
|
||||
}
|
||||
|
||||
public void testGetAllExtraSpecsFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.getExtraSpecs("9").isEmpty());
|
||||
}
|
||||
|
||||
public void testSetAllExtraSpecs() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
|
@ -186,7 +148,7 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.updateExtraSpecs("9", ImmutableMap.of("test1", "somevalue")));
|
||||
api.updateExtraSpecs("9", ImmutableMap.of("test1", "somevalue"));
|
||||
}
|
||||
|
||||
public void testSetExtraSpec() {
|
||||
|
@ -200,7 +162,7 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertTrue(api.updateExtraSpec("5", "test1", "somevalue"));
|
||||
api.updateExtraSpec("5", "test1", "somevalue");
|
||||
}
|
||||
|
||||
public void testGetExtraSpec() {
|
||||
|
@ -215,18 +177,6 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertEquals(api.getExtraSpec("5", "test1"), "another value");
|
||||
}
|
||||
|
||||
public void testGetExtraSpecFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertNull(api.getExtraSpec("5", "test1"));
|
||||
}
|
||||
|
||||
public void testDeleteExtraSpec() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
|
@ -239,18 +189,6 @@ public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
|
|||
assertTrue(api.deleteExtraSpec("5", "test1"));
|
||||
}
|
||||
|
||||
public void testDeleteExtraSpecFailNotFound() {
|
||||
URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1");
|
||||
VolumeTypeApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getVolumeTypeApi("az-1.region-a.geo-1").get();
|
||||
|
||||
assertFalse(api.deleteExtraSpec("5", "test1"));
|
||||
}
|
||||
|
||||
public VolumeType testVolumeType() {
|
||||
return VolumeType.builder().id("8").name("jclouds-test-1").created(dateService.iso8601SecondsDateParse("2012-05-10 12:33:06")).extraSpecs(ImmutableMap.of("test", "value1", "test1", "wibble")).build();
|
||||
}
|
||||
|
|
|
@ -110,14 +110,14 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
|
|||
if (volumeTypeOption.isPresent()) {
|
||||
assertEquals(volumeTypeOption.get().getExtraSpecs(testVolumeType.getId()), ImmutableMap.of("test", "value1"));
|
||||
assertEquals(volumeTypeOption.get().getExtraSpec(testVolumeType.getId(), "test"), "value1");
|
||||
assertTrue(volumeTypeOption.get().updateExtraSpecs(testVolumeType.getId(), ImmutableMap.of("test1", "wibble")));
|
||||
volumeTypeOption.get().updateExtraSpecs(testVolumeType.getId(), ImmutableMap.of("test1", "wibble"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateVolumeType")
|
||||
public void testUpdateIndividualSpec() {
|
||||
if (volumeTypeOption.isPresent()) {
|
||||
assertTrue(volumeTypeOption.get().updateExtraSpec(testVolumeType.getId(), "test1", "freddy"));
|
||||
volumeTypeOption.get().updateExtraSpec(testVolumeType.getId(), "test1", "freddy");
|
||||
assertEquals(volumeTypeOption.get().getExtraSpec(testVolumeType.getId(), "test1"), "freddy");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -56,22 +54,6 @@ public class ExtensionApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseExtensionListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListExtensionsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listExtensions = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getExtensionApi("az-1.region-a.geo-1").list().isEmpty());
|
||||
}
|
||||
|
||||
// TODO: gson deserializer for Multimap
|
||||
public void testGetExtensionByAliasWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest getExtension = HttpRequest.builder()
|
||||
|
@ -91,20 +73,4 @@ public class ExtensionApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseExtensionTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetExtensionByAliasWhenResponseIs404() throws Exception {
|
||||
HttpRequest getExtension = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions/RS-PIE")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/extension_details.json")).build();
|
||||
|
||||
NovaApi apiWhenNoExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getExtension, getExtensionResponse);
|
||||
|
||||
assertNull(apiWhenNoExtensionsExist.getExtensionApi("az-1.region-a.geo-1").get("RS-PIE"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -62,22 +60,6 @@ public class FlavorApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseFlavorListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listFlavors = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getFlavorApi("az-1.region-a.geo-1").list().concat().isEmpty());
|
||||
}
|
||||
|
||||
// TODO: gson deserializer for Multimap
|
||||
public void testGetFlavorWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest getFlavor = HttpRequest.builder()
|
||||
|
@ -98,22 +80,6 @@ public class FlavorApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseFlavorTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetFlavorWhenResponseIs404() throws Exception {
|
||||
HttpRequest getFlavor = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/123")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/flavor_details.json")).build();
|
||||
|
||||
NovaApi apiWhenNoFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getFlavor, getFlavorResponse);
|
||||
|
||||
assertNull(apiWhenNoFlavorsExist.getFlavorApi("az-1.region-a.geo-1").get("123"));
|
||||
}
|
||||
|
||||
public void testCreateFlavor200() throws Exception {
|
||||
ParseCreateFlavorTest parser = new ParseCreateFlavorTest();
|
||||
HttpRequest listFlavors = HttpRequest.builder()
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
package org.jclouds.openstack.nova.v2_0.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -61,22 +58,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseImageListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListImagesWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, list, listResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getImageApi("az-1.region-a.geo-1").list().concat().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetImageWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpRequest getImage = HttpRequest.builder()
|
||||
|
@ -97,22 +78,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
.toString(), new ParseImageTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetImageWhenResponseIs404() throws Exception {
|
||||
HttpRequest getImage = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getImage, getImageResponse);
|
||||
|
||||
assertNull(apiWhenNoImagesExist.getImageApi("az-1.region-a.geo-1").get("52415800-8b69-11e0-9b19-734f5736d2a2"));
|
||||
}
|
||||
|
||||
public void testListMetadataWhenResponseIs2xx() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
HttpRequest getMetadata = HttpRequest.builder()
|
||||
|
@ -132,28 +97,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListMetadataWhenResponseIs404() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
HttpRequest getMetadata = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata")
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getMetadata, getMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getImageApi("az-1.region-a.geo-1").getMetadata(imageId);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetMetadataWhenResponseIs2xx() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
|
@ -180,35 +123,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testSetMetadataWhenResponseIs404() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 1")
|
||||
.put("Image Version", "2.1")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("PUT")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata")
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getImageApi("az-1.region-a.geo-1").setMetadata(imageId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testUpdateMetadataWhenResponseIs2xx() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
|
@ -235,35 +149,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataUpdateTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testUpdateMetadataWhenResponseIs404() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 2")
|
||||
.put("Server Description", "Simple Server")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + imageId + "/metadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/metadata_updated.json")).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getImageApi("az-1.region-a.geo-1").setMetadata(imageId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetMetadataItemWhenResponseIs2xx() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
String key = "Image Version";
|
||||
|
@ -286,27 +171,6 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
"2.5");
|
||||
}
|
||||
|
||||
public void testGetMetadataItemWhenResponseIs404() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
String key = "Image Version";
|
||||
|
||||
HttpRequest getMetadata = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" +
|
||||
Strings2.urlEncode(key))
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json")).build();
|
||||
|
||||
NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getMetadata, getMetadataResponse);
|
||||
|
||||
assertNull(apiWhenImageExists.getImageApi("az-1.region-a.geo-1").getMetadata(imageId, key));
|
||||
}
|
||||
|
||||
public void testSetMetadataItemWhenResponseIs2xx() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
String key = "Image Version";
|
||||
|
@ -349,23 +213,4 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
|
|||
apiWhenImageExists.getImageApi("az-1.region-a.geo-1").deleteMetadata(imageId, key);
|
||||
}
|
||||
|
||||
public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
|
||||
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
|
||||
String key = "Image Version";
|
||||
|
||||
HttpRequest deleteMetadata = HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" +
|
||||
Strings2.urlEncode(key))
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse);
|
||||
|
||||
apiWhenImageExists.getImageApi("az-1.region-a.geo-1").deleteMetadata(imageId, key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.openstack.nova.v2_0.features;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -66,21 +65,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseServerListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListServersWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getServerApi("az-1.region-a.geo-1").list().concat().isEmpty());
|
||||
}
|
||||
|
||||
public void testListInDetailServersWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
|
@ -101,22 +85,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseServerDetailsStatesTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListInDetailServersWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listInDetailServersResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, listServers, listInDetailServersResponse);
|
||||
|
||||
assertTrue(apiWhenNoServersExist.getServerApi("az-1.region-a.geo-1").listInDetail().concat().isEmpty());
|
||||
}
|
||||
|
||||
public void testCreateServerWhenResponseIs202() throws Exception {
|
||||
HttpRequest createServer = HttpRequest.builder()
|
||||
.method("POST")
|
||||
|
@ -228,34 +196,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseCreatedServerTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testCreateServerWithBootVolumeWhenResponseIs404() throws Exception {
|
||||
HttpRequest createServer = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"\",\"flavorRef\":\"12345\",\"block_device_mapping_v2\":[{\"volume_size\":100,\"uuid\":\"f0c907a5-a26b-48ba-b803-83f6b7450ba5\",\"destination_type\":\"volume\",\"source_type\":\"image\"}]}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse createServerResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, createServer, createServerResponse);
|
||||
|
||||
BlockDeviceMapping blockDeviceMapping = BlockDeviceMapping.builder()
|
||||
.uuid("f0c907a5-a26b-48ba-b803-83f6b7450ba5").sourceType("image")
|
||||
.destinationType("volume").volumeSize(100).build();
|
||||
|
||||
try {
|
||||
apiWithNewServer.getServerApi("az-1.region-a.geo-1").create("test-e92", "", "12345", new CreateServerOptions().blockDeviceMappings(ImmutableSet.of(blockDeviceMapping)));
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateServerWithDiskConfigAuto() throws Exception {
|
||||
HttpRequest createServer = HttpRequest.builder()
|
||||
.method("POST")
|
||||
|
@ -347,32 +287,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
imageId);
|
||||
}
|
||||
|
||||
public void testCreateImageWhenResponseIs404IsEmpty() throws Exception {
|
||||
String serverId = "123";
|
||||
String imageName = "foo";
|
||||
|
||||
HttpRequest createImage = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"createImage\":{\"name\":\"" + imageName + "\", \"metadata\": {}}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse createImageResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerDoesNotExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, createImage, createImageResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerDoesNotExist.getServerApi("az-1.region-a.geo-1").createImageFromServer(imageName, serverId);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testStopServerWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest stopServer = HttpRequest.builder()
|
||||
|
@ -392,30 +306,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").stop(serverId);
|
||||
}
|
||||
|
||||
public void testStopServerWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest stopServer = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action")
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"os-stop\":null}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse stopServerResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, stopServer, stopServerResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").stop(serverId);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testStartServerWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest startServer = HttpRequest
|
||||
|
@ -436,30 +326,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").start(serverId);
|
||||
}
|
||||
|
||||
public void testStartServerWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest startServer = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"os-start\":null}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse startServerResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, startServer, startServerResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").start(serverId);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testListMetadataWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest getMetadata = HttpRequest.builder()
|
||||
|
@ -479,28 +345,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListMetadataWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest getMetadata = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata")
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, getMetadata, getMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").getMetadata(serverId);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetMetadataWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
|
@ -527,35 +371,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testSetMetadataWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 1")
|
||||
.put("Image Version", "2.1")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("PUT")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata")
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").setMetadata(serverId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testUpdateMetadataWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
|
@ -582,36 +397,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataUpdateTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testUpdateMetadataWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 2")
|
||||
.put("Server Description", "Simple Server")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/metadata_updated.json")).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").setMetadata(serverId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetMetadataItemWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
String key = "Server Label";
|
||||
|
@ -635,35 +420,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
"Web Head 1");
|
||||
}
|
||||
|
||||
public void testGetMetadataItemWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 1")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/metadata_updated.json")).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").setMetadata(serverId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetMetadataItemWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
|
@ -690,36 +446,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
new ParseMetadataUpdateTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testSetMetadataItemWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 2")
|
||||
.put("Server Description", "Simple Server")
|
||||
.build();
|
||||
|
||||
HttpRequest setMetadata = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/metadata_updated.json")).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, setMetadata, setMetadataResponse);
|
||||
|
||||
try {
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").setMetadata(serverId, metadata);
|
||||
fail("Expected an exception.");
|
||||
} catch (Exception e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception {
|
||||
String serverId = "123";
|
||||
String key = "Server Label";
|
||||
|
@ -740,26 +466,6 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
|
|||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").deleteMetadata(serverId, key);
|
||||
}
|
||||
|
||||
public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
|
||||
String serverId = "123";
|
||||
String key = "Server Label";
|
||||
|
||||
HttpRequest deleteMetadata = HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" +
|
||||
Strings2.urlEncode(key))
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("X-Auth-Token", authToken)
|
||||
.build();
|
||||
|
||||
HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse);
|
||||
|
||||
apiWhenServerExists.getServerApi("az-1.region-a.geo-1").deleteMetadata(serverId, key);
|
||||
}
|
||||
|
||||
public void testGetDiagnosticsWhenResponseIs200() throws Exception {
|
||||
String serverId = "123";
|
||||
HttpRequest getDiagnostics = HttpRequest.builder()
|
||||
|
|
|
@ -310,10 +310,7 @@ public class RegionScopedSwiftBlobStore implements BlobStore {
|
|||
userMetadata = metadata.getMetadata();
|
||||
}
|
||||
|
||||
boolean copied = objectApi.copy(toName, fromContainer, fromName, userMetadata, systemMetadata);
|
||||
if (!copied) {
|
||||
throw new KeyNotFoundException(fromContainer, fromName, "Swift could not find the specified key");
|
||||
}
|
||||
objectApi.copy(toName, fromContainer, fromName, userMetadata, systemMetadata);
|
||||
|
||||
// TODO: Swift copy object *appends* user metadata, does not overwrite
|
||||
return objectApi.getWithoutBody(toName).getETag();
|
||||
|
|
|
@ -73,27 +73,19 @@ public interface AccountApi {
|
|||
* Creates or updates the {@link Account} metadata.
|
||||
*
|
||||
* @param metadata the metadata to create or update.
|
||||
*
|
||||
* @return {@code true} if the metadata was successfully created or updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("account:updateMetadata")
|
||||
@POST
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateMetadata(@BinderParam(BindAccountMetadataToHeaders.class) Map<String, String> metadata);
|
||||
void updateMetadata(@BinderParam(BindAccountMetadataToHeaders.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
* Replaces the temporary URL key for the {@link Account}.
|
||||
*
|
||||
* @param temporaryUrlKey the temporary URL key to update.
|
||||
*
|
||||
* @return {@code true} if the temporary URL key was successfully updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("account:updateTemporaryUrlKey")
|
||||
@POST
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateTemporaryUrlKey(@HeaderParam(ACCOUNT_TEMPORARY_URL_KEY) String temporaryUrlKey);
|
||||
void updateTemporaryUrlKey(@HeaderParam(ACCOUNT_TEMPORARY_URL_KEY) String temporaryUrlKey);
|
||||
|
||||
/**
|
||||
* Deletes metadata from the {@link Account}.
|
||||
|
|
|
@ -150,15 +150,11 @@ public interface ContainerApi {
|
|||
* the container name corresponding to {@link Container#getName()}.
|
||||
* @param options
|
||||
* the container options to update.
|
||||
*
|
||||
* @return {@code true} if the container metadata was successfully created or updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("container:update")
|
||||
@POST
|
||||
@Path("/{containerName}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean update(@PathParam("containerName") String containerName, UpdateContainerOptions options);
|
||||
void update(@PathParam("containerName") String containerName, UpdateContainerOptions options);
|
||||
|
||||
/**
|
||||
* Creates or updates the {@link Container} metadata.
|
||||
|
@ -167,15 +163,11 @@ public interface ContainerApi {
|
|||
* the container name corresponding to {@link Container#getName()}.
|
||||
* @param metadata
|
||||
* the container metadata to create or update.
|
||||
*
|
||||
* @return {@code true} if the container metadata was successfully created or updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("container:updateMetadata")
|
||||
@POST
|
||||
@Path("/{containerName}")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateMetadata(@PathParam("containerName") String containerName,
|
||||
void updateMetadata(@PathParam("containerName") String containerName,
|
||||
@BinderParam(BindContainerMetadataToHeaders.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,8 +37,6 @@ import javax.ws.rs.Produces;
|
|||
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
import org.jclouds.blobstore.BlobStoreFallbacks.FalseOnContainerNotFound;
|
||||
import org.jclouds.blobstore.BlobStoreFallbacks.FalseOnKeyNotFound;
|
||||
import org.jclouds.blobstore.KeyNotFoundException;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.io.Payload;
|
||||
|
@ -198,16 +196,12 @@ public interface ObjectApi {
|
|||
* corresponds to {@link SwiftObject#getName()}.
|
||||
* @param metadata
|
||||
* the metadata to create or update.
|
||||
*
|
||||
* @return {@code true} if the metadata was successfully created or updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("object:updateMetadata")
|
||||
@POST
|
||||
@Path("/{objectName}")
|
||||
@Produces("")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateMetadata(@PathParam("objectName") String objectName,
|
||||
void updateMetadata(@PathParam("objectName") String objectName,
|
||||
@BinderParam(BindObjectMetadataToHeaders.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
|
@ -219,15 +213,12 @@ public interface ObjectApi {
|
|||
* @param metadata
|
||||
* the metadata to create or update.
|
||||
*
|
||||
* @return {@code true} if the metadata was successfully created or updated,
|
||||
* {@code false} if not.
|
||||
*/
|
||||
@Named("object:updateMetadata")
|
||||
@POST
|
||||
@Path("/{objectName}")
|
||||
@Produces("")
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
boolean updateHeaders(@PathParam("objectName") String objectName,
|
||||
void updateHeaders(@PathParam("objectName") String objectName,
|
||||
@BinderParam(BindToHeaders.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
|
@ -273,16 +264,13 @@ public interface ObjectApi {
|
|||
* @param sourceObject
|
||||
* the source object name.
|
||||
*
|
||||
* @return {@code true} if the object was successfully copied, {@code false} if not.
|
||||
*
|
||||
* @throws KeyNotFoundException if the source or destination container do not exist.
|
||||
*/
|
||||
@Named("object:copy")
|
||||
@PUT
|
||||
@Path("/{destinationObject}")
|
||||
@Headers(keys = OBJECT_COPY_FROM, values = "/{sourceContainer}/{sourceObject}")
|
||||
@Fallback(FalseOnContainerNotFound.class)
|
||||
boolean copy(@PathParam("destinationObject") String destinationObject,
|
||||
void copy(@PathParam("destinationObject") String destinationObject,
|
||||
@PathParam("sourceContainer") String sourceContainer,
|
||||
@PathParam("sourceObject") String sourceObject);
|
||||
|
||||
|
@ -303,16 +291,13 @@ public interface ObjectApi {
|
|||
* @param objectMetadata
|
||||
* Unprefixed/unescaped metadata, such as Content-Disposition
|
||||
*
|
||||
* @return {@code true} if the object was successfully copied, {@code false} if not.
|
||||
*
|
||||
* @throws KeyNotFoundException if the source or destination container do not exist.
|
||||
*/
|
||||
@Named("object:copy")
|
||||
@PUT
|
||||
@Path("/{destinationObject}")
|
||||
@Headers(keys = {OBJECT_COPY_FROM, OBJECT_COPY_FRESH_METADATA}, values = {"/{sourceContainer}/{sourceObject}", "True"})
|
||||
@Fallback(FalseOnKeyNotFound.class)
|
||||
boolean copy(@PathParam("destinationObject") String destinationObject,
|
||||
void copy(@PathParam("destinationObject") String destinationObject,
|
||||
@PathParam("sourceContainer") String sourceContainer,
|
||||
@PathParam("sourceObject") String sourceObject,
|
||||
@BinderParam(BindObjectMetadataToHeaders.class) Map<String, String> userMetadata,
|
||||
|
@ -336,16 +321,13 @@ public interface ObjectApi {
|
|||
* @param objectMetadata
|
||||
* Unprefixed/unescaped metadata, such as Content-Disposition
|
||||
*
|
||||
* @return {@code true} if the object was successfully copied, {@code false} if not.
|
||||
*
|
||||
* @throws KeyNotFoundException if the source or destination container do not exist.
|
||||
*/
|
||||
@Named("object:copy")
|
||||
@PUT
|
||||
@Path("/{destinationObject}")
|
||||
@Headers(keys = OBJECT_COPY_FROM, values = "/{sourceContainer}/{sourceObject}")
|
||||
@Fallback(FalseOnKeyNotFound.class)
|
||||
boolean copyAppendMetadata(@PathParam("destinationObject") String destinationObject,
|
||||
void copyAppendMetadata(@PathParam("destinationObject") String destinationObject,
|
||||
@PathParam("sourceContainer") String sourceContainer,
|
||||
@PathParam("sourceObject") String sourceObject,
|
||||
@BinderParam(BindObjectMetadataToHeaders.class) Map<String, String> userMetadata,
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
|
||||
Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
|
||||
|
||||
assertTrue(accountApi.updateMetadata(meta));
|
||||
accountApi.updateMetadata(meta);
|
||||
|
||||
accountHasMetadata(accountApi, meta);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class AccountApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
|
||||
Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
|
||||
|
||||
assertTrue(accountApi.updateMetadata(meta));
|
||||
accountApi.updateMetadata(meta);
|
||||
accountHasMetadata(accountApi, meta);
|
||||
|
||||
assertTrue(accountApi.deleteMetadata(meta));
|
||||
|
|
|
@ -77,7 +77,7 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getAccountApi("DFW").updateMetadata(metadata));
|
||||
api.getAccountApi("DFW").updateMetadata(metadata);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
@ -99,7 +99,7 @@ public class AccountApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getAccountApi("DFW").updateTemporaryUrlKey("foobar"));
|
||||
api.getAccountApi("DFW").updateTemporaryUrlKey("foobar");
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertAuthentication(server);
|
||||
|
|
|
@ -124,7 +124,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
assertEquals(container.getName(), name);
|
||||
assertTrue(container.getMetadata().isEmpty());
|
||||
|
||||
assertNotNull(api.getContainerApi(regionId).update(name, opts));
|
||||
api.getContainerApi(regionId).update(name, opts);
|
||||
|
||||
Container updatedContainer = api.getContainerApi(regionId).get(name);
|
||||
assertNotNull(updatedContainer);
|
||||
|
@ -144,7 +144,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
|
||||
assertThat(containerApi.get(name).getAnybodyRead().get()).isFalse();
|
||||
|
||||
assertThat(containerApi.update(name, new UpdateContainerOptions().anybodyRead())).isTrue();
|
||||
containerApi.update(name, new UpdateContainerOptions().anybodyRead());
|
||||
assertThat(containerApi.get(name).getAnybodyRead().get()).isTrue();
|
||||
|
||||
assertThat(containerApi.deleteIfEmpty(name)).isTrue();
|
||||
|
@ -165,7 +165,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
|
||||
for (String regionId : regions) {
|
||||
ContainerApi containerApi = api.getContainerApi(regionId);
|
||||
assertTrue(containerApi.updateMetadata(name, meta));
|
||||
containerApi.updateMetadata(name, meta);
|
||||
containerHasMetadata(containerApi, name, meta);
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class ContainerApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
for (String regionId : regions) {
|
||||
ContainerApi containerApi = api.getContainerApi(regionId);
|
||||
// update
|
||||
assertTrue(containerApi.updateMetadata(name, meta));
|
||||
containerApi.updateMetadata(name, meta);
|
||||
containerHasMetadata(containerApi, name, meta);
|
||||
// delete
|
||||
assertTrue(containerApi.deleteMetadata(name, meta));
|
||||
|
|
|
@ -259,7 +259,7 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getContainerApi("DFW").updateMetadata("myContainer", metadata));
|
||||
api.getContainerApi("DFW").updateMetadata("myContainer", metadata);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
|
@ -315,25 +315,6 @@ public class ContainerApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
}
|
||||
}
|
||||
|
||||
public void testAlreadyDeleted() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
|
||||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getContainerApi("DFW").deleteIfEmpty("myContainer"));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
RecordedRequest deleteRequest = server.takeRequest();
|
||||
assertEquals(deleteRequest.getRequestLine(),
|
||||
"DELETE /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer HTTP/1.1");
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testDeleteWhenNotEmpty() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
|
|
|
@ -132,7 +132,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
checkObject(object);
|
||||
|
||||
// check the copy operation
|
||||
assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObjectName));
|
||||
destApi.copy(destinationObject, sourceContainer, sourceObjectName);
|
||||
assertNotNull(destApi.get(destinationObject));
|
||||
|
||||
// now get a real SwiftObject
|
||||
|
@ -191,9 +191,9 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
checkObject(object);
|
||||
|
||||
// check the copy append metadata operation
|
||||
assertTrue(destApi.copyAppendMetadata(destinationObject, sourceContainer, sourceObjectName,
|
||||
destApi.copyAppendMetadata(destinationObject, sourceContainer, sourceObjectName,
|
||||
ImmutableMap.<String, String>of("additionalUserMetakey", "additionalUserMetavalue"),
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"updatedname.txt\"")));
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"updatedname.txt\""));
|
||||
|
||||
// now get a real SwiftObject
|
||||
SwiftObject destSwiftObject = destApi.get(destinationObject);
|
||||
|
@ -217,9 +217,9 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
assertEquals(destSwiftObject.getPayload().getContentMetadata().getContentDisposition(), "attachment; filename=\"updatedname.txt\"");
|
||||
|
||||
// check the copy replace metadata operation
|
||||
assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObjectName,
|
||||
destApi.copy(destinationObject, sourceContainer, sourceObjectName,
|
||||
ImmutableMap.<String, String>of("key3", "value3"),
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"updatedname.txt\"")));
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"updatedname.txt\""));
|
||||
|
||||
// now get a real SwiftObject
|
||||
destSwiftObject = destApi.get(destinationObject);
|
||||
|
@ -281,7 +281,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
ObjectApi objectApi = api.getObjectApi(regionId, containerName);
|
||||
|
||||
Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
|
||||
assertTrue(objectApi.updateMetadata(name, meta));
|
||||
objectApi.updateMetadata(name, meta);
|
||||
|
||||
SwiftObject object = objectApi.get(name);
|
||||
for (Entry<String, String> entry : meta.entrySet()) {
|
||||
|
@ -337,7 +337,7 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest<SwiftApi> {
|
|||
|
||||
Map<String, String> meta = ImmutableMap.of("MyDelete1", "foo", "MyDelete2", "bar");
|
||||
|
||||
assertTrue(objectApi.updateMetadata(name, meta));
|
||||
objectApi.updateMetadata(name, meta);
|
||||
assertFalse(objectApi.get(name).getMetadata().isEmpty());
|
||||
|
||||
assertTrue(objectApi.deleteMetadata(name, meta));
|
||||
|
|
|
@ -33,7 +33,6 @@ import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_METAD
|
|||
import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_REMOVE_METADATA_PREFIX;
|
||||
import static org.jclouds.util.Strings2.toStringAndClose;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -363,7 +362,7 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getObjectApi("DFW", "myContainer").updateMetadata("myObject", metadata));
|
||||
api.getObjectApi("DFW", "myContainer").updateMetadata("myObject", metadata);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
|
@ -387,7 +386,7 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getObjectApi("DFW", "myContainer").updateMetadata("myObject", metadata));
|
||||
api.getObjectApi("DFW", "myContainer").updateMetadata("myObject", metadata);
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
|
@ -472,8 +471,7 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
.addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bar/foo.txt")));
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getObjectApi("DFW", "foo")
|
||||
.copy("bar.txt", "bar", "foo.txt"));
|
||||
api.getObjectApi("DFW", "foo").copy("bar.txt", "bar", "foo.txt");
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
|
@ -510,9 +508,9 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertTrue(api.getObjectApi("DFW", "foo")
|
||||
api.getObjectApi("DFW", "foo")
|
||||
.copy("bar.txt", "bar", "foo.txt", ImmutableMap.of("someUserHeader", "someUserMetadataValue"),
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"fname.ext\"")));
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"fname.ext\""));
|
||||
|
||||
assertEquals(server.getRequestCount(), 2);
|
||||
assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
|
||||
|
@ -530,6 +528,7 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = KeyNotFoundException.class)
|
||||
public void testCopyObjectWithMetadataFail() throws Exception {
|
||||
MockWebServer server = mockOpenStackServer();
|
||||
server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
|
||||
|
@ -538,9 +537,9 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
|
|||
|
||||
try {
|
||||
SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
|
||||
assertFalse(api.getObjectApi("DFW", "foo")
|
||||
api.getObjectApi("DFW", "foo")
|
||||
.copy("bar.txt", "bar", "foo.txt", ImmutableMap.of("someUserHeader", "someUserMetadataValue"),
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"fname.ext\"")));
|
||||
ImmutableMap.of("Content-Disposition", "attachment; filename=\"fname.ext\""));
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
|
|
|
@ -55,9 +55,8 @@ public interface DatabaseApi {
|
|||
@POST
|
||||
@Path("/databases")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindCreateDatabaseToJson.class)
|
||||
boolean create(@PayloadParam("database") String database);
|
||||
void create(@PayloadParam("database") String database);
|
||||
|
||||
/**
|
||||
* This operation creates a new database within the specified instance.
|
||||
|
@ -71,9 +70,8 @@ public interface DatabaseApi {
|
|||
@POST
|
||||
@Path("/databases")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindCreateDatabaseToJson.class)
|
||||
boolean create(@PayloadParam("database") String database, @PayloadParam("character_set") String character_set, @PayloadParam("collate") String collate);
|
||||
void create(@PayloadParam("database") String database, @PayloadParam("character_set") String character_set, @PayloadParam("collate") String collate);
|
||||
|
||||
/**
|
||||
* This operation deletes the specified database for the specified database instance.
|
||||
|
|
|
@ -111,7 +111,6 @@ public interface InstanceApi {
|
|||
@Path("/instances/{id}/root")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ResponseParser(ParsePasswordFromRootedInstance.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
String enableRoot(@PathParam("id") String instanceId);
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,9 +69,8 @@ public interface UserApi {
|
|||
@POST
|
||||
@Path("/users")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindCreateUserToJson.class)
|
||||
boolean create(@PayloadParam("users") Set<User> users);
|
||||
void create(@PayloadParam("users") Set<User> users);
|
||||
|
||||
/**
|
||||
* Create a database user by name, password, and database name. Simpler overload for {@link #create(String, Set)}.
|
||||
|
@ -85,9 +84,8 @@ public interface UserApi {
|
|||
@POST
|
||||
@Path("/users")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindCreateUserToJson.class)
|
||||
boolean create(@PayloadParam("name") String userName, @PayloadParam("password") String password, @PayloadParam("databaseName") String databaseName);
|
||||
void create(@PayloadParam("name") String userName, @PayloadParam("password") String password, @PayloadParam("databaseName") String databaseName);
|
||||
|
||||
/**
|
||||
* Create a database user by name, password, and database name. Simpler overload for {@link #create(String, Set)}.
|
||||
|
@ -102,9 +100,8 @@ public interface UserApi {
|
|||
@POST
|
||||
@Path("/users")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindCreateUserToJson.class)
|
||||
boolean create(@PayloadParam("name") String userName, @PayloadParam("password") String password, @PayloadParam("host") String host, @PayloadParam("databaseName") String databaseName);
|
||||
void create(@PayloadParam("name") String userName, @PayloadParam("password") String password, @PayloadParam("host") String host, @PayloadParam("databaseName") String databaseName);
|
||||
|
||||
/**
|
||||
* This operation grants access for the specified user to a database for the specified instance.
|
||||
|
@ -118,9 +115,8 @@ public interface UserApi {
|
|||
@PUT
|
||||
@Path("/users/{name}/databases")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindGrantUserToJson.class)
|
||||
boolean grant(@PathParam("name") String userName, @PayloadParam("databases") List<String> databases);
|
||||
void grant(@PathParam("name") String userName, @PayloadParam("databases") List<String> databases);
|
||||
|
||||
/**
|
||||
* This operation grants access for the specified user to a database for the specified instance. Simpler overload for {@link #create(String, Set)}.
|
||||
|
@ -134,9 +130,8 @@ public interface UserApi {
|
|||
@PUT
|
||||
@Path("/users/{name}/databases")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(FalseOnNotFoundOr404.class)
|
||||
@MapBinder(BindGrantUserToJson.class)
|
||||
boolean grant(@PathParam("name") String userName, @PayloadParam("databaseName") String databaseName);
|
||||
void grant(@PathParam("name") String userName, @PayloadParam("databaseName") String databaseName);
|
||||
|
||||
/**
|
||||
* This operation grants access for the specified user to a database for the specified instance.
|
||||
|
|
|
@ -17,12 +17,10 @@
|
|||
package org.jclouds.openstack.trove.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
|
@ -48,24 +46,7 @@ public class DatabaseApiExpectTest extends BaseTroveApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build() // response
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("testingdb");
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testCreateDatabaseSimpleFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/databases");
|
||||
DatabaseApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/database_create_simple_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("testingdb");
|
||||
assertFalse(result);
|
||||
api.create("testingdb");
|
||||
}
|
||||
|
||||
public void testCreateDatabase() {
|
||||
|
@ -80,24 +61,7 @@ public class DatabaseApiExpectTest extends BaseTroveApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build() // response
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("testingdb", "utf8", "utf8_general_ci");
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testCreateDatabaseFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/databases");
|
||||
DatabaseApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/database_create_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("testingdb", "utf8", "utf8_general_ci");
|
||||
assertFalse(result);
|
||||
api.create("testingdb", "utf8", "utf8_general_ci");
|
||||
}
|
||||
|
||||
public void testDeleteDatabase() {
|
||||
|
@ -115,21 +79,6 @@ public class DatabaseApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testDeleteDatabaseFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/databases/db1");
|
||||
DatabaseApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint)
|
||||
.method("DELETE")
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.delete("db1");
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testListDatabases() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/databases");
|
||||
DatabaseApi api = requestsSendResponses(
|
||||
|
@ -144,16 +93,4 @@ public class DatabaseApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(databases.iterator().next(), "anotherdb");
|
||||
}
|
||||
|
||||
public void testListDatabasesFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/databases");
|
||||
DatabaseApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/database_list.json")).build()
|
||||
).getDatabaseApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
Set<String> databases = api.list().toSet();
|
||||
assertTrue(databases.isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class DatabaseApiLiveTest extends BaseTroveApiLiveTest {
|
|||
assertNotNull(database);
|
||||
assertTrue(database.equals("livetest_db1") || database.equals("livetest_db2") || database.equals("livetest_db3") );
|
||||
assertTrue(databaseApi.delete(database));
|
||||
assertTrue(databaseApi.create(database));
|
||||
databaseApi.create(database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.jclouds.openstack.trove.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
@ -49,19 +47,6 @@ public class FlavorApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(flavors.iterator().next().getRam(), 512);
|
||||
}
|
||||
|
||||
public void testListFlavorsFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/flavors");
|
||||
FlavorApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getFlavorApi("RegionOne");
|
||||
|
||||
Set<? extends Flavor> flavors = api.list().toSet();
|
||||
assertTrue(flavors.isEmpty());
|
||||
}
|
||||
|
||||
public void testGetFlavor() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/flavors/1");
|
||||
FlavorApi api = requestsSendResponses(
|
||||
|
@ -79,31 +64,20 @@ public class FlavorApiExpectTest extends BaseTroveApiExpectTest {
|
|||
}
|
||||
|
||||
public void testGetFlavorByAccountId() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/flavors/40806637803162");
|
||||
TroveApi troveApi = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/flavor_list.json")).build() );
|
||||
FlavorApi api = troveApi.getFlavorApi("RegionOne");
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/flavors/40806637803162");
|
||||
TroveApi troveApi = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/flavor_list.json")).build() );
|
||||
FlavorApi api = troveApi.getFlavorApi("RegionOne");
|
||||
|
||||
Set<? extends Flavor> flavors = api.list(troveApi.getCurrentTenantId().get().getId() ).toSet();
|
||||
Flavor flavor = flavors.iterator().next();
|
||||
assertEquals(flavor.getName(), "512MB Instance");
|
||||
assertEquals(flavor.getId(), 1);
|
||||
assertEquals(flavor.getRam(), 512);
|
||||
assertEquals(flavor.getLinks().size(), 2);
|
||||
}
|
||||
|
||||
public void testGetFlavorFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/flavors/12312");
|
||||
FlavorApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getFlavorApi("RegionOne");
|
||||
|
||||
assertNull(api.get(12312));
|
||||
Set<? extends Flavor> flavors = api.list(troveApi.getCurrentTenantId().get().getId() ).toSet();
|
||||
Flavor flavor = flavors.iterator().next();
|
||||
assertEquals(flavor.getName(), "512MB Instance");
|
||||
assertEquals(flavor.getId(), 1);
|
||||
assertEquals(flavor.getRam(), 512);
|
||||
assertEquals(flavor.getLinks().size(), 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,15 +17,16 @@
|
|||
package org.jclouds.openstack.trove.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.trove.v1.domain.Instance;
|
||||
import org.jclouds.openstack.trove.v1.internal.BaseTroveApiExpectTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -51,22 +52,6 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(instance.getName(), "json_rack_instance");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testCreateInstanceFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/instance_create_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/instance_create.json")).build() // response
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
api.create("1", 2, "json_rack_instance");
|
||||
}
|
||||
|
||||
public void testDeleteInstance() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/098653ba-218b-47ce-936a-e0b749101f81");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
|
@ -79,19 +64,6 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertTrue( api.delete("098653ba-218b-47ce-936a-e0b749101f81") );
|
||||
}
|
||||
|
||||
public void testDeleteInstanceFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/098653ba-218b-47ce-936a-e0b749101f81");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
assertTrue( !api.delete("098653ba-218b-47ce-936a-e0b749101f81") );
|
||||
}
|
||||
|
||||
|
||||
public void testListInstances() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
|
@ -106,19 +78,6 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(instances.iterator().next().getSize(), 2);
|
||||
}
|
||||
|
||||
public void testListInstancesFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
Set<? extends Instance> instances = api.list().toSet();
|
||||
assertTrue(instances.isEmpty());
|
||||
}
|
||||
|
||||
public void testGetInstance() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
|
@ -135,18 +94,6 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(instance.getHostname(), "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com");
|
||||
}
|
||||
|
||||
public void testGetInstanceFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/12312");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).build()
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
assertNull(api.get("12312"));
|
||||
}
|
||||
|
||||
public void testEnableRootOnInstance() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7/root");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
|
@ -160,19 +107,6 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(password, "12345");
|
||||
}
|
||||
|
||||
public void testEnableRootOnInstanceFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7/root");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().method("POST").endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/instance_root.json")).build()
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
String password = api.enableRoot("44b277eb-39be-4921-be31-3d61b43651d7");
|
||||
assertEquals(password, null);
|
||||
}
|
||||
|
||||
public void testIsRootInstance() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7/root");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
|
@ -199,17 +133,4 @@ public class InstanceApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(rooted.booleanValue(), false);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testIsRootInstanceFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7/root");
|
||||
InstanceApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/instance_is_rooted.json")).build()
|
||||
).getInstanceApi("RegionOne");
|
||||
|
||||
Boolean rooted = api.isRooted("44b277eb-39be-4921-be31-3d61b43651d7");
|
||||
assertNull(rooted);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
package org.jclouds.openstack.trove.v1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
@ -30,6 +28,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.trove.v1.domain.User;
|
||||
import org.jclouds.openstack.trove.v1.internal.BaseTroveApiExpectTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.collections.Lists;
|
||||
|
||||
|
@ -55,26 +54,9 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("dbuser1", "password", "databaseA");
|
||||
assertTrue(result);
|
||||
api.create("dbuser1", "password", "databaseA");
|
||||
}
|
||||
|
||||
public void testCreateUserSimpleFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/user_create_simple_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("dbuser1", "password", "databaseA");
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testCreateUserSimpleWithHost() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -87,26 +69,9 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("dbuser1", "password", "192.168.64.64", "databaseA");
|
||||
assertTrue(result);
|
||||
api.create("dbuser1", "password", "192.168.64.64", "databaseA");
|
||||
}
|
||||
|
||||
public void testCreateUserSimpleWithHostFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("POST")
|
||||
.payload(payloadFromResourceWithContentType("/user_create_with_host_simple_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.create("dbuser1", "password", "192.168.64.64", "databaseA");
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testCreateUser() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -135,10 +100,10 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
users.add(user2);
|
||||
users.add(user3);
|
||||
|
||||
boolean result = api.create(ImmutableSortedSet.<User>naturalOrder().addAll(users).build());
|
||||
assertTrue(result);
|
||||
api.create(ImmutableSortedSet.<User>naturalOrder().addAll(users).build());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testCreateUserFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -167,8 +132,7 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
users.add(user2);
|
||||
users.add(user3);
|
||||
|
||||
boolean result = api.create( ImmutableSortedSet.<User>naturalOrder().addAll(users).build());
|
||||
assertFalse(result);
|
||||
api.create( ImmutableSortedSet.<User>naturalOrder().addAll(users).build());
|
||||
}
|
||||
|
||||
public void testGrantUserSimple() {
|
||||
|
@ -183,24 +147,7 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
HttpResponse.builder().statusCode(202).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.grant("dbuser1", "databaseZ");
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testGrantUserSimpleFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("PUT")
|
||||
.payload(payloadFromResourceWithContentType("/user_grant_simple_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
boolean result = api.grant("dbuser1", "databaseZ");
|
||||
assertFalse(result);
|
||||
api.grant("dbuser1", "databaseZ");
|
||||
}
|
||||
|
||||
public void testGrantUser() {
|
||||
|
@ -219,30 +166,9 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
databases.add( "databaseC" );
|
||||
databases.add( "databaseD" );
|
||||
|
||||
boolean result = api.grant("dbuser1", databases);
|
||||
assertTrue(result);
|
||||
api.grant("dbuser1", databases);
|
||||
}
|
||||
|
||||
public void testGrantUserFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("PUT")
|
||||
.payload(payloadFromResourceWithContentType("/user_grant_request.json", MediaType.APPLICATION_JSON))
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
List<String> databases = Lists.newArrayList();
|
||||
databases.add( "databaseC" );
|
||||
databases.add( "databaseD" );
|
||||
|
||||
boolean result = api.grant("dbuser1", databases);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testRevokeUser() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases/databaseA");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -261,24 +187,6 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testRevokeUserFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases/databaseA");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("DELETE")
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
Set<String> databases = Sets.newHashSet();
|
||||
databases.add( "database" );
|
||||
databases.add( "database" );
|
||||
boolean result = api.revoke("dbuser1", "databaseA");
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testDeleteUser() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -297,24 +205,6 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertTrue(result);
|
||||
}
|
||||
|
||||
public void testDeleteUserFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint) // bad naming convention, you should not be able to change the method to POST
|
||||
.method("DELETE")
|
||||
.build(),
|
||||
HttpResponse.builder().statusCode(404).build() // response
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
Set<String> databases = Sets.newHashSet();
|
||||
databases.add( "database" );
|
||||
databases.add( "database" );
|
||||
boolean result = api.delete("dbuser1");
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
public void testListUsers() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -330,19 +220,6 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(users.iterator().next().getName(), "dbuser1");
|
||||
}
|
||||
|
||||
public void testListUsersFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/trove_user_list.json")).build()
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
Set<User> users = api.list().toSet();
|
||||
assertTrue(users.isEmpty());
|
||||
}
|
||||
|
||||
public void testUserGetDatabaseList() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -357,19 +234,6 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(databases.iterator().next(), "databaseA");
|
||||
}
|
||||
|
||||
public void testUserGetDatabaseListFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/dbuser1/databases");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/user_list_access.json")).build()
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
Set<String> databases = api.getDatabaseList("dbuser1").toSet();
|
||||
assertTrue(databases.isEmpty());
|
||||
}
|
||||
|
||||
public void testGetUser() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/exampleuser");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -386,19 +250,6 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(user.getDatabases().iterator().next(), "databaseA");
|
||||
}
|
||||
|
||||
public void testGetUserFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/exampleuser");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/user_get.json")).build()
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
User user = api.get("exampleuser");
|
||||
assertNull(user);
|
||||
}
|
||||
|
||||
public void testGetUserWithHostname() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/example%2euser%40192%2e168%2e64%2e64");
|
||||
UserApi api = requestsSendResponses(
|
||||
|
@ -416,16 +267,4 @@ public class UserApiExpectTest extends BaseTroveApiExpectTest {
|
|||
assertEquals(user.getDatabases().iterator().next(), "databaseA");
|
||||
}
|
||||
|
||||
public void testGetUserWithHostnameFail() {
|
||||
URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/instanceId-1234-5678/users/example%2euser%40192%2e168%2e64%2e64");
|
||||
UserApi api = requestsSendResponses(
|
||||
keystoneAuthWithUsernameAndPasswordAndTenantName,
|
||||
responseWithKeystoneAccess,
|
||||
authenticatedGET().endpoint(endpoint).build(),
|
||||
HttpResponse.builder().statusCode(404).payload(payloadFromResource("/user_get_withhost.json")).build()
|
||||
).getUserApi("RegionOne", "instanceId-1234-5678");
|
||||
|
||||
User user = api.get("example.user", "192.168.64.64");
|
||||
assertNull(user);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue