spec/unit/client_spec.rb in duracloud-client-0.1.4 vs spec/unit/client_spec.rb in duracloud-client-0.1.5
- old
+ new
@@ -109,10 +109,15 @@
specify {
stub = stub_request(:get, "https://example.com/durastore/foo/bar")
subject.get_content("foo", "bar")
expect(stub).to have_been_requested
}
+ it "escapes percent signs in the content id" do
+ stub = stub_request(:get, "https://example.com/durastore/foo/z/z/bar%252Fbaz")
+ subject.get_content("foo", "z/z/bar%2Fbaz")
+ expect(stub).to have_been_requested
+ end
specify {
stub = stub_request(:get, "https://example.com/durastore/foo/bar")
.with(query: {storeID: 1})
subject.get_content("foo", "bar", storeID: 1)
expect(stub).to have_been_requested
@@ -123,10 +128,15 @@
specify {
stub = stub_request(:head, "https://example.com/durastore/foo/bar")
subject.get_content_properties("foo", "bar")
expect(stub).to have_been_requested
}
+ it "escapes percent signs in the content id" do
+ stub = stub_request(:head, "https://example.com/durastore/foo/z/z/bar%252Fbaz")
+ subject.get_content_properties("foo", "z/z/bar%2Fbaz")
+ expect(stub).to have_been_requested
+ end
specify {
stub = stub_request(:head, "https://example.com/durastore/foo/bar")
.with(query: {storeID: 1})
subject.get_content_properties("foo", "bar", storeID: 1)
expect(stub).to have_been_requested
@@ -139,10 +149,17 @@
.with(headers: {'x-dura-meta-owner'=>'testuser'})
subject.set_content_properties("foo", "bar",
headers: {'x-dura-meta-owner'=>'testuser'})
expect(stub).to have_been_requested
}
+ it "escapes percent signs in the content id" do
+ stub = stub_request(:post, "https://example.com/durastore/foo/z/z/bar%252Fbaz")
+ .with(headers: {'x-dura-meta-owner'=>'testuser'})
+ subject.set_content_properties("foo", "z/z/bar%2Fbaz",
+ headers: {'x-dura-meta-owner'=>'testuser'})
+ expect(stub).to have_been_requested
+ end
specify {
stub = stub_request(:post, "https://example.com/durastore/foo/bar")
.with(headers: {'x-dura-meta-owner'=>'testuser'},
query: {storeID: 1})
subject.set_content_properties("foo", "bar",
@@ -166,10 +183,25 @@
'Content-Type'=>'text/plain',
'Content-MD5'=>'8bb2564936980e92ceec8a5759ec34a8'
})
expect(stub).to have_been_requested
}
+ it "escapes percent signs in the content id" do
+ stub = stub_request(:put, "https://example.com/durastore/foo/z/z/bar%252Fbaz")
+ .with(body: "File content",
+ headers: {
+ 'Content-Type'=>'text/plain',
+ 'Content-MD5'=>'8bb2564936980e92ceec8a5759ec34a8'
+ })
+ subject.store_content("foo", "z/z/bar%2Fbaz",
+ body: "File content",
+ headers: {
+ 'Content-Type'=>'text/plain',
+ 'Content-MD5'=>'8bb2564936980e92ceec8a5759ec34a8'
+ })
+ expect(stub).to have_been_requested
+ end
specify {
stub = stub_request(:put, "https://example.com/durastore/foo/bar")
.with(body: "File content",
headers: {
'Content-Type'=>'text/plain',
@@ -191,9 +223,14 @@
specify {
stub = stub_request(:delete, "https://example.com/durastore/foo/bar")
subject.delete_content("foo", "bar")
expect(stub).to have_been_requested
}
+ it "escapes percent signs in the content id" do
+ stub = stub_request(:delete, "https://example.com/durastore/foo/z/z/bar%252Fbaz")
+ subject.delete_content("foo", "z/z/bar%2Fbaz")
+ expect(stub).to have_been_requested
+ end
specify {
stub = stub_request(:delete, "https://example.com/durastore/foo/bar")
.with(query: {storeID: 1})
subject.delete_content("foo", "bar", storeID: 1)
expect(stub).to have_been_requested