Resolve double encoding of path parameters (#361)
This commit is contained in:
Родитель
6068568091
Коммит
5ae932801d
|
@ -28,8 +28,8 @@ describe Azure::Blob::BlobService do
|
|||
subject.create_container container_name
|
||||
}
|
||||
|
||||
it 'creates a page blob' do
|
||||
blob = subject.create_page_blob container_name, blob_name, length
|
||||
it 'creates page blob with non uri encoded path' do
|
||||
blob = subject.create_page_blob container_name, 'фбаф.jpg', length
|
||||
blob.name.must_equal blob_name
|
||||
end
|
||||
|
||||
|
@ -80,4 +80,28 @@ describe Azure::Blob::BlobService do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create block blob' do
|
||||
let(:container_name) { 'testcontainer' }
|
||||
|
||||
before do
|
||||
subject.create_container container_name
|
||||
end
|
||||
|
||||
after do
|
||||
subject.delete_container container_name
|
||||
end
|
||||
|
||||
it 'should create a block blob with spaces in name' do
|
||||
blob_name = 'blob with spaces'
|
||||
blob = subject.create_block_blob container_name, blob_name, 'content'
|
||||
blob.name.must_equal blob_name
|
||||
end
|
||||
|
||||
it 'should create block blob with complex in name' do
|
||||
blob_name = 'with фбаф.txt'
|
||||
blob = subject.create_block_blob container_name, blob_name, 'content'
|
||||
blob.name.must_equal blob_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -244,61 +244,4 @@ describe Azure::Service::StorageService do
|
|||
headers['x-ms-meta-Foo'].must_equal 'Bar'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#generate_uri' do
|
||||
it 'returns a URI instance' do
|
||||
subject.generate_uri.must_be_kind_of ::URI
|
||||
end
|
||||
|
||||
describe 'when called with no arguments' do
|
||||
it 'returns the StorageService host URL' do
|
||||
subject.generate_uri.to_s.must_equal 'http://dumyhost.uri/'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when passed an optional path' do
|
||||
it 'adds the path to the host url' do
|
||||
subject.generate_uri('resource/entity/').path.must_equal '/resource/entity/'
|
||||
end
|
||||
|
||||
it 'correctly joins the path if the host url contained a path' do
|
||||
subject.host = 'http://dummy.uri/host/path'
|
||||
subject.generate_uri('resource/entity/').path.must_equal '/host/path/resource/entity/'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when passed non uri encoded path' do
|
||||
it 'correctly generates encoded uri' do
|
||||
non_uri_encoded_path = 'host/path/фбаф.jpg'
|
||||
subject.generate_uri(non_uri_encoded_path).to_s.must_equal 'http://dumyhost.uri/host/path/%D1%84%D0%B1%D0%B0%D1%84.jpg'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when passed an Hash of query parameters' do
|
||||
|
||||
it 'encodes the keys' do
|
||||
subject.generate_uri('', {'key !' => 'value'}).query.must_include 'key+%21=value'
|
||||
end
|
||||
|
||||
it 'encodes the values' do
|
||||
subject.generate_uri('', {'key' => 'value !'}).query.must_include 'key=value+%21'
|
||||
end
|
||||
|
||||
it 'sets the query string to the encoded result' do
|
||||
subject.generate_uri('', {'key' => 'value !', 'key !' => 'value'}).query.must_equal 'key=value+%21&key+%21=value'
|
||||
end
|
||||
|
||||
describe 'when the query parameters include a timeout key' do
|
||||
it 'overrides the default timeout' do
|
||||
subject.generate_uri('', {'timeout' => 45}).query.must_equal 'timeout=45'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when the query parameters are nil' do
|
||||
it 'does not include any query parameters' do
|
||||
subject.generate_uri('', nil).query.must_equal nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче