@@ -347,115 +347,114 @@ def check_filtered_bindings(*bindings)
347347 end
348348 end
349349
350- describe 'GET /v3/service_credential_bindings/:missing_key' do
351- let ( :api_call ) { -> ( user_headers ) { get '/v3/service_credential_bindings/no-binding' , nil , user_headers } }
352-
353- let ( :expected_codes_and_responses ) do
354- Hash . new ( code : 404 )
355- end
356-
357- it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
358- end
359-
360- describe 'GET /v3/service_credential_bindings/:key_guid' do
361- let ( :key ) { VCAP ::CloudController ::ServiceKey . make ( service_instance : instance ) }
362- let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : space ) }
363- let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ key . guid } " , nil , user_headers } }
364- let ( :expected_object ) { expected_json ( key ) }
350+ describe 'GET /v3/service_credential_bindings/:guid' do
351+ describe 'query params' do
352+ let ( :binding ) { VCAP ::CloudController ::ServiceBinding . make }
353+ it 'returns 400 for invalid query params' do
354+ get "/v3/service_credential_bindings/#{ binding . guid } ?bahamas=yes-please" , nil , admin_headers
365355
366- describe 'permissions' do
367- let ( :expected_codes_and_responses ) do
368- responses_for_space_restricted_single_endpoint ( expected_object )
356+ expect ( last_response ) . to have_status_code ( 400 )
357+ expect ( parsed_response [ 'errors' ] ) . to include ( include ( {
358+ 'detail' => "The query parameter is invalid: Unknown query parameter(s): 'bahamas'. Valid parameters are: 'include'" ,
359+ 'title' => 'CF-BadQueryParameter' ,
360+ 'code' => 10005 ,
361+ } ) )
369362 end
370363
371- it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
372- end
373-
374- describe 'query params' do
375- describe 'include' do
376- it 'can include `app`' do
377- get "/v3/service_credential_bindings/#{ key . guid } ?include=app" , nil , admin_headers
378- expect ( last_response ) . to have_status_code ( 200 )
379- expect ( parsed_response [ 'included' ] [ 'apps' ] ) . to have ( 0 ) . items
380- end
381-
382- it 'can include `service_instance`' do
383- get "/v3/service_credential_bindings/#{ key . guid } ?include=service_instance" , nil , admin_headers
384- expect ( last_response ) . to have_status_code ( 200 )
364+ describe 'includes' do
365+ it 'returns 400 for invalid includes' do
366+ get "/v3/service_credential_bindings/#{ binding . guid } ?include=routes" , nil , admin_headers
385367
386- expect ( parsed_response [ 'included' ] [ 'service_instances' ] ) . to have ( 1 ) . items
387- guids = parsed_response [ 'included' ] [ 'service_instances' ] . map { |x | x [ 'guid' ] }
388- expect ( guids ) . to contain_exactly ( instance . guid )
368+ expect ( last_response ) . to have_status_code ( 400 )
369+ expect ( parsed_response [ 'errors' ] ) . to include ( include ( {
370+ 'detail' => include ( "Invalid included resource: 'routes'" ) ,
371+ 'title' => 'CF-BadQueryParameter' ,
372+ 'code' => 10005 ,
373+ } ) )
389374 end
390375 end
391376 end
392- end
393377
394- describe 'GET /v3/service_credential_bindings/:app_binding_guid' do
395- let ( :app_to_bind_to ) { VCAP ::CloudController ::AppModel . make ( space : space ) }
396- let ( :app_binding ) do
397- VCAP ::CloudController ::ServiceBinding . make ( service_instance : instance , app : app_to_bind_to ) . tap do |binding |
398- operate_on ( binding )
399- end
400- end
401- let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : space ) }
402- let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ app_binding . guid } " , nil , user_headers } }
403- let ( :expected_object ) { expected_json ( app_binding ) }
378+ describe 'missing binding' do
379+ let ( :api_call ) { -> ( user_headers ) { get '/v3/service_credential_bindings/no-binding' , nil , user_headers } }
404380
405- describe 'permissions' do
406381 let ( :expected_codes_and_responses ) do
407- responses_for_space_restricted_single_endpoint ( expected_object )
382+ Hash . new ( code : 404 )
408383 end
409384
410385 it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
411386 end
412387
413- describe 'include' do
414- it 'can include `app`' do
415- get "/v3/service_credential_bindings/#{ app_binding . guid } ?include=app" , nil , admin_headers
416- expect ( last_response ) . to have_status_code ( 200 )
388+ describe 'key credential binding' do
389+ let ( :key ) { VCAP ::CloudController ::ServiceKey . make ( service_instance : instance ) }
390+ let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : space ) }
391+ let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ key . guid } " , nil , user_headers } }
392+ let ( :expected_object ) { expected_json ( key ) }
417393
418- expect ( parsed_response [ 'included' ] [ 'apps' ] ) . to have ( 1 ) . items
419- guids = parsed_response [ 'included' ] [ 'apps' ] . map { |x | x [ 'guid' ] }
420- expect ( guids ) . to contain_exactly ( app_to_bind_to . guid )
394+ describe 'permissions' do
395+ let ( :expected_codes_and_responses ) do
396+ responses_for_space_restricted_single_endpoint ( expected_object )
397+ end
398+
399+ it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
421400 end
422401
423- it 'can include `service_instance`' do
424- get "/v3/service_credential_bindings/#{ app_binding . guid } ?include=service_instance" , nil , admin_headers
425- expect ( last_response ) . to have_status_code ( 200 )
402+ describe 'query params' do
403+ describe 'include' do
404+ it 'can include `app`' do
405+ get "/v3/service_credential_bindings/#{ key . guid } ?include=app" , nil , admin_headers
406+ expect ( last_response ) . to have_status_code ( 200 )
407+ expect ( parsed_response [ 'included' ] [ 'apps' ] ) . to have ( 0 ) . items
408+ end
409+
410+ it 'can include `service_instance`' do
411+ get "/v3/service_credential_bindings/#{ key . guid } ?include=service_instance" , nil , admin_headers
412+ expect ( last_response ) . to have_status_code ( 200 )
426413
427- expect ( parsed_response [ 'included' ] [ 'service_instances' ] ) . to have ( 1 ) . items
428- guids = parsed_response [ 'included' ] [ 'service_instances' ] . map { |x | x [ 'guid' ] }
429- expect ( guids ) . to contain_exactly ( instance . guid )
414+ expect ( parsed_response [ 'included' ] [ 'service_instances' ] ) . to have ( 1 ) . items
415+ guids = parsed_response [ 'included' ] [ 'service_instances' ] . map { |x | x [ 'guid' ] }
416+ expect ( guids ) . to contain_exactly ( instance . guid )
417+ end
418+ end
430419 end
431420 end
432- end
433421
434- describe 'GET /v3/service_credential_bindings/:guid' do
435- let ( :binding ) { VCAP ::CloudController ::ServiceBinding . make }
422+ describe 'app credential binding ' do
423+ let ( :app_to_bind_to ) { VCAP ::CloudController ::AppModel . make ( space : space ) }
424+ let ( :app_binding ) do
425+ VCAP ::CloudController ::ServiceBinding . make ( service_instance : instance , app : app_to_bind_to ) . tap do |binding |
426+ operate_on ( binding )
427+ end
428+ end
429+ let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space : space ) }
430+ let ( :api_call ) { -> ( user_headers ) { get "/v3/service_credential_bindings/#{ app_binding . guid } " , nil , user_headers } }
431+ let ( :expected_object ) { expected_json ( app_binding ) }
436432
437- describe 'query params' do
438- it 'returns 400 for invalid query params' do
439- get "/v3/service_credential_bindings/#{ binding . guid } ?bahamas=yes-please" , nil , admin_headers
433+ describe 'permissions' do
434+ let ( :expected_codes_and_responses ) do
435+ responses_for_space_restricted_single_endpoint ( expected_object )
436+ end
440437
441- expect ( last_response ) . to have_status_code ( 400 )
442- expect ( parsed_response [ 'errors' ] ) . to include ( include ( {
443- 'detail' => "The query parameter is invalid: Unknown query parameter(s): 'bahamas'. Valid parameters are: 'include'" ,
444- 'title' => 'CF-BadQueryParameter' ,
445- 'code' => 10005 ,
446- } ) )
438+ it_behaves_like 'permissions for single object endpoint' , ALL_PERMISSIONS
447439 end
448440
449- describe 'includes' do
450- it 'returns 400 for invalid includes' do
451- get "/v3/service_credential_bindings/#{ binding . guid } ?include=routes" , nil , admin_headers
441+ describe 'include' do
442+ it 'can include `app`' do
443+ get "/v3/service_credential_bindings/#{ app_binding . guid } ?include=app" , nil , admin_headers
444+ expect ( last_response ) . to have_status_code ( 200 )
452445
453- expect ( last_response ) . to have_status_code ( 400 )
454- expect ( parsed_response [ 'errors' ] ) . to include ( include ( {
455- 'detail' => include ( "Invalid included resource: 'routes'" ) ,
456- 'title' => 'CF-BadQueryParameter' ,
457- 'code' => 10005 ,
458- } ) )
446+ expect ( parsed_response [ 'included' ] [ 'apps' ] ) . to have ( 1 ) . items
447+ guids = parsed_response [ 'included' ] [ 'apps' ] . map { |x | x [ 'guid' ] }
448+ expect ( guids ) . to contain_exactly ( app_to_bind_to . guid )
449+ end
450+
451+ it 'can include `service_instance`' do
452+ get "/v3/service_credential_bindings/#{ app_binding . guid } ?include=service_instance" , nil , admin_headers
453+ expect ( last_response ) . to have_status_code ( 200 )
454+
455+ expect ( parsed_response [ 'included' ] [ 'service_instances' ] ) . to have ( 1 ) . items
456+ guids = parsed_response [ 'included' ] [ 'service_instances' ] . map { |x | x [ 'guid' ] }
457+ expect ( guids ) . to contain_exactly ( instance . guid )
459458 end
460459 end
461460 end
0 commit comments