@@ -363,42 +363,12 @@ def check_filtered_bindings(*bindings)
363363 let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ key . guid } " , nil , user_headers } }
364364 let ( :expected_object ) { expected_json ( key ) }
365365
366- context 'global roles ' do
366+ describe 'permissions ' do
367367 let ( :expected_codes_and_responses ) do
368- Hash . new ( { code : 200 , response_object : expected_object } )
368+ responses_for_space_restricted_single_endpoint ( expected_object )
369369 end
370370
371- it_behaves_like 'permissions for single object endpoint' , GLOBAL_SCOPES
372- end
373-
374- context 'local roles' do
375- context 'user is in the original space of the service instance' do
376- let ( :expected_codes_and_responses ) do
377- Hash . new ( { code : 200 , response_object : expected_object } ) . tap do |h |
378- h [ 'org_auditor' ] = { code : 404 }
379- h [ 'org_billing_manager' ] = { code : 404 }
380- h [ 'no_role' ] = { code : 404 }
381- end
382- end
383-
384- it_behaves_like 'permissions for single object endpoint' , LOCAL_ROLES
385- end
386-
387- context 'user is in a space that the service instance is shared to' do
388- let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : other_space ) }
389-
390- before do
391- instance . add_shared_space ( space )
392- end
393-
394- let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ key . guid } " , nil , user_headers } }
395-
396- let ( :expected_codes_and_responses ) do
397- Hash . new ( code : 404 )
398- end
399-
400- it_behaves_like 'permissions for single object endpoint' , LOCAL_ROLES
401- end
371+ it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
402372 end
403373
404374 describe 'query params' do
@@ -432,48 +402,12 @@ def check_filtered_bindings(*bindings)
432402 let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ app_binding . guid } " , nil , user_headers } }
433403 let ( :expected_object ) { expected_json ( app_binding ) }
434404
435- context 'global roles ' do
405+ describe 'permissions ' do
436406 let ( :expected_codes_and_responses ) do
437- Hash . new ( { code : 200 , response_object : expected_object } )
407+ responses_for_space_restricted_single_endpoint ( expected_object )
438408 end
439409
440- it_behaves_like 'permissions for single object endpoint' , GLOBAL_SCOPES
441- end
442-
443- context 'local roles' do
444- let ( :expected_codes_and_responses ) do
445- Hash . new ( { code : 200 , response_object : expected_object } ) . tap do |h |
446- h [ 'org_auditor' ] = { code : 404 }
447- h [ 'org_billing_manager' ] = { code : 404 }
448- h [ 'no_role' ] = { code : 404 }
449- end
450- end
451-
452- context 'user is in the original space of the service instance' do
453- it_behaves_like 'permissions for single object endpoint' , LOCAL_ROLES
454- end
455-
456- context 'user is in a space that the service instance is shared to' do
457- let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : other_space ) }
458-
459- before do
460- instance . add_shared_space ( space )
461- end
462-
463- context 'the app is in the users space' do
464- it_behaves_like 'permissions for single object endpoint' , LOCAL_ROLES
465- end
466-
467- context 'the app is not in the users space' do
468- let ( :app_to_bind_to ) { VCAP ::CloudController ::AppModel . make ( space : other_space ) }
469-
470- let ( :expected_codes_and_responses ) do
471- Hash . new ( code : 404 )
472- end
473-
474- it_behaves_like 'permissions for single object endpoint' , LOCAL_ROLES
475- end
476- end
410+ it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
477411 end
478412
479413 describe 'include' do
@@ -725,11 +659,7 @@ def check_filtered_bindings(*bindings)
725659
726660 it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS do
727661 let ( :expected_codes_and_responses ) do
728- Hash . new ( code : 200 , response_object : binding_params ) . tap do |h |
729- h [ 'org_auditor' ] = { code : 404 }
730- h [ 'org_billing_manager' ] = { code : 404 }
731- h [ 'no_role' ] = { code : 404 }
732- end
662+ responses_for_space_restricted_single_endpoint ( binding_params )
733663 end
734664 end
735665
0 commit comments