right_aws_api 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,69 +3,12 @@ require 'right_aws_api'
3
3
  require 'rspec'
4
4
 
5
5
  describe RightScale::CloudApi::AWS::S3::RequestSigner do
6
- context '#get_subresources' do
7
- before :each do
8
- @sub_resources = {
9
- 'acl' => 0,
10
- 'policy' => 0,
11
- 'versions' => 0,
12
- 'website' => 0,
13
- 'response-content-type' => 0,
14
- 'response-content-language' => 0,
15
- 'response-foo-bar' => 0,
16
- }
17
- trash = {
18
- 'foo' => 0,
19
- 'bar' => 0,
20
- }
21
- params = @sub_resources.merge(trash)
22
- @result = subject.get_subresources(params)
23
- end
24
-
25
- it "extracts SUB_RESOURCES and response- params" do
26
- expect(@result).to eq(@sub_resources)
27
- end
28
- end
29
-
30
-
31
- context '#compute_canonicalized_bucket' do
32
- context 'DNS bucket' do
33
- it 'adds a trailing slash' do
34
- expect(subject.compute_canonicalized_bucket('foo-bar')).to eq('foo-bar/')
35
- end
36
- end
37
-
38
- context 'non DNS bucket' do
39
- it 'does nothing' do
40
- expect(subject.compute_canonicalized_bucket('foo_bar')).to eq('foo_bar')
41
- end
42
- end
43
- end
44
-
45
-
46
- context '#compute_canonicalized_path' do
47
- context 'with no sub-resources' do
48
- before :each do
49
- bucket = 'foo-bar_bucket'
50
- relative_path = 'a/b/c/d.jpg'
51
- params = { 'Foo' => 1, 'acl' => '2', 'response-content-type' => 'jpg' }
52
- @result = subject.compute_canonicalized_path(bucket, relative_path, params)
53
- @expectation = '/foo-bar_bucket/a/b/c/d.jpg?acl=2&response-content-type=jpg'
54
- end
55
-
56
- it 'works' do
57
- expect(@result).to eq(@expectation)
58
- end
59
- end
60
- end
61
-
62
-
63
6
 
64
7
  context '#compute_bucket_name_and_object_path' do
65
8
  before :each do
66
9
  @original_path = 'my-test-bucket/foo/bar/банана.jpg'
67
10
  @bucket = 'my-test-bucket'
68
- @relative_path = 'foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg'
11
+ @relative_path = 'foo/bar/%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg'
69
12
  end
70
13
 
71
14
  context 'when this is a first API call attempt' do
@@ -151,64 +94,6 @@ describe RightScale::CloudApi::AWS::S3::RequestSigner do
151
94
  expect(result['content-type']).to eq(expectation)
152
95
  end
153
96
  end
154
-
155
-
156
- context 'date' do
157
- it 'sets date' do
158
- result = subject.compute_headers!(@headers, @body, @host)
159
- expect(result['date']).to be_an(Array)
160
- expect(result['date'].first).to be_a(String)
161
- end
162
- end
163
-
164
-
165
- context 'content-md5' do
166
- context 'body is blank' do
167
- it 'does not set the header' do
168
- result = subject.compute_headers!(@headers, @body, @host)
169
- expect(result['content-md5']).to eq([])
170
- end
171
- end
172
-
173
-
174
- context 'body is not blank' do
175
- it 'does not set the header' do
176
- result = subject.compute_headers!(@headers, 'woo-hoo', @host)
177
- expect(result['content-md5']).to eq(['Ezs4dVuMkr7EgUDB41SEMg=='])
178
- end
179
- end
180
- end
181
-
182
-
183
- context 'host' do
184
- it 'sets the host' do
185
- result = subject.compute_headers!(@headers, @body, @host)
186
- expect(result['host']).to eq([@host])
187
- end
188
- end
189
- end
190
-
191
-
192
- context '#compute_signature' do
193
- before :each do
194
- @secret_key = 'secret-key'
195
- @verb = :get
196
- @bucket = 'foo-bar'
197
- @object = 'foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg'
198
- @params = { 'Foo' => 1, 'Bar' => 2}
199
- @headers = RightScale::CloudApi::HTTPHeaders.new(
200
- 'x-amz-foo-bar' => '1',
201
- 'x-amx-foo-boo' => '2',
202
- 'date' => 'Fri, 11 Jul 2014 21:25:46 GMT',
203
- 'other-header' => 'moo'
204
- )
205
- @expectation = "Z7hSptZVg7WytxFfM7K73henBpA="
206
- @result = subject.compute_signature(@access_key, @secret_key, @verb, @bucket, @object, @params, @headers)
207
- end
208
-
209
- it 'properly calculates the signature' do
210
- expect(@result).to eq(@expectation)
211
- end
212
97
  end
213
98
 
214
99
 
@@ -216,15 +101,14 @@ describe RightScale::CloudApi::AWS::S3::RequestSigner do
216
101
  before :each do
217
102
  @path = 'foo-bar'
218
103
  @object = 'foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg'
219
- @params = { 'Foo' => 1, 'Bar' => 2}
220
104
  end
221
105
 
222
106
  it 'works for DNS bucket' do
223
- expect(subject.compute_path('foo-bar', @object, @params)).to eq('/foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg?Bar=2&Foo=1')
107
+ expect(subject.compute_path('foo-bar', @object)).to eq('/foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg')
224
108
  end
225
109
 
226
110
  it 'works for non DNS bucket' do
227
- expect(subject.compute_path('foo_bar', @object, @params)).to eq('/foo_bar/foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg?Bar=2&Foo=1')
111
+ expect(subject.compute_path('foo_bar', @object)).to eq('/foo_bar/foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg')
228
112
  end
229
113
  end
230
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_aws_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RightScale, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-15 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: right_cloud_api_base
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0
26
+ version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: |+
56
70
  == DESCRIPTION:
57
71
 
@@ -99,10 +113,11 @@ files:
99
113
  - lib/cloud/aws/sdb/manager.rb
100
114
  - lib/cloud/aws/sns/manager.rb
101
115
  - lib/cloud/aws/sqs/manager.rb
116
+ - lib/cloud/aws/sqs/routines/request_signer.rb
102
117
  - lib/right_aws_api.rb
103
118
  - lib/right_aws_api_version.rb
104
119
  - right_aws_api.gemspec
105
- - spec/cloud/aws/s3/link/routines/request_signer_spec.rb
120
+ - spec/cloud/aws/base/helpers/utils_spec.rb
106
121
  - spec/cloud/aws/s3/routines/request_signer_spec.rb
107
122
  - spec/describe_calls.rb
108
123
  homepage:
@@ -128,12 +143,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
143
  version: '0'
129
144
  requirements: []
130
145
  rubyforge_project:
131
- rubygems_version: 2.1.11
146
+ rubygems_version: 2.4.3
132
147
  signing_key:
133
148
  specification_version: 4
134
149
  summary: The gem provides interface to AWS cloud services.
135
150
  test_files:
136
- - spec/cloud/aws/s3/routines/request_signer_spec.rb
137
- - spec/cloud/aws/s3/link/routines/request_signer_spec.rb
138
151
  - spec/describe_calls.rb
152
+ - spec/cloud/aws/s3/routines/request_signer_spec.rb
153
+ - spec/cloud/aws/base/helpers/utils_spec.rb
139
154
  has_rdoc:
@@ -1,53 +0,0 @@
1
- require 'right_aws_api'
2
-
3
- require 'rspec'
4
-
5
- describe RightScale::CloudApi::AWS::S3::Link::RequestSigner do
6
-
7
-
8
- context '#compute_params!' do
9
- before :each do
10
- @access_key = 'access-key'
11
- end
12
-
13
- context 'Expires' do
14
- it 'defaults to something in the future' do
15
- result = subject.compute_params!({}, @access_key)
16
- expect(result['Expires']).to be_an(Integer)
17
- end
18
-
19
- it 'sets the passed value' do
20
- expectation = 123
21
- result = subject.compute_params!({ 'Expires' => expectation }, @access_key)
22
- expect(result['Expires']).to eq(expectation)
23
- end
24
- end
25
-
26
-
27
- context 'AWSAccessKeyId' do
28
- it 'sets the passed value' do
29
- result = subject.compute_params!({}, @access_key)
30
- expect(result['AWSAccessKeyId']).to eq(@access_key)
31
- end
32
- end
33
-
34
- end
35
-
36
-
37
- context '#compute_signature' do
38
- before :each do
39
- @secret_key = 'secret-key'
40
- @verb = :get
41
- @bucket = 'foo-bar'
42
- @object = 'foo%2Fbar%2F%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%B0.jpg'
43
- @params = { 'Foo' => 1, 'Bar' => 2, 'Expires' => 1000000 }
44
- @expectation = "EShMsLs2Bqak5YuIqOTJq15qcJE="
45
- @result = subject.compute_signature(@secret_key, @verb, @bucket, @object, @params)
46
- end
47
-
48
- it 'properly calculates the signature' do
49
- expect(@result).to eq(@expectation)
50
- end
51
- end
52
-
53
- end