api-auth 1.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -44
  3. data/.rubocop.yml +102 -0
  4. data/.travis.yml +1 -0
  5. data/Appraisals +8 -0
  6. data/CHANGELOG.md +8 -1
  7. data/Gemfile +3 -0
  8. data/README.md +33 -5
  9. data/VERSION +1 -1
  10. data/api_auth.gemspec +17 -17
  11. data/gemfiles/rails_23.gemfile +3 -0
  12. data/gemfiles/rails_30.gemfile +3 -0
  13. data/gemfiles/rails_31.gemfile +5 -0
  14. data/gemfiles/rails_32.gemfile +5 -0
  15. data/gemfiles/rails_4.gemfile +2 -0
  16. data/gemfiles/rails_41.gemfile +2 -0
  17. data/gemfiles/rails_42.gemfile +2 -0
  18. data/lib/api-auth.rb +1 -1
  19. data/lib/api_auth/base.rb +21 -25
  20. data/lib/api_auth/errors.rb +4 -3
  21. data/lib/api_auth/headers.rb +11 -27
  22. data/lib/api_auth/helpers.rb +2 -6
  23. data/lib/api_auth/railtie.rb +5 -50
  24. data/lib/api_auth/request_drivers/action_controller.rb +7 -13
  25. data/lib/api_auth/request_drivers/action_dispatch.rb +0 -6
  26. data/lib/api_auth/request_drivers/curb.rb +8 -14
  27. data/lib/api_auth/request_drivers/faraday.rb +11 -21
  28. data/lib/api_auth/request_drivers/httpi.rb +8 -14
  29. data/lib/api_auth/request_drivers/net_http.rb +8 -14
  30. data/lib/api_auth/request_drivers/rack.rb +10 -16
  31. data/lib/api_auth/request_drivers/rest_client.rb +9 -15
  32. data/spec/api_auth_spec.rb +90 -88
  33. data/spec/headers_spec.rb +69 -84
  34. data/spec/helpers_spec.rb +7 -9
  35. data/spec/railtie_spec.rb +42 -72
  36. data/spec/request_drivers/action_controller_spec.rb +53 -55
  37. data/spec/request_drivers/action_dispatch_spec.rb +52 -55
  38. data/spec/request_drivers/curb_spec.rb +25 -28
  39. data/spec/request_drivers/faraday_spec.rb +54 -56
  40. data/spec/request_drivers/httpi_spec.rb +42 -48
  41. data/spec/request_drivers/net_http_spec.rb +51 -53
  42. data/spec/request_drivers/rack_spec.rb +58 -60
  43. data/spec/request_drivers/rest_client_spec.rb +86 -89
  44. data/spec/spec_helper.rb +9 -9
  45. metadata +4 -11
  46. data/Gemfile.lock +0 -115
  47. data/gemfiles/rails_23.gemfile.lock +0 -70
  48. data/gemfiles/rails_30.gemfile.lock +0 -92
  49. data/gemfiles/rails_31.gemfile.lock +0 -98
  50. data/gemfiles/rails_32.gemfile.lock +0 -97
  51. data/gemfiles/rails_4.gemfile.lock +0 -94
  52. data/gemfiles/rails_41.gemfile.lock +0 -98
  53. data/gemfiles/rails_42.gemfile.lock +0 -115
@@ -1,96 +1,93 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ApiAuth::RequestDrivers::CurbRequest do
4
-
5
- let(:timestamp){ Time.now.utc.httpdate }
4
+ let(:timestamp) { Time.now.utc.httpdate }
6
5
 
7
6
  let(:request) do
8
7
  headers = {
9
8
  'Authorization' => 'APIAuth 1044:12345',
10
- 'Content-MD5' => "1B2M2Y8AsgTpgAmY7PhCfg==",
11
- 'Content-Type' => "text/plain",
9
+ 'Content-MD5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
10
+ 'Content-Type' => 'text/plain',
12
11
  'Date' => timestamp
13
12
  }
14
- Curl::Easy.new("/resource.xml?foo=bar&bar=foo") do |curl|
13
+ Curl::Easy.new('/resource.xml?foo=bar&bar=foo') do |curl|
15
14
  curl.headers = headers
16
15
  end
17
16
  end
18
17
 
18
+ subject(:driven_request) { ApiAuth::RequestDrivers::CurbRequest.new(request) }
19
19
 
20
- subject(:driven_request){ ApiAuth::RequestDrivers::CurbRequest.new(request) }
21
-
22
- describe "getting headers correctly" do
23
- it "gets the content_type" do
20
+ describe 'getting headers correctly' do
21
+ it 'gets the content_type' do
24
22
  expect(driven_request.content_type).to eq('text/plain')
25
23
  end
26
24
 
27
- it "gets the content_md5" do
25
+ it 'gets the content_md5' do
28
26
  expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
29
27
  end
30
28
 
31
- it "gets the request_uri" do
29
+ it 'gets the request_uri' do
32
30
  expect(driven_request.request_uri).to eq('/resource.xml?foo=bar&bar=foo')
33
31
  end
34
32
 
35
- it "gets the timestamp" do
33
+ it 'gets the timestamp' do
36
34
  expect(driven_request.timestamp).to eq(timestamp)
37
35
  end
38
36
 
39
- it "gets the authorization_header" do
37
+ it 'gets the authorization_header' do
40
38
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
41
39
  end
42
40
 
43
- describe "http_method" do
44
- it "is always nil" do
41
+ describe 'http_method' do
42
+ it 'is always nil' do
45
43
  expect(driven_request.http_method).to be_nil
46
44
  end
47
45
  end
48
46
  end
49
47
 
50
- describe "setting headers correctly" do
48
+ describe 'setting headers correctly' do
51
49
  let(:request) do
52
50
  headers = {
53
- 'Content-Type' => "text/plain"
51
+ 'Content-Type' => 'text/plain'
54
52
  }
55
- Curl::Easy.new("/resource.xml?foo=bar&bar=foo") do |curl|
53
+ Curl::Easy.new('/resource.xml?foo=bar&bar=foo') do |curl|
56
54
  curl.headers = headers
57
55
  end
58
56
  end
59
57
 
60
- describe "#populate_content_md5" do
61
- it "is a no-op" do
58
+ describe '#populate_content_md5' do
59
+ it 'is a no-op' do
62
60
  expect(driven_request.populate_content_md5).to be_nil
63
61
  expect(request.headers['Content-MD5']).to be_nil
64
62
  end
65
-
66
63
  end
67
64
 
68
- describe "#set_date" do
65
+ describe '#set_date' do
69
66
  before do
70
67
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
71
68
  end
72
69
 
73
- it "sets the date header of the request" do
70
+ it 'sets the date header of the request' do
74
71
  driven_request.set_date
75
72
  expect(request.headers['DATE']).to eq(timestamp)
76
73
  end
77
74
 
78
- it "refreshes the cached headers" do
75
+ it 'refreshes the cached headers' do
79
76
  driven_request.set_date
80
77
  expect(driven_request.timestamp).to eq(timestamp)
81
78
  end
82
79
  end
83
80
 
84
- describe "#set_auth_header" do
85
- it "sets the auth header" do
81
+ describe '#set_auth_header' do
82
+ it 'sets the auth header' do
86
83
  driven_request.set_auth_header('APIAuth 1044:54321')
87
84
  expect(request.headers['Authorization']).to eq('APIAuth 1044:54321')
88
85
  end
89
86
  end
90
87
  end
91
88
 
92
- describe "md5_mismatch?" do
93
- it "is always false" do
89
+ describe 'md5_mismatch?' do
90
+ it 'is always false' do
94
91
  expect(driven_request.md5_mismatch?).to be false
95
92
  end
96
93
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ApiAuth::RequestDrivers::FaradayRequest do
4
-
5
- let(:timestamp){ Time.now.utc.httpdate }
4
+ let(:timestamp) { Time.now.utc.httpdate }
6
5
 
7
6
  let(:faraday_stubs) do
8
7
  Faraday::Adapter::Test::Stubs.new do |stub|
@@ -20,8 +19,8 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
20
19
 
21
20
  let(:request_headers) do
22
21
  {
23
- 'Authorization' => 'APIAuth 1044:12345',
24
- 'Content-MD5' => "1B2M2Y8AsgTpgAmY7PhCfg==",
22
+ 'Authorization' => 'APIAuth 1044:12345',
23
+ 'Content-MD5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
25
24
  'content-type' => 'text/plain',
26
25
  'DATE' => timestamp
27
26
  }
@@ -38,42 +37,42 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
38
37
  faraday_request
39
38
  end
40
39
 
41
- subject(:driven_request){ ApiAuth::RequestDrivers::FaradayRequest.new(request) }
40
+ subject(:driven_request) { ApiAuth::RequestDrivers::FaradayRequest.new(request) }
42
41
 
43
- describe "getting headers correctly" do
44
- it "gets the content_type" do
42
+ describe 'getting headers correctly' do
43
+ it 'gets the content_type' do
45
44
  expect(driven_request.content_type).to eq('text/plain')
46
45
  end
47
46
 
48
- it "gets the content_md5" do
47
+ it 'gets the content_md5' do
49
48
  expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
50
49
  end
51
50
 
52
- it "gets the request_uri" do
51
+ it 'gets the request_uri' do
53
52
  expect(driven_request.request_uri).to eq('/resource.xml?bar=foo&foo=bar')
54
53
  end
55
54
 
56
- it "gets the timestamp" do
55
+ it 'gets the timestamp' do
57
56
  expect(driven_request.timestamp).to eq(timestamp)
58
57
  end
59
58
 
60
- it "gets the authorization_header" do
59
+ it 'gets the authorization_header' do
61
60
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
62
61
  end
63
62
 
64
- describe "#calculated_md5" do
65
- it "calculates md5 from the body" do
63
+ describe '#calculated_md5' do
64
+ it 'calculates md5 from the body' do
66
65
  expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
67
66
  end
68
67
 
69
- it "treats no body as empty string" do
68
+ it 'treats no body as empty string' do
70
69
  request.body = nil
71
70
  expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
72
71
  end
73
72
  end
74
73
 
75
- describe "http_method" do
76
- context "when put request" do
74
+ describe 'http_method' do
75
+ context 'when put request' do
77
76
  let(:request) do
78
77
  faraday_request = nil
79
78
 
@@ -85,12 +84,12 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
85
84
  faraday_request
86
85
  end
87
86
 
88
- it "returns upcased put" do
87
+ it 'returns upcased put' do
89
88
  expect(driven_request.http_method).to eq('PUT')
90
89
  end
91
90
  end
92
91
 
93
- context "when get request" do
92
+ context 'when get request' do
94
93
  let(:request) do
95
94
  faraday_request = nil
96
95
 
@@ -102,158 +101,157 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
102
101
  faraday_request
103
102
  end
104
103
 
105
- it "returns upcased get" do
104
+ it 'returns upcased get' do
106
105
  expect(driven_request.http_method).to eq('GET')
107
106
  end
108
107
  end
109
108
  end
110
109
  end
111
110
 
112
- describe "setting headers correctly" do
111
+ describe 'setting headers correctly' do
113
112
  let(:request_headers) do
114
113
  {
115
114
  'content-type' => 'text/plain'
116
115
  }
117
116
  end
118
117
 
119
- describe "#populate_content_md5" do
120
- context "when getting" do
118
+ describe '#populate_content_md5' do
119
+ context 'when getting' do
121
120
  it "doesn't populate content-md5" do
122
121
  request.method = :get
123
122
  driven_request.populate_content_md5
124
- expect(request.headers["Content-MD5"]).to be_nil
123
+ expect(request.headers['Content-MD5']).to be_nil
125
124
  end
126
125
  end
127
126
 
128
- context "when posting" do
129
- it "populates content-md5" do
127
+ context 'when posting' do
128
+ it 'populates content-md5' do
130
129
  request.method = :post
131
130
  driven_request.populate_content_md5
132
- expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
131
+ expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
133
132
  end
134
133
 
135
- it "refreshes the cached headers" do
134
+ it 'refreshes the cached headers' do
136
135
  driven_request.populate_content_md5
137
136
  expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
138
137
  end
139
138
  end
140
139
 
141
- context "when putting" do
142
- it "populates content-md5" do
140
+ context 'when putting' do
141
+ it 'populates content-md5' do
143
142
  request.method = :put
144
143
  driven_request.populate_content_md5
145
- expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
144
+ expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
146
145
  end
147
146
 
148
- it "refreshes the cached headers" do
147
+ it 'refreshes the cached headers' do
149
148
  driven_request.populate_content_md5
150
149
  expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
151
150
  end
152
151
  end
153
152
 
154
- context "when deleting" do
153
+ context 'when deleting' do
155
154
  it "doesn't populate content-md5" do
156
155
  request.method = :delete
157
156
  driven_request.populate_content_md5
158
- expect(request.headers["Content-MD5"]).to be_nil
157
+ expect(request.headers['Content-MD5']).to be_nil
159
158
  end
160
159
  end
161
-
162
160
  end
163
161
 
164
- describe "#set_date" do
162
+ describe '#set_date' do
165
163
  before do
166
164
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
167
165
  end
168
166
 
169
- it "sets the date header of the request" do
167
+ it 'sets the date header of the request' do
170
168
  driven_request.set_date
171
169
  expect(request.headers['DATE']).to eq(timestamp)
172
170
  end
173
171
 
174
- it "refreshes the cached headers" do
172
+ it 'refreshes the cached headers' do
175
173
  driven_request.set_date
176
174
  expect(driven_request.timestamp).to eq(timestamp)
177
175
  end
178
176
  end
179
177
 
180
- describe "#set_auth_header" do
181
- it "sets the auth header" do
178
+ describe '#set_auth_header' do
179
+ it 'sets the auth header' do
182
180
  driven_request.set_auth_header('APIAuth 1044:54321')
183
181
  expect(request.headers['Authorization']).to eq('APIAuth 1044:54321')
184
182
  end
185
183
  end
186
184
  end
187
185
 
188
- describe "md5_mismatch?" do
189
- context "when getting" do
186
+ describe 'md5_mismatch?' do
187
+ context 'when getting' do
190
188
  before do
191
189
  request.method = :get
192
190
  end
193
191
 
194
- it "is false" do
192
+ it 'is false' do
195
193
  expect(driven_request.md5_mismatch?).to be false
196
194
  end
197
195
  end
198
196
 
199
- context "when posting" do
197
+ context 'when posting' do
200
198
  before do
201
199
  request.method = :post
202
200
  end
203
201
 
204
- context "when calculated matches sent" do
202
+ context 'when calculated matches sent' do
205
203
  before do
206
- request.headers["Content-MD5"] = 'kZXQvrKoieG+Be1rsZVINw=='
204
+ request.headers['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
207
205
  end
208
206
 
209
- it "is false" do
207
+ it 'is false' do
210
208
  expect(driven_request.md5_mismatch?).to be false
211
209
  end
212
210
  end
213
211
 
214
212
  context "when calculated doesn't match sent" do
215
213
  before do
216
- request.headers["Content-MD5"] = "3"
214
+ request.headers['Content-MD5'] = '3'
217
215
  end
218
216
 
219
- it "is true" do
217
+ it 'is true' do
220
218
  expect(driven_request.md5_mismatch?).to be true
221
219
  end
222
220
  end
223
221
  end
224
222
 
225
- context "when putting" do
223
+ context 'when putting' do
226
224
  before do
227
225
  request.method = :put
228
226
  end
229
227
 
230
- context "when calculated matches sent" do
228
+ context 'when calculated matches sent' do
231
229
  before do
232
- request.headers["Content-MD5"] = 'kZXQvrKoieG+Be1rsZVINw=='
230
+ request.headers['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
233
231
  end
234
232
 
235
- it "is false" do
233
+ it 'is false' do
236
234
  expect(driven_request.md5_mismatch?).to be false
237
235
  end
238
236
  end
239
237
 
240
238
  context "when calculated doesn't match sent" do
241
239
  before do
242
- request.headers["Content-MD5"] = "3"
240
+ request.headers['Content-MD5'] = '3'
243
241
  end
244
242
 
245
- it "is true" do
243
+ it 'is true' do
246
244
  expect(driven_request.md5_mismatch?).to be true
247
245
  end
248
246
  end
249
247
  end
250
248
 
251
- context "when deleting" do
249
+ context 'when deleting' do
252
250
  before do
253
251
  request.method = :delete
254
252
  end
255
253
 
256
- it "is false" do
254
+ it 'is false' do
257
255
  expect(driven_request.md5_mismatch?).to be false
258
256
  end
259
257
  end
@@ -1,157 +1,151 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ApiAuth::RequestDrivers::HttpiRequest do
4
-
5
- let(:timestamp){ Time.now.utc.httpdate }
4
+ let(:timestamp) { Time.now.utc.httpdate }
6
5
 
7
6
  let(:request) do
8
- httpi_request = HTTPI::Request.new("http://localhost/resource.xml?foo=bar&bar=foo")
9
- httpi_request.headers.merge!({
10
- 'Authorization' => 'APIAuth 1044:12345',
11
- 'content-md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
12
- 'content-type' => 'text/plain',
13
- 'date' => timestamp
14
- })
7
+ httpi_request = HTTPI::Request.new('http://localhost/resource.xml?foo=bar&bar=foo')
8
+ httpi_request.headers.merge!('Authorization' => 'APIAuth 1044:12345',
9
+ 'content-md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
10
+ 'content-type' => 'text/plain',
11
+ 'date' => timestamp)
15
12
  httpi_request.body = "hello\nworld"
16
13
  httpi_request
17
14
  end
18
15
 
19
- subject(:driven_request){ ApiAuth::RequestDrivers::HttpiRequest.new(request) }
16
+ subject(:driven_request) { ApiAuth::RequestDrivers::HttpiRequest.new(request) }
20
17
 
21
- describe "getting headers correctly" do
22
- it "gets the content_type" do
18
+ describe 'getting headers correctly' do
19
+ it 'gets the content_type' do
23
20
  expect(driven_request.content_type).to eq('text/plain')
24
21
  end
25
22
 
26
- it "gets the content_md5" do
23
+ it 'gets the content_md5' do
27
24
  expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
28
25
  end
29
26
 
30
- it "gets the request_uri" do
27
+ it 'gets the request_uri' do
31
28
  expect(driven_request.request_uri).to eq('/resource.xml?foo=bar&bar=foo')
32
29
  end
33
30
 
34
- it "gets the timestamp" do
31
+ it 'gets the timestamp' do
35
32
  expect(driven_request.timestamp).to eq(timestamp)
36
33
  end
37
34
 
38
- it "gets the authorization_header" do
35
+ it 'gets the authorization_header' do
39
36
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
40
37
  end
41
38
 
42
- describe "#calculated_md5" do
43
- it "calculates md5 from the body" do
39
+ describe '#calculated_md5' do
40
+ it 'calculates md5 from the body' do
44
41
  expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
45
42
  end
46
43
 
47
- it "treats no body as empty string" do
44
+ it 'treats no body as empty string' do
48
45
  request.body = nil
49
46
  expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
50
47
  end
51
48
  end
52
49
 
53
- describe "http_method" do
54
- it "is always nil" do
50
+ describe 'http_method' do
51
+ it 'is always nil' do
55
52
  expect(driven_request.http_method).to be_nil
56
53
  end
57
54
  end
58
55
  end
59
56
 
60
- describe "setting headers correctly" do
57
+ describe 'setting headers correctly' do
61
58
  let(:request) do
62
- httpi_request = HTTPI::Request.new("http://localhost/resource.xml?foo=bar&bar=foo")
63
- httpi_request.headers.merge!({
64
- 'content-type' => 'text/plain'
65
- })
59
+ httpi_request = HTTPI::Request.new('http://localhost/resource.xml?foo=bar&bar=foo')
60
+ httpi_request.headers['content-type'] = 'text/plain'
66
61
  httpi_request
67
62
  end
68
63
 
69
- describe "#populate_content_md5" do
70
- context "when there is no content body" do
64
+ describe '#populate_content_md5' do
65
+ context 'when there is no content body' do
71
66
  before do
72
67
  request.body = nil
73
68
  end
74
69
 
75
70
  it "doesn't populate content-md5" do
76
71
  driven_request.populate_content_md5
77
- expect(request.headers["Content-MD5"]).to be_nil
72
+ expect(request.headers['Content-MD5']).to be_nil
78
73
  end
79
74
  end
80
75
 
81
- context "when there is a content body" do
76
+ context 'when there is a content body' do
82
77
  before do
83
78
  request.body = "hello\nworld"
84
79
  end
85
80
 
86
- it "populates content-md5" do
81
+ it 'populates content-md5' do
87
82
  driven_request.populate_content_md5
88
- expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
83
+ expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
89
84
  end
90
85
 
91
- it "refreshes the cached headers" do
86
+ it 'refreshes the cached headers' do
92
87
  driven_request.populate_content_md5
93
88
  expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
94
89
  end
95
90
  end
96
91
  end
97
92
 
98
- describe "#set_date" do
93
+ describe '#set_date' do
99
94
  before do
100
95
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
101
96
  end
102
97
 
103
- it "sets the date header of the request" do
98
+ it 'sets the date header of the request' do
104
99
  driven_request.set_date
105
100
  expect(request.headers['DATE']).to eq(timestamp)
106
101
  end
107
102
 
108
- it "refreshes the cached headers" do
103
+ it 'refreshes the cached headers' do
109
104
  driven_request.set_date
110
105
  expect(driven_request.timestamp).to eq(timestamp)
111
106
  end
112
107
  end
113
108
 
114
- describe "#set_auth_header" do
115
- it "sets the auth header" do
109
+ describe '#set_auth_header' do
110
+ it 'sets the auth header' do
116
111
  driven_request.set_auth_header('APIAuth 1044:54321')
117
112
  expect(request.headers['Authorization']).to eq('APIAuth 1044:54321')
118
113
  end
119
114
  end
120
115
  end
121
116
 
122
- describe "md5_mismatch?" do
123
- context "when there is no content body" do
117
+ describe 'md5_mismatch?' do
118
+ context 'when there is no content body' do
124
119
  before do
125
120
  request.body = nil
126
121
  end
127
122
 
128
-
129
- it "is false" do
123
+ it 'is false' do
130
124
  expect(driven_request.md5_mismatch?).to be false
131
125
  end
132
126
  end
133
127
 
134
- context "when there is a content body" do
128
+ context 'when there is a content body' do
135
129
  before do
136
130
  request.body = "hello\nworld"
137
131
  end
138
132
 
139
- context "when calculated matches sent" do
133
+ context 'when calculated matches sent' do
140
134
  before do
141
- request.headers["Content-MD5"] = 'kZXQvrKoieG+Be1rsZVINw=='
135
+ request.headers['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
142
136
  end
143
137
 
144
- it "is false" do
138
+ it 'is false' do
145
139
  expect(driven_request.md5_mismatch?).to be false
146
140
  end
147
141
  end
148
142
 
149
143
  context "when calculated doesn't match sent" do
150
144
  before do
151
- request.headers["Content-MD5"] = "3"
145
+ request.headers['Content-MD5'] = '3'
152
146
  end
153
147
 
154
- it "is true" do
148
+ it 'is true' do
155
149
  expect(driven_request.md5_mismatch?).to be true
156
150
  end
157
151
  end