hoodoo 2.8.0 → 2.9.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18fc233fa796b76a8275e120ca461c417262e23ead78bc600171506feb851b13
|
4
|
+
data.tar.gz: 3c8aaa457667904c1fb073e8423241f6455f3e78b1339ab36b99f7601481fb50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb400413ec681232584714aa0b58efc50ec8c15eacc2814372c38fee617c99d83c7899cd807dfdda9469f91790cda63f39958f11acb37a8015564b019a9bebf
|
7
|
+
data.tar.gz: 8280be1231ab84f35fccf6872eea53923040229e6355afe891bd356a6b2fc7d1e608a5725ab26d3ec13e459a0b8806a9896190c921d5f0d10f9d6435a3bfe8b0
|
@@ -2266,6 +2266,9 @@ module Hoodoo; module Services
|
|
2266
2266
|
return nil
|
2267
2267
|
end
|
2268
2268
|
|
2269
|
+
elsif rules_value == '*'
|
2270
|
+
identity_overrides[ rules_key ] = input_value
|
2271
|
+
|
2269
2272
|
elsif rules_value.is_a?( Hash )
|
2270
2273
|
if rules_value.has_key?( input_value )
|
2271
2274
|
identity_overrides[ rules_key ] = input_value
|
data/lib/hoodoo/version.rb
CHANGED
@@ -12,11 +12,11 @@ module Hoodoo
|
|
12
12
|
# The Hoodoo gem version. If this changes, be sure to re-run
|
13
13
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
14
14
|
#
|
15
|
-
VERSION = '2.
|
15
|
+
VERSION = '2.9.0'
|
16
16
|
|
17
17
|
# The Hoodoo gem date. If this changes, be sure to re-run
|
18
18
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
19
19
|
#
|
20
|
-
DATE = '2018-08-
|
20
|
+
DATE = '2018-08-21'
|
21
21
|
|
22
22
|
end
|
@@ -152,279 +152,436 @@ describe Hoodoo::Services::Middleware do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
context 'with flat rules' do
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'rejects bad account ID' do
|
168
|
-
result = show( { 'account_id' => 'bad' }, 403 )
|
169
|
-
|
170
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
171
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
172
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
173
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
174
|
-
end
|
155
|
+
context 'and no wildcards' do
|
156
|
+
before :each do
|
157
|
+
@test_session.scoping.authorised_http_headers = [ 'X-Assume-Identity-Of' ]
|
158
|
+
@test_session.scoping.authorised_identities =
|
159
|
+
{
|
160
|
+
'account_id' => [ '20', '21', '22' ],
|
161
|
+
'member_id' => [ '1', '2', '3', '4', '5', '6' ],
|
162
|
+
'device_id' => [ 'A', 'B' ]
|
163
|
+
}
|
175
164
|
|
176
|
-
|
177
|
-
|
165
|
+
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'rejects bad account ID' do
|
169
|
+
result = show( { 'account_id' => 'bad' }, 403 )
|
170
|
+
|
171
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
172
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
173
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
174
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'rejects bad member ID' do
|
178
|
+
result = show( { 'member_id' => 'bad' }, 403 )
|
179
|
+
|
180
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
181
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
182
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
183
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'rejects bad device ID' do
|
187
|
+
result = show( { 'device_id' => 'bad' }, 403 )
|
188
|
+
|
189
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
190
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
191
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
192
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
193
|
+
end
|
194
|
+
|
195
|
+
# Belt-and-braces check that multiple bad items are still rejected,
|
196
|
+
# but don't have any expectations about which one gets picked out
|
197
|
+
# in the 'reference' field.
|
198
|
+
#
|
199
|
+
it 'rejects bad combinations' do
|
200
|
+
result = show( { 'account_id' => 'bad', 'member_id' => 'bad', 'device_id' => 'bad' }, 403 )
|
201
|
+
|
202
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
203
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
204
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'rejects bad IDs amongst good' do
|
208
|
+
result = show( { 'account_id' => '21', 'member_id' => 'bad', 'device_id' => 'A' }, 403 )
|
209
|
+
|
210
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
211
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
212
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
213
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
214
|
+
end
|
215
|
+
|
216
|
+
# Each 'show' must be in its own test so that the test session data
|
217
|
+
# gets reset in between; otherwise, the *same* session identity is
|
218
|
+
# being successively merged/updated under test, since it's a single
|
219
|
+
# object that's reused rather than a new loaded-in session.
|
220
|
+
#
|
221
|
+
it 'accepts one good ID (1)' do
|
222
|
+
result = show( { 'account_id' => '22' }, 200 )
|
223
|
+
end
|
224
|
+
it 'accepts one good ID (2)' do
|
225
|
+
result = show( { 'member_id' => '1' }, 200 )
|
226
|
+
end
|
227
|
+
it 'accepts one good ID (3)' do
|
228
|
+
result = show( { 'device_id' => 'B' }, 200 )
|
229
|
+
end
|
230
|
+
it 'accepts many good IDs' do
|
231
|
+
result = show( { 'account_id' => '22', 'member_id' => '1', 'device_id' => 'B' }, 200 )
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'accepts encoded names' do
|
235
|
+
get(
|
236
|
+
'/v1/rspec_assumed_identity/hello',
|
237
|
+
nil,
|
238
|
+
{
|
239
|
+
'CONTENT_TYPE' => 'application/json; charset=utf-8',
|
240
|
+
'HTTP_X_ASSUME_IDENTITY_OF' => 'a%63%63ount_id=22'
|
241
|
+
}
|
242
|
+
)
|
178
243
|
|
179
|
-
|
180
|
-
|
181
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
182
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
183
|
-
end
|
244
|
+
expect( last_response.status ).to eq( 200 )
|
245
|
+
end
|
184
246
|
|
185
|
-
|
186
|
-
|
247
|
+
it 'accepts encoded values' do
|
248
|
+
get(
|
249
|
+
'/v1/rspec_assumed_identity/hello',
|
250
|
+
nil,
|
251
|
+
{
|
252
|
+
'CONTENT_TYPE' => 'application/json; charset=utf-8',
|
253
|
+
'HTTP_X_ASSUME_IDENTITY_OF' => 'account_id=%32%32'
|
254
|
+
}
|
255
|
+
)
|
187
256
|
|
188
|
-
|
189
|
-
|
190
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
191
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
192
|
-
end
|
257
|
+
expect( last_response.status ).to eq( 200 )
|
258
|
+
end
|
193
259
|
|
194
|
-
|
195
|
-
|
196
|
-
# in the 'reference' field.
|
197
|
-
#
|
198
|
-
it 'rejects bad combinations' do
|
199
|
-
result = show( { 'account_id' => 'bad', 'member_id' => 'bad', 'device_id' => 'bad' }, 403 )
|
260
|
+
it 'rejects an unknown name' do
|
261
|
+
result = show( { 'another_id' => 'A155C' }, 403 )
|
200
262
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
263
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
264
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
265
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
266
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
267
|
+
end
|
205
268
|
|
206
|
-
|
207
|
-
|
269
|
+
it 'rejects unknown names' do
|
270
|
+
result = show( { 'another_id' => 'A155C', 'additional_id' => 'iiv' }, 403 )
|
208
271
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
272
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
273
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
274
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
275
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'additional_id\\,another_id' )
|
276
|
+
end
|
214
277
|
|
215
|
-
|
216
|
-
|
217
|
-
# being successively merged/updated under test, since it's a single
|
218
|
-
# object that's reused rather than a new loaded-in session.
|
219
|
-
#
|
220
|
-
it 'accepts one good ID (1)' do
|
221
|
-
result = show( { 'account_id' => '22' }, 200 )
|
222
|
-
end
|
223
|
-
it 'accepts one good ID (2)' do
|
224
|
-
result = show( { 'member_id' => '1' }, 200 )
|
225
|
-
end
|
226
|
-
it 'accepts one good ID (3)' do
|
227
|
-
result = show( { 'device_id' => 'B' }, 200 )
|
228
|
-
end
|
278
|
+
it 'rejects an unknown name amongst a known name' do
|
279
|
+
result = show( { 'another_id' => 'A155C', 'account_id' => '22' }, 403 )
|
229
280
|
|
230
|
-
|
231
|
-
|
232
|
-
|
281
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
282
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
283
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
284
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
285
|
+
end
|
233
286
|
|
234
|
-
|
235
|
-
|
236
|
-
'/v1/rspec_assumed_identity/hello',
|
237
|
-
nil,
|
238
|
-
{
|
239
|
-
'CONTENT_TYPE' => 'application/json; charset=utf-8',
|
240
|
-
'HTTP_X_ASSUME_IDENTITY_OF' => 'a%63%63ount_id=22'
|
241
|
-
}
|
242
|
-
)
|
287
|
+
it 'rejects an unknown name amongst known names' do
|
288
|
+
result = show( { 'another_id' => 'A155C', 'account_id' => '22', 'member_id' => '1' }, 403 )
|
243
289
|
|
244
|
-
|
290
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
291
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
292
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
293
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
294
|
+
end
|
245
295
|
end
|
246
296
|
|
247
|
-
|
248
|
-
|
249
|
-
'
|
250
|
-
|
297
|
+
context 'and wildcards' do
|
298
|
+
before :each do
|
299
|
+
@test_session.scoping.authorised_http_headers = [ 'X-Assume-Identity-Of' ]
|
300
|
+
@test_session.scoping.authorised_identities =
|
251
301
|
{
|
252
|
-
'
|
253
|
-
'
|
302
|
+
'account_id' => [ '20', '21', '22' ],
|
303
|
+
'member_id' => '*',
|
304
|
+
'device_id' => [ 'A', 'B' ]
|
254
305
|
}
|
255
|
-
)
|
256
|
-
|
257
|
-
expect( last_response.status ).to eq( 200 )
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'rejects an unknown name' do
|
261
|
-
result = show( { 'another_id' => 'A155C' }, 403 )
|
262
|
-
|
263
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
264
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
265
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
266
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
267
|
-
end
|
268
|
-
|
269
|
-
it 'rejects unknown names' do
|
270
|
-
result = show( { 'another_id' => 'A155C', 'additional_id' => 'iiv' }, 403 )
|
271
306
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
307
|
+
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'rejects bad account ID' do
|
311
|
+
result = show( { 'account_id' => 'bad' }, 403 )
|
312
|
+
|
313
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
314
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
315
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
316
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'rejects bad device ID' do
|
320
|
+
result = show( { 'device_id' => 'bad' }, 403 )
|
321
|
+
|
322
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
323
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
324
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
325
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'rejects bad combinations' do
|
329
|
+
result = show( { 'account_id' => 'bad', 'member_id' => 'hit_wildcard', 'device_id' => 'bad' }, 403 )
|
330
|
+
|
331
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
332
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
333
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'rejects bad IDs amongst good' do
|
337
|
+
result = show( { 'account_id' => '21', 'member_id' => 'hit_wildcard', 'device_id' => 'bad' }, 403 )
|
338
|
+
|
339
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
340
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
341
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
342
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'accepts wildcard combinations' do
|
346
|
+
result = show( { 'account_id' => '21', 'member_id' => 'hit_wildcard', 'device_id' => 'A' }, 200 )
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'accepts one good ID (1)' do
|
350
|
+
result = show( { 'account_id' => '22' }, 200 )
|
351
|
+
end
|
352
|
+
it 'accepts one good ID (2)' do
|
353
|
+
result = show( { 'member_id' => 'hit_wildcard' }, 200 )
|
354
|
+
end
|
355
|
+
it 'accepts one good ID (3)' do
|
356
|
+
result = show( { 'device_id' => 'B' }, 200 )
|
357
|
+
end
|
358
|
+
it 'accepts many good IDs' do
|
359
|
+
result = show( { 'account_id' => '22', 'member_id' => '1', 'device_id' => 'B' }, 200 )
|
360
|
+
end
|
294
361
|
end
|
295
362
|
end
|
296
363
|
|
297
364
|
context 'with deep rules' do
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
'account_id' =>
|
365
|
+
context 'and no wildcards' do
|
366
|
+
before :each do
|
367
|
+
@test_session.scoping.authorised_http_headers = [ 'X-Assume-Identity-Of' ]
|
368
|
+
@test_session.scoping.authorised_identities =
|
303
369
|
{
|
304
|
-
'
|
305
|
-
'21' => { 'member_id' => [ '3', '4' ] },
|
306
|
-
'22' =>
|
370
|
+
'account_id' =>
|
307
371
|
{
|
308
|
-
'member_id' =>
|
372
|
+
'20' => { 'member_id' => [ '1', '2' ] },
|
373
|
+
'21' => { 'member_id' => [ '3', '4' ] },
|
374
|
+
'22' =>
|
309
375
|
{
|
310
|
-
'
|
311
|
-
|
376
|
+
'member_id' =>
|
377
|
+
{
|
378
|
+
'5' => { 'device_id' => [ 'A' ] },
|
379
|
+
'6' => { 'device_id' => [ 'B' ] }
|
380
|
+
}
|
312
381
|
}
|
313
382
|
}
|
314
383
|
}
|
315
|
-
}
|
316
|
-
|
317
|
-
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
318
|
-
end
|
319
|
-
|
320
|
-
it 'rejects bad account ID' do
|
321
|
-
result = show( { 'account_id' => 'bad' }, 403 )
|
322
|
-
|
323
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
324
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
325
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
326
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
327
|
-
end
|
328
|
-
|
329
|
-
it 'rejects bad member ID' do
|
330
|
-
result = show( { 'account_id' => '20', 'member_id' => 'bad' }, 403 )
|
331
|
-
|
332
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
333
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
334
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
335
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
336
|
-
end
|
337
|
-
|
338
|
-
it 'rejects bad device ID' do
|
339
|
-
result = show( { 'account_id' => '22', 'member_id' => '5', 'device_id' => 'bad' }, 403 )
|
340
|
-
|
341
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
342
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
343
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
344
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
345
|
-
end
|
346
|
-
|
347
|
-
it 'rejects attempt to use device ID when not listed in rules' do
|
348
|
-
result = show( { 'account_id' => '21', 'member_id' => '4', 'device_id' => 'A' }, 403 )
|
349
|
-
|
350
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
351
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
352
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
353
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id' )
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'rejects an ID that is present but listed under a different key' do
|
357
|
-
result = show( { 'account_id' => '20', 'member_id' => '4' }, 403 )
|
358
|
-
|
359
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
360
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
361
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
362
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,4' )
|
363
|
-
end
|
364
|
-
|
365
|
-
it 'rejects an ID that is present but not top-level' do
|
366
|
-
result = show( { 'member_id' => '1' }, 403 )
|
367
|
-
|
368
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
369
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
370
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
371
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id' )
|
372
|
-
end
|
373
|
-
|
374
|
-
# Each 'show' must be in its own test so that the test session data
|
375
|
-
# gets reset in between; otherwise, the *same* session identity is
|
376
|
-
# being successively merged/updated under test, since it's a single
|
377
|
-
# object that's reused rather than a new loaded-in session.
|
378
|
-
#
|
379
|
-
it 'accepts a subset of good IDs (1)' do
|
380
|
-
result = show( { 'account_id' => '22' }, 200 )
|
381
|
-
end
|
382
|
-
it 'accepts a subset of good IDs (2)' do
|
383
|
-
result = show( { 'account_id' => '22', 'member_id' => '5' }, 200 )
|
384
|
-
end
|
385
|
-
it 'accepts many good IDs (1)' do
|
386
|
-
result = show( { 'account_id' => '20', 'member_id' => '2' }, 200 )
|
387
|
-
end
|
388
|
-
it 'accepts many good IDs (2)' do
|
389
|
-
result = show( { 'account_id' => '22', 'member_id' => '6', 'device_id' => 'B' }, 200 )
|
390
|
-
end
|
391
|
-
|
392
|
-
it 'rejects an unknown name' do
|
393
|
-
result = show( { 'another_id' => 'A155C' }, 403 )
|
394
|
-
|
395
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
396
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
397
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
398
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
399
|
-
end
|
400
|
-
|
401
|
-
it 'rejects unknown names' do
|
402
|
-
result = show( { 'another_id' => 'A155C', 'additional_id' => 'iiv' }, 403 )
|
403
|
-
|
404
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
405
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
406
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
407
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'additional_id\\,another_id' )
|
408
|
-
end
|
409
|
-
|
410
|
-
it 'rejects an unknown name amongst a known name' do
|
411
|
-
result = show( { 'another_id' => 'A155C', 'account_id' => '22' }, 403 )
|
412
|
-
|
413
|
-
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
414
|
-
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
415
|
-
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
416
|
-
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
417
|
-
end
|
418
384
|
|
419
|
-
|
420
|
-
|
385
|
+
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'rejects bad account ID' do
|
389
|
+
result = show( { 'account_id' => 'bad' }, 403 )
|
390
|
+
|
391
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
392
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
393
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
394
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'rejects bad member ID' do
|
398
|
+
result = show( { 'account_id' => '20', 'member_id' => 'bad' }, 403 )
|
399
|
+
|
400
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
401
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
402
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
403
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'rejects bad device ID' do
|
407
|
+
result = show( { 'account_id' => '22', 'member_id' => '5', 'device_id' => 'bad' }, 403 )
|
408
|
+
|
409
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
410
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
411
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
412
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
413
|
+
end
|
414
|
+
|
415
|
+
it 'rejects attempt to use device ID when not listed in rules' do
|
416
|
+
result = show( { 'account_id' => '21', 'member_id' => '4', 'device_id' => 'A' }, 403 )
|
417
|
+
|
418
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
419
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
420
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
421
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id' )
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'rejects an ID that is present but listed under a different key' do
|
425
|
+
result = show( { 'account_id' => '20', 'member_id' => '4' }, 403 )
|
426
|
+
|
427
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
428
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
429
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
430
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,4' )
|
431
|
+
end
|
432
|
+
|
433
|
+
it 'rejects an ID that is present but not top-level' do
|
434
|
+
result = show( { 'member_id' => '1' }, 403 )
|
435
|
+
|
436
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
437
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
438
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
439
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id' )
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'accepts a subset of good IDs (1)' do
|
443
|
+
result = show( { 'account_id' => '22' }, 200 )
|
444
|
+
end
|
445
|
+
it 'accepts a subset of good IDs (2)' do
|
446
|
+
result = show( { 'account_id' => '22', 'member_id' => '5' }, 200 )
|
447
|
+
end
|
448
|
+
it 'accepts many good IDs (1)' do
|
449
|
+
result = show( { 'account_id' => '20', 'member_id' => '2' }, 200 )
|
450
|
+
end
|
451
|
+
it 'accepts many good IDs (2)' do
|
452
|
+
result = show( { 'account_id' => '22', 'member_id' => '6', 'device_id' => 'B' }, 200 )
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'rejects an unknown name' do
|
456
|
+
result = show( { 'another_id' => 'A155C' }, 403 )
|
457
|
+
|
458
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
459
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
460
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
461
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'rejects unknown names' do
|
465
|
+
result = show( { 'another_id' => 'A155C', 'additional_id' => 'iiv' }, 403 )
|
466
|
+
|
467
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
468
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
469
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
470
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'additional_id\\,another_id' )
|
471
|
+
end
|
472
|
+
|
473
|
+
it 'rejects an unknown name amongst a known name' do
|
474
|
+
result = show( { 'another_id' => 'A155C', 'account_id' => '22' }, 403 )
|
475
|
+
|
476
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
477
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
478
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
479
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
480
|
+
end
|
481
|
+
|
482
|
+
it 'rejects an unknown name amongst known names' do
|
483
|
+
result = show( { 'another_id' => 'A155C', 'account_id' => '22', 'member_id' => '6' }, 403 )
|
484
|
+
|
485
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
486
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
487
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
488
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'another_id' )
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
context 'and wildcards' do
|
493
|
+
before :each do
|
494
|
+
@test_session.scoping.authorised_http_headers = [ 'X-Assume-Identity-Of' ]
|
495
|
+
@test_session.scoping.authorised_identities =
|
496
|
+
{
|
497
|
+
'account_id' =>
|
498
|
+
{
|
499
|
+
'20' => { 'member_id' => [ '1', '2' ] },
|
500
|
+
'21' => { 'member_id' => '*' },
|
501
|
+
'22' =>
|
502
|
+
{
|
503
|
+
'member_id' =>
|
504
|
+
{
|
505
|
+
'5' => { 'device_id' => [ 'A' ] },
|
506
|
+
'6' => { 'device_id' => [ 'B' ] }
|
507
|
+
}
|
508
|
+
}
|
509
|
+
}
|
510
|
+
}
|
421
511
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
512
|
+
Hoodoo::Services::Middleware.set_test_session( @test_session )
|
513
|
+
end
|
514
|
+
|
515
|
+
it 'rejects bad account ID' do
|
516
|
+
result = show( { 'account_id' => 'bad' }, 403 )
|
517
|
+
|
518
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
519
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
520
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
521
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'account_id,bad' )
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'rejects bad member ID' do
|
525
|
+
result = show( { 'account_id' => '20', 'member_id' => 'bad' }, 403 )
|
526
|
+
|
527
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
528
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
529
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
530
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,bad' )
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'rejects bad device ID' do
|
534
|
+
result = show( { 'account_id' => '22', 'member_id' => '5', 'device_id' => 'bad' }, 403 )
|
535
|
+
|
536
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
537
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
538
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
539
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id,bad' )
|
540
|
+
end
|
541
|
+
|
542
|
+
it 'rejects attempt to use device ID when not listed in rules' do
|
543
|
+
result = show( { 'account_id' => '21', 'member_id' => '4', 'device_id' => 'A' }, 403 )
|
544
|
+
|
545
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
546
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
547
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
548
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'device_id' )
|
549
|
+
end
|
550
|
+
|
551
|
+
it 'rejects an ID that is present but listed under a different key' do
|
552
|
+
result = show( { 'account_id' => '20', 'member_id' => '4' }, 403 )
|
553
|
+
|
554
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
555
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
556
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests a prohibited identity quantity' )
|
557
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id,4' )
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'rejects an ID that is present but not top-level' do
|
561
|
+
result = show( { 'member_id' => '1' }, 403 )
|
562
|
+
|
563
|
+
expect( result[ 'kind' ] ).to eq( 'Errors' )
|
564
|
+
expect( result[ 'errors' ][ 0 ][ 'code' ] ).to eq( 'platform.forbidden' )
|
565
|
+
expect( result[ 'errors' ][ 0 ][ 'message' ] ).to eq( 'X-Assume-Identity-Of header value requests prohibited identity name(s)' )
|
566
|
+
expect( result[ 'errors' ][ 0 ][ 'reference' ] ).to eq( 'member_id' )
|
567
|
+
end
|
568
|
+
|
569
|
+
it 'accepts a subset of good IDs (1)' do
|
570
|
+
result = show( { 'account_id' => '22' }, 200 )
|
571
|
+
end
|
572
|
+
it 'accepts a subset of good IDs (2)' do
|
573
|
+
result = show( { 'account_id' => '22', 'member_id' => '5' }, 200 )
|
574
|
+
end
|
575
|
+
it 'accepts many good IDs (1)' do
|
576
|
+
result = show( { 'account_id' => '20', 'member_id' => '2' }, 200 )
|
577
|
+
end
|
578
|
+
it 'accepts many good IDs (2)' do
|
579
|
+
result = show( { 'account_id' => '22', 'member_id' => '6', 'device_id' => 'B' }, 200 )
|
580
|
+
end
|
581
|
+
it 'accepts wildcard names' do
|
582
|
+
result = show( { 'account_id' => '21', 'member_id' => 'hit_wildcard' }, 200 )
|
583
|
+
end
|
426
584
|
end
|
427
|
-
|
428
585
|
end
|
429
586
|
|
430
587
|
context 'with malformed rules' do
|
@@ -25,6 +25,17 @@ describe Hoodoo::TransientStore::Mocks::Redis do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
context 'deprecated interfaces in Redis' do
|
29
|
+
it 'supports Array-like "set" and "get"' do
|
30
|
+
mock_redis_instance = Hoodoo::TransientStore::Mocks::Redis.new
|
31
|
+
key = Hoodoo::UUID.generate()
|
32
|
+
value = Hoodoo::UUID.generate()
|
33
|
+
|
34
|
+
mock_redis_instance[ key ] = value
|
35
|
+
expect( mock_redis_instance[ key ] ).to eq( value )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
context 'approximate old behaviour by' do
|
29
40
|
it 'using the mock client in test mode if there is an empty host' do
|
30
41
|
expect_any_instance_of( Hoodoo::TransientStore::Mocks::Redis ).to receive( :initialize ).once.and_call_original()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|