You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2018/05/22 05:24:12 UTC
[1/2] jclouds git commit: JCLOUDS-1263: URL encode object names from
list object response before creating URIs with them
Repository: jclouds
Updated Branches:
refs/heads/2.1.x d47c776cf -> d464e8a37
JCLOUDS-1263: URL encode object names from list object response before creating URIs with them
This fix calls urlEncode on the path before appending them to the existing path, as the core UriBuilder
class expects them to be URL-encoded.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/4288c9eb
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/4288c9eb
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/4288c9eb
Branch: refs/heads/2.1.x
Commit: 4288c9eb7f3d920eb24af8da006b8c32f1cff703
Parents: d47c776
Author: Mat Mannion <m....@warwick.ac.uk>
Authored: Mon Apr 3 14:49:22 2017 +0100
Committer: Andrew Gaul <ga...@apache.org>
Committed: Mon May 21 22:22:56 2018 -0700
----------------------------------------------------------------------
.../swift/v1/functions/ParseObjectListFromResponse.java | 2 +-
.../jclouds/openstack/swift/v1/features/ObjectApiMockTest.java | 4 ++--
apis/openstack-swift/src/test/resources/object_list.json | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4288c9eb/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
----------------------------------------------------------------------
diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
index a31fe85..38c9100 100644
--- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
+++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/ParseObjectListFromResponse.java
@@ -87,7 +87,7 @@ public class ParseObjectListFromResponse implements Function<HttpResponse, Objec
public SwiftObject apply(InternalObject input) {
if (input.subdir != null) {
return SwiftObject.builder()
- .uri(uriBuilder(containerUri).clearQuery().appendPath(input.subdir).build())
+ .uri(uriBuilder(containerUri).clearQuery().appendPath(urlEncode(input.subdir)).build())
.name(input.subdir)
.etag(SUBDIR_ETAG)
.payload(payload(input.bytes, input.hash, "application/directory", input.expires))
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4288c9eb/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
index 7b6ae32..da0de45 100644
--- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
+++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java
@@ -91,8 +91,8 @@ public class ObjectApiMockTest extends BaseOpenStackMockTest<SwiftApi> {
.payload(payload(64L, "application/octet-stream", null))
.lastModified(dates.iso8601DateParse("2009-02-03T05:26:32.612278")).build(),
SwiftObject.builder()
- .name("test obj 3")
- .uri(URI.create(baseUri + "/test%20obj%203"))
+ .name("test obj 3 %$.")
+ .uri(URI.create(baseUri + "/test%20obj%203%20%25%24."))
.etag("0b2e80bd0744d9ebb20484149a57c82e")
.payload(payload(14, "application/octet-stream", new Date()))
.lastModified(dates.iso8601DateParse("2014-05-20T05:26:32.612278")).build());
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4288c9eb/apis/openstack-swift/src/test/resources/object_list.json
----------------------------------------------------------------------
diff --git a/apis/openstack-swift/src/test/resources/object_list.json b/apis/openstack-swift/src/test/resources/object_list.json
index afe8c77..0deab8c 100644
--- a/apis/openstack-swift/src/test/resources/object_list.json
+++ b/apis/openstack-swift/src/test/resources/object_list.json
@@ -14,7 +14,7 @@
"last_modified": "2009-02-03T05:26:32.612278"
},
{
- "name": "test obj 3",
+ "name": "test obj 3 %$.",
"hash": "0b2e80bd0744d9ebb20484149a57c82e",
"bytes": 123,
"content_type": "application/octet-stream",
[2/2] jclouds git commit: JCLOUDS-1263: Add live integration test for
manipulating objects through the Swift ObjectApi with unicode characters in
their path
Posted by ga...@apache.org.
JCLOUDS-1263: Add live integration test for manipulating objects through the Swift ObjectApi with unicode characters in their path
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/d464e8a3
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/d464e8a3
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/d464e8a3
Branch: refs/heads/2.1.x
Commit: d464e8a3704a780f7bec4873bce905413f987faa
Parents: 4288c9e
Author: Mat Mannion <m....@warwick.ac.uk>
Authored: Tue Apr 4 13:52:26 2017 +0100
Committer: Andrew Gaul <ga...@apache.org>
Committed: Mon May 21 22:23:04 2018 -0700
----------------------------------------------------------------------
.../swift/v1/features/ObjectApiLiveTest.java | 35 +++++++++++++++-----
1 file changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/d464e8a3/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
index 98a546e..02116f6 100644
--- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
+++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java
@@ -61,21 +61,40 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest {
private String containerName = getClass().getSimpleName() + "Container";
static final Payload PAYLOAD = newByteSourcePayload(ByteSource.wrap("swifty".getBytes()));
+ protected void assertCanCreateReadUpdateDeleteList(String regionId, String containerName, String objectName) throws Exception {
+ assertNotNull(getApi().getContainerApi(regionId).create(containerName));
+ assertNotNull(getApi().getObjectApi(regionId, containerName).put(objectName, PAYLOAD));
+
+ SwiftObject object = getApi().getObjectApi(regionId, containerName).get(objectName);
+ assertEquals(object.getName(), objectName);
+ checkObject(object);
+ assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
+
+ String lexicographicallyBeforeName = objectName.substring(0, objectName.length() - 1);
+ object = getApi().getObjectApi(regionId, containerName)
+ .list(marker(lexicographicallyBeforeName)).get(0);
+ assertEquals(object.getName(), objectName);
+ checkObject(object);
+
+ getApi().getObjectApi(regionId, containerName).delete(objectName);
+ getApi().getContainerApi(regionId).deleteIfEmpty(containerName);
+ }
+
public void testCreateWithSpacesAndSpecialCharacters() throws Exception {
final String containerName = "container # ! special";
final String objectName = "object # ! special";
for (String regionId : regions) {
- assertNotNull(getApi().getContainerApi(regionId).create(containerName));
- assertNotNull(getApi().getObjectApi(regionId, containerName).put(objectName, PAYLOAD));
+ assertCanCreateReadUpdateDeleteList(regionId, containerName, objectName);
+ }
+ }
- SwiftObject object = getApi().getObjectApi(regionId, containerName).get(objectName);
- assertEquals(object.getName(), objectName);
- checkObject(object);
- assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
+ public void testCreateAndListWithUnicodeCharacters() throws Exception {
+ final String containerName = "container-unic₪de";
+ final String objectName = "object-unic₪de";
- getApi().getObjectApi(regionId, containerName).delete(objectName);
- getApi().getContainerApi(regionId).deleteIfEmpty(containerName);
+ for (String regionId : regions) {
+ assertCanCreateReadUpdateDeleteList(regionId, containerName, objectName);
}
}