api-auth 2.4.1 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +67 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +15 -2
- data/.rubocop_todo.yml +29 -19
- data/Appraisals +12 -18
- data/CHANGELOG.md +8 -0
- data/Gemfile +0 -2
- data/README.md +29 -27
- data/VERSION +1 -1
- data/api_auth.gemspec +11 -4
- data/gemfiles/rails_52.gemfile +5 -5
- data/gemfiles/rails_60.gemfile +5 -7
- data/gemfiles/rails_61.gemfile +9 -0
- data/lib/api_auth/base.rb +2 -2
- data/lib/api_auth/headers.rb +6 -6
- data/lib/api_auth/helpers.rb +2 -2
- data/lib/api_auth/railtie.rb +3 -1
- data/lib/api_auth/request_drivers/action_controller.rb +8 -8
- data/lib/api_auth/request_drivers/curb.rb +4 -4
- data/lib/api_auth/request_drivers/faraday.rb +11 -11
- data/lib/api_auth/request_drivers/grape_request.rb +8 -8
- data/lib/api_auth/request_drivers/http.rb +8 -8
- data/lib/api_auth/request_drivers/httpi.rb +8 -8
- data/lib/api_auth/request_drivers/net_http.rb +8 -8
- data/lib/api_auth/request_drivers/rack.rb +8 -8
- data/lib/api_auth/request_drivers/rest_client.rb +8 -8
- data/spec/api_auth_spec.rb +8 -8
- data/spec/headers_spec.rb +26 -26
- data/spec/helpers_spec.rb +1 -1
- data/spec/railtie_spec.rb +3 -3
- data/spec/request_drivers/action_controller_spec.rb +74 -35
- data/spec/request_drivers/action_dispatch_spec.rb +74 -35
- data/spec/request_drivers/curb_spec.rb +8 -8
- data/spec/request_drivers/faraday_spec.rb +43 -43
- data/spec/request_drivers/grape_request_spec.rb +33 -32
- data/spec/request_drivers/http_spec.rb +23 -23
- data/spec/request_drivers/httpi_spec.rb +22 -22
- data/spec/request_drivers/net_http_spec.rb +23 -23
- data/spec/request_drivers/rack_spec.rb +35 -35
- data/spec/request_drivers/rest_client_spec.rb +36 -36
- metadata +48 -23
- data/.travis.yml +0 -37
- data/gemfiles/http2.gemfile +0 -7
- data/gemfiles/http3.gemfile +0 -7
- data/gemfiles/http4.gemfile +0 -7
- data/gemfiles/rails_5.gemfile +0 -9
- data/gemfiles/rails_51.gemfile +0 -9
- data/spec/.rubocop.yml +0 -5
@@ -8,7 +8,7 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
|
|
8
8
|
let(:request_headers) do
|
9
9
|
{
|
10
10
|
'Authorization' => 'APIAuth 1044:12345',
|
11
|
-
'
|
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
|
40
|
-
expect(driven_request.
|
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 '#
|
56
|
-
it '
|
57
|
-
expect(driven_request.
|
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.
|
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.
|
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 '#
|
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
|
109
|
-
driven_request.
|
110
|
-
expect(request['Content-
|
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
|
122
|
-
driven_request.
|
123
|
-
expect(request['Content-
|
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.
|
128
|
-
expect(driven_request.
|
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 '
|
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.
|
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-
|
177
|
+
request['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'is false' do
|
181
|
-
expect(driven_request.
|
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-
|
187
|
+
request['X-Authorization-Content-SHA256'] = '3'
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'is true' do
|
191
|
-
expect(driven_request.
|
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-
|
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
|
35
|
-
expect(driven_request.
|
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 '#
|
51
|
-
it 'calculates
|
52
|
-
expect(driven_request.
|
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.
|
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 '#
|
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
|
119
|
-
driven_request.
|
120
|
-
expect(request.env['Content-
|
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
|
136
|
-
driven_request.
|
137
|
-
expect(request.env['Content-
|
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.
|
142
|
-
expect(driven_request.
|
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
|
158
|
-
driven_request.
|
159
|
-
expect(request.env['Content-
|
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.
|
164
|
-
expect(driven_request.
|
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
|
179
|
-
driven_request.
|
180
|
-
expect(request.env['Content-
|
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 '
|
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.
|
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-
|
238
|
+
request.env['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
|
239
239
|
end
|
240
240
|
|
241
241
|
it 'is false' do
|
242
|
-
expect(driven_request.
|
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-
|
248
|
+
request.env['X-Authorization-Content-SHA256'] = '3'
|
249
249
|
end
|
250
250
|
|
251
251
|
it 'is true' do
|
252
|
-
expect(driven_request.
|
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-
|
270
|
+
request.env['X-Authorization-Content-SHA256'] = 'JsYKYdAdtYNspw/v1EpqAWYgQTyO9fJZpsVhLU9507g='
|
271
271
|
end
|
272
272
|
|
273
273
|
it 'is false' do
|
274
|
-
expect(driven_request.
|
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-
|
280
|
+
request.env['X-Authorization-Content-SHA256'] = '3'
|
281
281
|
end
|
282
282
|
|
283
283
|
it 'is true' do
|
284
|
-
expect(driven_request.
|
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.
|
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-
|
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
|
34
|
-
expect(driven_request.
|
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 '#
|
50
|
-
it 'calculates
|
51
|
-
expect(driven_request.
|
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.
|
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 '#
|
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
|
114
|
-
driven_request.
|
115
|
-
expect(request.headers['Content-
|
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
|
130
|
-
driven_request.
|
131
|
-
expect(request.headers['Content-
|
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.
|
136
|
-
expect(driven_request.
|
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
|
151
|
-
driven_request.
|
152
|
-
expect(request.headers['Content-
|
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.
|
157
|
-
expect(driven_request.
|
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
|
171
|
-
driven_request.
|
172
|
-
expect(request.headers['Content-
|
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 '
|
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.
|
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-
|
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.
|
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-
|
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.
|
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-
|
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.
|
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-
|
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.
|
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.
|
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-
|
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',
|