awsraw 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,7 +57,12 @@ module AWSRaw
57
57
 
58
58
  def canonicalized_resource(request)
59
59
  # TODO: Should also append the sub-resource.
60
- request.path
60
+ if request.host =~ /^(.+)\.s3\.amazonaws\.com/
61
+ bucket = request.host.split(/\./).first
62
+ '/' + bucket + request.path
63
+ else
64
+ request.path
65
+ end
61
66
  end
62
67
 
63
68
  end
@@ -1,3 +1,3 @@
1
1
  module Awsraw
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -24,6 +24,22 @@ describe AWSRaw::S3::QueryStringSigner do
24
24
  "http://s3.amazonaws.com/johnsmith/photos/puppy.jpg?AWSAccessKeyId=#{access_key_id}&Expires=#{expiry}&Signature=NpgCjnDzrM%2BWFzoENXmpNDUsSn8%3D"
25
25
  end
26
26
 
27
+ it "signs a get request to a non-us-east bucket" do
28
+ url = "http://johnsmith.s3.amazonaws.com/photos/puppy.jpg"
29
+ expiry = 1175139620
30
+
31
+ subject.string_to_sign(url, expiry).should ==
32
+ "GET\n\n\n#{expiry}\n/johnsmith/photos/puppy.jpg"
33
+
34
+ subject.query_string_hash(url, expiry).should == {
35
+ "AWSAccessKeyId" => access_key_id,
36
+ "Expires" => expiry.to_s,
37
+ "Signature" => "NpgCjnDzrM%2BWFzoENXmpNDUsSn8%3D"
38
+ }
39
+
40
+ subject.sign_with_query_string(url, expiry).to_s.should ==
41
+ "http://johnsmith.s3.amazonaws.com/photos/puppy.jpg?AWSAccessKeyId=#{access_key_id}&Expires=#{expiry}&Signature=NpgCjnDzrM%2BWFzoENXmpNDUsSn8%3D"
42
+ end
27
43
  end
28
44
  end
29
45
 
@@ -10,6 +10,7 @@ describe AWSRaw::S3::Signer do
10
10
  it "signs a get request correctly" do
11
11
  request = stub(
12
12
  :method => "GET",
13
+ :host => "s3.amazonaws.com",
13
14
  :path => "/johnsmith/photos/puppy.jpg",
14
15
  :headers => { "Date" => "Tue, 27 Mar 2007 19:36:42 +0000" }
15
16
  )
@@ -23,6 +24,7 @@ describe AWSRaw::S3::Signer do
23
24
  it "signs an upload correctly" do
24
25
  request = stub(
25
26
  :method => "PUT",
27
+ :host => "s3.amazonaws.com",
26
28
  :path => "/static.johnsmith.net/db-backup.dat.gz",
27
29
  :headers => {
28
30
  "User-Agent" => "curl/7.15.5",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-08 00:00:00.000000000 Z
14
+ date: 2013-04-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -87,12 +87,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
+ segments:
91
+ - 0
92
+ hash: -2102654929379621144
90
93
  required_rubygems_version: !ruby/object:Gem::Requirement
91
94
  none: false
92
95
  requirements:
93
96
  - - ! '>='
94
97
  - !ruby/object:Gem::Version
95
98
  version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -2102654929379621144
96
102
  requirements: []
97
103
  rubyforge_project: awsraw
98
104
  rubygems_version: 1.8.23