awsraw 1.0.0.alpha.2 → 1.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64214884680bff94ead6d97622548ca2b2220696
4
- data.tar.gz: fb9def9e60782f6a8fcea2925cffffb87df7aa87
3
+ metadata.gz: 27534ba6f94fa8bd5456bc693dc5505bcf30840e
4
+ data.tar.gz: cacd2d4029079c1c2a71b611d050ff00d5d878ea
5
5
  SHA512:
6
- metadata.gz: efd7197aad5e071fb3706845c324230891b80d736be0fb9eaebe9989a9faf3563abb064f237853c0b6371e99996d4ba0be30b2a63c9bd0abe0f556cd439e84b5
7
- data.tar.gz: c460f8556b43325d1355f71aad38fa870122e9d19aa41193e6c9f51808ac09871faf587346676c22c04b1b05e1f485c8dae0176d0bc04a7379f813e3d01da1c1
6
+ metadata.gz: eccdf2a5654dc5fdaf984a2745bc39e5795177e23ff19bc6bda8108d792dfe648c2d854aec9fbb4e3ba233a045ebcbf3e842700a7cdd6766baeb33b780a6bf78
7
+ data.tar.gz: 8e4ab1687c3445a1289acb7540ca576243a37e127328fb9150d73ddebdafa066b01a8bf6648e11649db2f85d8d6b3756be83af65616dd0d35197adb53a34160b
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
1
+ /*.gem
2
+ /.bundle
3
+ /Gemfile.lock
4
+ /pkg/*
5
+ /vendor
data/.travis.yml CHANGED
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.0
data/awsraw.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # specify any dependencies here; for example:
23
23
  s.add_development_dependency "rake"
24
- s.add_development_dependency "rspec", "~> 2.14"
24
+ s.add_development_dependency "rspec", "~> 3.0.0"
25
25
  s.add_runtime_dependency "finer_struct", "~> 0.0.5"
26
- s.add_runtime_dependency "faraday", "~> 0.8.8"
26
+ s.add_runtime_dependency "faraday", "~> 0.9.0"
27
27
  end
data/build ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ mkdir -p vendor/bundle
4
+ bundle install --path vendor/bundle
5
+ bundle exec rspec
@@ -19,9 +19,20 @@ module AWSRaw
19
19
  raise AWSRaw::Error, "Can't make a request with a body but no Content-Type header"
20
20
  end
21
21
 
22
+ add_missing_headers(env)
23
+ sign_request(env)
24
+
25
+ @app.call(env)
26
+ end
27
+
28
+ private
29
+
30
+ def add_missing_headers(env)
22
31
  env[:request_headers]['Date'] ||= Time.now.httpdate
23
32
  env[:request_headers]['Content-MD5'] ||= ContentMD5Header.generate_content_md5(env[:body]) if env[:body]
33
+ end
24
34
 
35
+ def sign_request(env)
25
36
  string_to_sign = StringToSign.string_to_sign(
26
37
  :method => env[:method].to_s.upcase,
27
38
  :uri => env[:url],
@@ -32,9 +43,8 @@ module AWSRaw
32
43
  )
33
44
 
34
45
  env[:request_headers]['Authorization'] = Signature.authorization_header(string_to_sign, @credentials)
35
-
36
- @app.call(env)
37
46
  end
47
+
38
48
  end
39
49
  end
40
50
  end
@@ -38,7 +38,7 @@ module AWSRaw
38
38
  private
39
39
 
40
40
  def self.hmac_sha1(data, credentials)
41
- digest = OpenSSL::Digest::Digest.new("sha1")
41
+ digest = OpenSSL::Digest.new("sha1")
42
42
  OpenSSL::HMAC.digest(digest, credentials.secret_access_key, data)
43
43
  end
44
44
 
@@ -1,3 +1,3 @@
1
1
  module AWSRaw
2
- VERSION = "1.0.0.alpha.2"
2
+ VERSION = "1.0.0.alpha.3"
3
3
  end
@@ -37,7 +37,7 @@ describe AWSRaw::S3::FaradayMiddleware do
37
37
  end
38
38
 
39
39
  it "sets the Date header if there isn't one" do
40
- Time.stub(:now => time) # Freeze time for the duration of the test.
40
+ allow(Time).to receive(:now).and_return(time) # Freeze time for the duration of the test.
41
41
 
42
42
  env = {
43
43
  :method => :get,
@@ -103,7 +103,7 @@ describe AWSRaw::S3::FaradayMiddleware do
103
103
  :request_headers => { }
104
104
  }
105
105
 
106
- app.should_receive(:call).with(env)
106
+ expect(app).to receive(:call).with(env)
107
107
 
108
108
  subject.call(env)
109
109
  end
@@ -11,6 +11,7 @@ describe AWSRaw::S3::Signature do
11
11
  )
12
12
  end
13
13
 
14
+
14
15
  context ".signature" do
15
16
  context "AWS example tests:" do
16
17
  # Examples are pulled from the AWS docs:
@@ -90,14 +91,21 @@ EOF
90
91
 
91
92
  let(:signature) { "0RavWzkygo6QX9caELEqKi9kDbU=" }
92
93
 
94
+ # Note: These credentials are (I think) from an old version of the AWS
95
+ # examples. The credentials currently in the docs don't produce the
96
+ # example signature. I suspect AWS haven't correctly updated their docs.
97
+ let(:credentials) do
98
+ OpenStruct.new(
99
+ :access_key_id => "0PN5J17HBGZHT7JJ3X82",
100
+ :secret_access_key => "uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o"
101
+ )
102
+ end
103
+
93
104
  it ".encode_form_policy correctly encodes a policy" do
94
105
  expect(subject.encode_form_policy(policy_json)).to eq(policy_base64)
95
106
  end
96
107
 
97
- # Note: This test fails. I'm pretty sure the example in the AWS docs is
98
- # wrong, but I'm leaving it failing until I can confirm that.
99
108
  it ".form_signature correctly signs a policy" do
100
- pending "Figure out which is wrong: the AWS examples or the code"
101
109
  expect(subject.form_signature(policy_base64, credentials)).to eq(signature)
102
110
  end
103
111
 
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: 1.0.0.alpha.2
4
+ version: 1.0.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Yandell
@@ -10,64 +10,64 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-19 00:00:00.000000000 Z
13
+ date: 2014-08-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ~>
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '2.14'
35
+ version: 3.0.0
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.14'
42
+ version: 3.0.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: finer_struct
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 0.0.5
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: 0.0.5
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: faraday
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 0.8.8
63
+ version: 0.9.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: 0.8.8
70
+ version: 0.9.0
71
71
  description: A client for Amazon Web Services in the style of FlickRaw
72
72
  email:
73
73
  - pete@notahat.com
@@ -77,14 +77,15 @@ executables: []
77
77
  extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
- - .gitignore
81
- - .rspec
82
- - .travis.yml
80
+ - ".gitignore"
81
+ - ".rspec"
82
+ - ".travis.yml"
83
83
  - Gemfile
84
84
  - LICENSE
85
85
  - README.md
86
86
  - Rakefile
87
87
  - awsraw.gemspec
88
+ - build
88
89
  - lib/awsraw.rb
89
90
  - lib/awsraw/credentials.rb
90
91
  - lib/awsraw/error.rb
@@ -112,17 +113,17 @@ require_paths:
112
113
  - lib
113
114
  required_ruby_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
- - - '>='
116
+ - - ">="
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
119
  required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  requirements:
120
- - - '>'
121
+ - - ">"
121
122
  - !ruby/object:Gem::Version
122
123
  version: 1.3.1
123
124
  requirements: []
124
125
  rubyforge_project: awsraw
125
- rubygems_version: 2.0.3
126
+ rubygems_version: 2.2.2
126
127
  signing_key:
127
128
  specification_version: 4
128
129
  summary: Minimal AWS client
@@ -133,3 +134,4 @@ test_files:
133
134
  - spec/s3/query_string_signer_spec.rb
134
135
  - spec/s3/signature_spec.rb
135
136
  - spec/s3/string_to_sign_spec.rb
137
+ has_rdoc: