api-auth 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -2
  3. data/.rubocop_todo.yml +29 -19
  4. data/.travis.yml +4 -11
  5. data/CHANGELOG.md +8 -0
  6. data/README.md +28 -26
  7. data/VERSION +1 -1
  8. data/api_auth.gemspec +5 -4
  9. data/gemfiles/rails_60.gemfile +0 -2
  10. data/gemfiles/{rails_51.gemfile → rails_61.gemfile} +4 -2
  11. data/lib/api_auth/base.rb +2 -2
  12. data/lib/api_auth/headers.rb +6 -6
  13. data/lib/api_auth/helpers.rb +2 -2
  14. data/lib/api_auth/railtie.rb +3 -1
  15. data/lib/api_auth/request_drivers/action_controller.rb +8 -8
  16. data/lib/api_auth/request_drivers/curb.rb +4 -4
  17. data/lib/api_auth/request_drivers/faraday.rb +11 -11
  18. data/lib/api_auth/request_drivers/grape_request.rb +8 -8
  19. data/lib/api_auth/request_drivers/http.rb +8 -8
  20. data/lib/api_auth/request_drivers/httpi.rb +8 -8
  21. data/lib/api_auth/request_drivers/net_http.rb +8 -8
  22. data/lib/api_auth/request_drivers/rack.rb +8 -8
  23. data/lib/api_auth/request_drivers/rest_client.rb +8 -8
  24. data/spec/api_auth_spec.rb +8 -8
  25. data/spec/headers_spec.rb +26 -26
  26. data/spec/helpers_spec.rb +1 -1
  27. data/spec/railtie_spec.rb +3 -3
  28. data/spec/request_drivers/action_controller_spec.rb +35 -35
  29. data/spec/request_drivers/action_dispatch_spec.rb +35 -35
  30. data/spec/request_drivers/curb_spec.rb +8 -8
  31. data/spec/request_drivers/faraday_spec.rb +43 -43
  32. data/spec/request_drivers/grape_request_spec.rb +33 -32
  33. data/spec/request_drivers/http_spec.rb +23 -23
  34. data/spec/request_drivers/httpi_spec.rb +22 -22
  35. data/spec/request_drivers/net_http_spec.rb +23 -23
  36. data/spec/request_drivers/rack_spec.rb +35 -35
  37. data/spec/request_drivers/rest_client_spec.rb +36 -36
  38. metadata +29 -19
  39. data/gemfiles/http2.gemfile +0 -7
  40. data/gemfiles/http3.gemfile +0 -7
  41. data/gemfiles/rails_5.gemfile +0 -9
  42. data/spec/.rubocop.yml +0 -5
@@ -6,7 +6,7 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
6
6
  let(:request) do
7
7
  httpi_request = HTTPI::Request.new('http://localhost/resource.xml?foo=bar&bar=foo')
8
8
  httpi_request.headers.merge!('Authorization' => 'APIAuth 1044:12345',
9
- 'content-md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
9
+ 'X-Authorization-Content-SHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
10
10
  'content-type' => 'text/plain',
11
11
  'date' => timestamp)
12
12
  httpi_request.body = "hello\nworld"
@@ -20,8 +20,8 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
20
20
  expect(driven_request.content_type).to eq('text/plain')
21
21
  end
22
22
 
23
- it 'gets the content_md5' do
24
- expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
23
+ it 'gets the content_hash' do
24
+ expect(driven_request.content_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
25
25
  end
26
26
 
27
27
  it 'gets the request_uri' do
@@ -36,14 +36,14 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
36
36
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
37
37
  end
38
38
 
39
- describe '#calculated_md5' do
40
- it 'calculates md5 from the body' do
41
- expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
39
+ describe '#calculated_hash' do
40
+ it 'calculates hash from the body' do
41
+ expect(driven_request.calculated_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
42
42
  end
43
43
 
44
44
  it 'treats no body as empty string' do
45
45
  request.body = nil
46
- expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
46
+ expect(driven_request.calculated_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
47
47
  end
48
48
  end
49
49
 
@@ -61,15 +61,15 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
61
61
  httpi_request
62
62
  end
63
63
 
64
- describe '#populate_content_md5' do
64
+ describe '#populate_content_hash' do
65
65
  context 'when there is no content body' do
66
66
  before do
67
67
  request.body = nil
68
68
  end
69
69
 
70
- it "doesn't populate content-md5" do
71
- driven_request.populate_content_md5
72
- expect(request.headers['Content-MD5']).to be_nil
70
+ it "doesn't populate content hash" do
71
+ driven_request.populate_content_hash
72
+ expect(request.headers['X-Authorization-Content-SHA256']).to be_nil
73
73
  end
74
74
  end
75
75
 
@@ -78,14 +78,14 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
78
78
  request.body = "hello\nworld"
79
79
  end
80
80
 
81
- it 'populates content-md5' do
82
- driven_request.populate_content_md5
83
- expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
81
+ it 'populates content hash' do
82
+ driven_request.populate_content_hash
83
+ expect(request.headers['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
84
84
  end
85
85
 
86
86
  it 'refreshes the cached headers' do
87
- driven_request.populate_content_md5
88
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
87
+ driven_request.populate_content_hash
88
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
89
89
  end
90
90
  end
91
91
  end
@@ -114,14 +114,14 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
114
114
  end
115
115
  end
116
116
 
117
- describe 'md5_mismatch?' do
117
+ describe 'content_hash_mismatch?' do
118
118
  context 'when there is no content body' do
119
119
  before do
120
120
  request.body = nil
121
121
  end
122
122
 
123
123
  it 'is false' do
124
- expect(driven_request.md5_mismatch?).to be false
124
+ expect(driven_request.content_hash_mismatch?).to be false
125
125
  end
126
126
  end
127
127
 
@@ -132,21 +132,21 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
132
132
 
133
133
  context 'when calculated matches sent' do
134
134
  before do
135
- request.headers['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
135
+ request.headers['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
136
136
  end
137
137
 
138
138
  it 'is false' do
139
- expect(driven_request.md5_mismatch?).to be false
139
+ expect(driven_request.content_hash_mismatch?).to be false
140
140
  end
141
141
  end
142
142
 
143
143
  context "when calculated doesn't match sent" do
144
144
  before do
145
- request.headers['Content-MD5'] = '3'
145
+ request.headers['X-Authorization-Content-SHA256'] = '3'
146
146
  end
147
147
 
148
148
  it 'is true' do
149
- expect(driven_request.md5_mismatch?).to be true
149
+ expect(driven_request.content_hash_mismatch?).to be true
150
150
  end
151
151
  end
152
152
  end
@@ -8,7 +8,7 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
8
8
  let(:request_headers) do
9
9
  {
10
10
  'Authorization' => 'APIAuth 1044:12345',
11
- 'content-md5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
11
+ 'X-Authorization-Content-SHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
12
12
  'content-type' => 'text/plain',
13
13
  'date' => timestamp
14
14
  }
@@ -36,8 +36,8 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
36
36
  end
37
37
  end
38
38
 
39
- it 'gets the content_md5' do
40
- expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
39
+ it 'gets the content_hash' do
40
+ expect(driven_request.content_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
41
41
  end
42
42
 
43
43
  it 'gets the request_uri' do
@@ -52,20 +52,20 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
52
52
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
53
53
  end
54
54
 
55
- describe '#calculated_md5' do
56
- it 'calculates md5 from the body' do
57
- expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
55
+ describe '#calculated_hash' do
56
+ it 'calculate content hash from the body' do
57
+ expect(driven_request.calculated_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
58
58
  end
59
59
 
60
60
  it 'treats no body as empty string' do
61
61
  request.body = nil
62
- expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
62
+ expect(driven_request.calculated_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
63
63
  end
64
64
 
65
65
  it 'calculates correctly for multipart content' do
66
66
  request.body = nil
67
67
  request.body_stream = File.new('spec/fixtures/upload.png')
68
- expect(driven_request.calculated_md5).to eq('k4U8MTA3RHDcewBzymVNEQ==')
68
+ expect(driven_request.calculated_hash).to eq('AlKDe7kjMQhuKgKuNG8I7GA93MasHcaVJkJLaUT7+dY=')
69
69
  end
70
70
  end
71
71
 
@@ -99,15 +99,15 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
99
99
  Net::HTTP::Put.new(request_path, request_headers)
100
100
  end
101
101
 
102
- describe '#populate_content_md5' do
102
+ describe '#populate_content_hash' do
103
103
  context 'when request type has no body' do
104
104
  let(:request) do
105
105
  Net::HTTP::Get.new(request_path, request_headers)
106
106
  end
107
107
 
108
- it "doesn't populate content-md5" do
109
- driven_request.populate_content_md5
110
- expect(request['Content-MD5']).to be_nil
108
+ it "doesn't populate content hash" do
109
+ driven_request.populate_content_hash
110
+ expect(request['X-Authorization-Content-SHA256']).to be_nil
111
111
  end
112
112
  end
113
113
 
@@ -118,14 +118,14 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
118
118
  net_http_request
119
119
  end
120
120
 
121
- it 'populates content-md5' do
122
- driven_request.populate_content_md5
123
- expect(request['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
121
+ it 'populates content hash' do
122
+ driven_request.populate_content_hash
123
+ expect(request['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
124
124
  end
125
125
 
126
126
  it 'refreshes the cached headers' do
127
- driven_request.populate_content_md5
128
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
127
+ driven_request.populate_content_hash
128
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
129
129
  end
130
130
  end
131
131
  end
@@ -154,14 +154,14 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
154
154
  end
155
155
  end
156
156
 
157
- describe 'md5_mismatch?' do
157
+ describe 'content_hash_mismatch?' do
158
158
  context 'when request type has no body' do
159
159
  let(:request) do
160
160
  Net::HTTP::Get.new(request_path, request_headers)
161
161
  end
162
162
 
163
163
  it 'is false' do
164
- expect(driven_request.md5_mismatch?).to be false
164
+ expect(driven_request.content_hash_mismatch?).to be false
165
165
  end
166
166
  end
167
167
 
@@ -174,21 +174,21 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
174
174
 
175
175
  context 'when calculated matches sent' do
176
176
  before do
177
- request['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
177
+ request['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
178
178
  end
179
179
 
180
180
  it 'is false' do
181
- expect(driven_request.md5_mismatch?).to be false
181
+ expect(driven_request.content_hash_mismatch?).to be false
182
182
  end
183
183
  end
184
184
 
185
185
  context "when calculated doesn't match sent" do
186
186
  before do
187
- request['Content-MD5'] = '3'
187
+ request['X-Authorization-Content-SHA256'] = '3'
188
188
  end
189
189
 
190
190
  it 'is true' do
191
- expect(driven_request.md5_mismatch?).to be true
191
+ expect(driven_request.content_hash_mismatch?).to be true
192
192
  end
193
193
  end
194
194
  end
@@ -8,7 +8,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
8
8
  let(:request_headers) do
9
9
  {
10
10
  'Authorization' => 'APIAuth 1044:12345',
11
- 'Content-MD5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
11
+ 'X-Authorization-Content-SHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
12
12
  'Content-Type' => 'text/plain',
13
13
  'Date' => timestamp
14
14
  }
@@ -31,8 +31,8 @@ describe ApiAuth::RequestDrivers::RackRequest do
31
31
  expect(driven_request.content_type).to eq('text/plain')
32
32
  end
33
33
 
34
- it 'gets the content_md5' do
35
- expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
34
+ it 'gets the content_hash' do
35
+ expect(driven_request.content_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
36
36
  end
37
37
 
38
38
  it 'gets the request_uri' do
@@ -47,9 +47,9 @@ describe ApiAuth::RequestDrivers::RackRequest do
47
47
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
48
48
  end
49
49
 
50
- describe '#calculated_md5' do
51
- it 'calculates md5 from the body' do
52
- expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
50
+ describe '#calculated_hash' do
51
+ it 'calculates hash from the body' do
52
+ expect(driven_request.calculated_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
53
53
  end
54
54
 
55
55
  it 'treats no body as empty string' do
@@ -60,7 +60,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
60
60
  ).merge!(request_headers)
61
61
  )
62
62
  driven_request = ApiAuth::RequestDrivers::RackRequest.new(request)
63
- expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
63
+ expect(driven_request.calculated_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
64
64
  end
65
65
  end
66
66
 
@@ -104,7 +104,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
104
104
  }
105
105
  end
106
106
 
107
- describe '#populate_content_md5' do
107
+ describe '#populate_content_hash' do
108
108
  context 'when getting' do
109
109
  let(:request) do
110
110
  Rack::Request.new(
@@ -115,9 +115,9 @@ describe ApiAuth::RequestDrivers::RackRequest do
115
115
  )
116
116
  end
117
117
 
118
- it "doesn't populate content-md5" do
119
- driven_request.populate_content_md5
120
- expect(request.env['Content-MD5']).to be_nil
118
+ it "doesn't populate content hash" do
119
+ driven_request.populate_content_hash
120
+ expect(request.env['X-Authorization-Content-SHA256']).to be_nil
121
121
  end
122
122
  end
123
123
 
@@ -132,14 +132,14 @@ describe ApiAuth::RequestDrivers::RackRequest do
132
132
  )
133
133
  end
134
134
 
135
- it 'populates content-md5' do
136
- driven_request.populate_content_md5
137
- expect(request.env['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
135
+ it 'populates content hash' do
136
+ driven_request.populate_content_hash
137
+ expect(request.env['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
138
138
  end
139
139
 
140
140
  it 'refreshes the cached headers' do
141
- driven_request.populate_content_md5
142
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
141
+ driven_request.populate_content_hash
142
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
143
143
  end
144
144
  end
145
145
 
@@ -154,14 +154,14 @@ describe ApiAuth::RequestDrivers::RackRequest do
154
154
  )
155
155
  end
156
156
 
157
- it 'populates content-md5' do
158
- driven_request.populate_content_md5
159
- expect(request.env['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
157
+ it 'populates content hash' do
158
+ driven_request.populate_content_hash
159
+ expect(request.env['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
160
160
  end
161
161
 
162
162
  it 'refreshes the cached headers' do
163
- driven_request.populate_content_md5
164
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
163
+ driven_request.populate_content_hash
164
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
165
165
  end
166
166
  end
167
167
 
@@ -175,9 +175,9 @@ describe ApiAuth::RequestDrivers::RackRequest do
175
175
  )
176
176
  end
177
177
 
178
- it "doesn't populate content-md5" do
179
- driven_request.populate_content_md5
180
- expect(request.env['Content-MD5']).to be_nil
178
+ it "doesn't populate content hash" do
179
+ driven_request.populate_content_hash
180
+ expect(request.env['X-Authorization-Content-SHA256']).to be_nil
181
181
  end
182
182
  end
183
183
  end
@@ -206,7 +206,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
206
206
  end
207
207
  end
208
208
 
209
- describe 'md5_mismatch?' do
209
+ describe 'content_hash_mismatch?' do
210
210
  context 'when getting' do
211
211
  let(:request) do
212
212
  Rack::Request.new(
@@ -218,7 +218,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
218
218
  end
219
219
 
220
220
  it 'is false' do
221
- expect(driven_request.md5_mismatch?).to be false
221
+ expect(driven_request.content_hash_mismatch?).to be false
222
222
  end
223
223
  end
224
224
 
@@ -235,21 +235,21 @@ describe ApiAuth::RequestDrivers::RackRequest do
235
235
 
236
236
  context 'when calculated matches sent' do
237
237
  before do
238
- request.env['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
238
+ request.env['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
239
239
  end
240
240
 
241
241
  it 'is false' do
242
- expect(driven_request.md5_mismatch?).to be false
242
+ expect(driven_request.content_hash_mismatch?).to be false
243
243
  end
244
244
  end
245
245
 
246
246
  context "when calculated doesn't match sent" do
247
247
  before do
248
- request.env['Content-MD5'] = '3'
248
+ request.env['X-Authorization-Content-SHA256'] = '3'
249
249
  end
250
250
 
251
251
  it 'is true' do
252
- expect(driven_request.md5_mismatch?).to be true
252
+ expect(driven_request.content_hash_mismatch?).to be true
253
253
  end
254
254
  end
255
255
  end
@@ -267,21 +267,21 @@ describe ApiAuth::RequestDrivers::RackRequest do
267
267
 
268
268
  context 'when calculated matches sent' do
269
269
  before do
270
- request.env['Content-MD5'] = 'kZXQvrKoieG+Be1rsZVINw=='
270
+ request.env['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
271
271
  end
272
272
 
273
273
  it 'is false' do
274
- expect(driven_request.md5_mismatch?).to be false
274
+ expect(driven_request.content_hash_mismatch?).to be false
275
275
  end
276
276
  end
277
277
 
278
278
  context "when calculated doesn't match sent" do
279
279
  before do
280
- request.env['Content-MD5'] = '3'
280
+ request.env['X-Authorization-Content-SHA256'] = '3'
281
281
  end
282
282
 
283
283
  it 'is true' do
284
- expect(driven_request.md5_mismatch?).to be true
284
+ expect(driven_request.content_hash_mismatch?).to be true
285
285
  end
286
286
  end
287
287
  end
@@ -297,7 +297,7 @@ describe ApiAuth::RequestDrivers::RackRequest do
297
297
  end
298
298
 
299
299
  it 'is false' do
300
- expect(driven_request.md5_mismatch?).to be false
300
+ expect(driven_request.content_hash_mismatch?).to be false
301
301
  end
302
302
  end
303
303
  end
@@ -8,7 +8,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
8
8
  let(:request_headers) do
9
9
  {
10
10
  'Authorization' => 'APIAuth 1044:12345',
11
- 'Content-MD5' => '1B2M2Y8AsgTpgAmY7PhCfg==',
11
+ 'X-Authorization-Content-SHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
12
12
  'Content-Type' => 'text/plain',
13
13
  'Date' => timestamp
14
14
  }
@@ -30,8 +30,8 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
30
30
  expect(driven_request.content_type).to eq('text/plain')
31
31
  end
32
32
 
33
- it 'gets the content_md5' do
34
- expect(driven_request.content_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
33
+ it 'gets the content_hash' do
34
+ expect(driven_request.content_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
35
35
  end
36
36
 
37
37
  it 'gets the request_uri' do
@@ -46,9 +46,9 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
46
46
  expect(driven_request.authorization_header).to eq('APIAuth 1044:12345')
47
47
  end
48
48
 
49
- describe '#calculated_md5' do
50
- it 'calculates md5 from the body' do
51
- expect(driven_request.calculated_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
49
+ describe '#calculated_hash' do
50
+ it 'calculates hash from the body' do
51
+ expect(driven_request.calculated_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
52
52
  end
53
53
 
54
54
  it 'treats no body as empty string' do
@@ -58,7 +58,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
58
58
  method: :put
59
59
  )
60
60
  driven_request = ApiAuth::RequestDrivers::RestClientRequest.new(request)
61
- expect(driven_request.calculated_md5).to eq('1B2M2Y8AsgTpgAmY7PhCfg==')
61
+ expect(driven_request.calculated_hash).to eq('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=')
62
62
  end
63
63
  end
64
64
 
@@ -100,7 +100,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
100
100
  }
101
101
  end
102
102
 
103
- describe '#populate_content_md5' do
103
+ describe '#populate_content_hash' do
104
104
  context 'when getting' do
105
105
  let(:request) do
106
106
  RestClient::Request.new(
@@ -110,9 +110,9 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
110
110
  )
111
111
  end
112
112
 
113
- it "doesn't populate content-md5" do
114
- driven_request.populate_content_md5
115
- expect(request.headers['Content-MD5']).to be_nil
113
+ it "doesn't populate content hash" do
114
+ driven_request.populate_content_hash
115
+ expect(request.headers['X-Authorization-Content-SHA256']).to be_nil
116
116
  end
117
117
  end
118
118
 
@@ -126,14 +126,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
126
126
  )
127
127
  end
128
128
 
129
- it 'populates content-md5' do
130
- driven_request.populate_content_md5
131
- expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
129
+ it 'populates content hash' do
130
+ driven_request.populate_content_hash
131
+ expect(request.headers['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
132
132
  end
133
133
 
134
134
  it 'refreshes the cached headers' do
135
- driven_request.populate_content_md5
136
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
135
+ driven_request.populate_content_hash
136
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
137
137
  end
138
138
  end
139
139
 
@@ -147,14 +147,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
147
147
  )
148
148
  end
149
149
 
150
- it 'populates content-md5' do
151
- driven_request.populate_content_md5
152
- expect(request.headers['Content-MD5']).to eq('kZXQvrKoieG+Be1rsZVINw==')
150
+ it 'populates content hash' do
151
+ driven_request.populate_content_hash
152
+ expect(request.headers['X-Authorization-Content-SHA256']).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
153
153
  end
154
154
 
155
155
  it 'refreshes the cached headers' do
156
- driven_request.populate_content_md5
157
- expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
156
+ driven_request.populate_content_hash
157
+ expect(driven_request.content_hash).to eq('JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=')
158
158
  end
159
159
  end
160
160
 
@@ -167,9 +167,9 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
167
167
  )
168
168
  end
169
169
 
170
- it "doesn't populate content-md5" do
171
- driven_request.populate_content_md5
172
- expect(request.headers['Content-MD5']).to be_nil
170
+ it "doesn't populate content hash" do
171
+ driven_request.populate_content_hash
172
+ expect(request.headers['X-Authorization-Content-SHA256']).to be_nil
173
173
  end
174
174
  end
175
175
  end
@@ -199,7 +199,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
199
199
  end
200
200
  end
201
201
 
202
- describe 'md5_mismatch?' do
202
+ describe 'content_hash_mismatch?' do
203
203
  context 'when getting' do
204
204
  let(:request) do
205
205
  RestClient::Request.new(
@@ -210,7 +210,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
210
210
  end
211
211
 
212
212
  it 'is false' do
213
- expect(driven_request.md5_mismatch?).to be false
213
+ expect(driven_request.content_hash_mismatch?).to be false
214
214
  end
215
215
  end
216
216
 
@@ -228,14 +228,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
228
228
  let(:request_headers) do
229
229
  {
230
230
  'Authorization' => 'APIAuth 1044:12345',
231
- 'Content-MD5' => 'kZXQvrKoieG+Be1rsZVINw==',
231
+ 'X-Authorization-Content-SHA256' => 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=',
232
232
  'Content-Type' => 'text/plain',
233
233
  'Date' => timestamp
234
234
  }
235
235
  end
236
236
 
237
237
  it 'is false' do
238
- expect(driven_request.md5_mismatch?).to be false
238
+ expect(driven_request.content_hash_mismatch?).to be false
239
239
  end
240
240
  end
241
241
 
@@ -243,14 +243,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
243
243
  let(:request_headers) do
244
244
  {
245
245
  'Authorization' => 'APIAuth 1044:12345',
246
- 'Content-MD5' => '3',
246
+ 'X-Authorization-Content-SHA256' => '3',
247
247
  'Content-Type' => 'text/plain',
248
248
  'Date' => timestamp
249
249
  }
250
250
  end
251
251
 
252
252
  it 'is true' do
253
- expect(driven_request.md5_mismatch?).to be true
253
+ expect(driven_request.content_hash_mismatch?).to be true
254
254
  end
255
255
  end
256
256
  end
@@ -269,14 +269,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
269
269
  let(:request_headers) do
270
270
  {
271
271
  'Authorization' => 'APIAuth 1044:12345',
272
- 'Content-MD5' => 'kZXQvrKoieG+Be1rsZVINw==',
272
+ 'X-Authorization-Content-SHA256' => 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g=',
273
273
  'Content-Type' => 'text/plain',
274
274
  'Date' => timestamp
275
275
  }
276
276
  end
277
277
 
278
278
  it 'is false' do
279
- expect(driven_request.md5_mismatch?).to be false
279
+ expect(driven_request.content_hash_mismatch?).to be false
280
280
  end
281
281
  end
282
282
 
@@ -284,14 +284,14 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
284
284
  let(:request_headers) do
285
285
  {
286
286
  'Authorization' => 'APIAuth 1044:12345',
287
- 'Content-MD5' => '3',
287
+ 'X-Authorization-Content-SHA256' => '3',
288
288
  'Content-Type' => 'text/plain',
289
289
  'Date' => timestamp
290
290
  }
291
291
  end
292
292
 
293
293
  it 'is true' do
294
- expect(driven_request.md5_mismatch?).to be true
294
+ expect(driven_request.content_hash_mismatch?).to be true
295
295
  end
296
296
  end
297
297
  end
@@ -306,7 +306,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
306
306
  end
307
307
 
308
308
  it 'is false' do
309
- expect(driven_request.md5_mismatch?).to be false
309
+ expect(driven_request.content_hash_mismatch?).to be false
310
310
  end
311
311
  end
312
312
  end
@@ -385,7 +385,7 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
385
385
 
386
386
  describe 'edge cases' do
387
387
  it "doesn't mess up symbol based headers" do
388
- headers = { 'Content-MD5' => 'e59ff97941044f85df5297e1c302d260',
388
+ headers = { 'X-Authorization-Content-SHA256' => 'e59ff97941044f85df5297e1c302d260',
389
389
  :content_type => 'text/plain',
390
390
  'Date' => 'Mon, 23 Jan 1984 03:29:56 GMT' }
391
391
  request = RestClient::Request.new(url: 'http://localhost/resource.xml?foo=bar&bar=foo',