JCLOUDS-217: Nova: do encode form parameters.

OpenStack Nova tests should not pre-encode parameters before passing
them to generate the HTTP requests, as they end up encoded twice.
This commit is contained in:
Timur Alperovich 2015-08-26 09:22:25 -07:00
parent 9b15fdfde8
commit f7370d2b12
2 changed files with 22 additions and 13 deletions

View File

@ -29,6 +29,7 @@ import org.jclouds.openstack.nova.v2_0.parse.ParseImageListTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseImageTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataListTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataUpdateTest;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@ -265,11 +266,12 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
public void testGetMetadataItemWhenResponseIs2xx() throws Exception {
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
String key = "Image%20Version";
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/" + key)
.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();
@ -286,11 +288,12 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
public void testGetMetadataItemWhenResponseIs404() throws Exception {
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
String key = "Image%20Version";
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/" + key)
.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();
@ -328,11 +331,12 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception {
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
String key = "Image%20Version";
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/" + key)
.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();
@ -347,11 +351,12 @@ public class ImageApiExpectTest extends BaseNovaApiExpectTest {
public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
String key = "Image%20Version";
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/" + key)
.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();

View File

@ -34,6 +34,7 @@ import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataUpdateTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseServerDetailsStatesTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseServerDiagnostics;
import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
@ -618,7 +619,8 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
HttpRequest getMetadata = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" + "Server%20Label")
.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();
@ -720,11 +722,12 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception {
String serverId = "123";
String key = "Server%20Label";
String key = "Server Label";
HttpRequest updateMetadata = HttpRequest.builder()
.method("DELETE")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" + key)
.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();
@ -739,11 +742,12 @@ public class ServerApiExpectTest extends BaseNovaApiExpectTest {
public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
String serverId = "123";
String key = "Server%20Label";
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/" + key)
.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();