mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[AWS|Signature] fix handling of repeated slashes
This commit is contained in:
parent
f92c7d2326
commit
02a009bf64
2 changed files with 13 additions and 1 deletions
|
@ -79,7 +79,7 @@ DATA
|
|||
protected
|
||||
|
||||
def canonical_path(path)
|
||||
components = path.split('/')
|
||||
components = path.split(%r{/+}, -1)
|
||||
path = components.inject([]) do |acc, component|
|
||||
case component
|
||||
when '.' #canonicalize by removing .
|
||||
|
|
|
@ -50,6 +50,18 @@ Shindo.tests('AWS | signaturev4', ['aws']) do
|
|||
end
|
||||
end
|
||||
|
||||
tests('get with repeated / ') do
|
||||
returns(@signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '//'}, @now)) do
|
||||
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470'
|
||||
end
|
||||
end
|
||||
|
||||
tests('get with repeated trailing / ') do
|
||||
returns(@signer.sign({:query => {}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '//foo//'}, @now)) do
|
||||
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b00392262853cfe3201e47ccf945601079e9b8a7f51ee4c3d9ee4f187aa9bf19'
|
||||
end
|
||||
end
|
||||
|
||||
tests('get signature as components') do
|
||||
returns(@signer.signature_parameters({:query => {'a' => 'foo', 'b' => 'foo'}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/'}, @now)) do
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue