|
63 | 63 | end |
64 | 64 |
|
65 | 65 | describe 'GET /v3/service_credential_bindings/:app_guid' do |
66 | | - let(:app_binding) { VCAP::CloudController::ServiceBinding.make(service_instance: instance) } |
| 66 | + let(:app_to_bind_to) { VCAP::CloudController::AppModel.make(space: space) } |
| 67 | + let(:app_binding) { VCAP::CloudController::ServiceBinding.make(service_instance: instance, app: app_to_bind_to) } |
67 | 68 | let(:instance) { VCAP::CloudController::ManagedServiceInstance.make(space: space) } |
68 | 69 | let(:api_call) { ->(user_headers) { get "/v3/service_credential_bindings/#{app_binding.guid}", nil, user_headers } } |
69 | 70 | let(:expected_object) { { guid: app_binding.guid, type: 'app' } } |
|
77 | 78 | end |
78 | 79 |
|
79 | 80 | context 'local roles' do |
80 | | - context 'user is in the original space of the service instance' do |
81 | | - let(:expected_codes_and_responses) do |
82 | | - Hash.new({ code: 200, response_object: expected_object }).tap do |h| |
83 | | - h['org_auditor'] = { code: 404 } |
84 | | - h['org_billing_manager'] = { code: 404 } |
85 | | - h['no_role'] = { code: 404 } |
86 | | - end |
| 81 | + let(:expected_codes_and_responses) do |
| 82 | + Hash.new({ code: 200, response_object: expected_object }).tap do |h| |
| 83 | + h['org_auditor'] = { code: 404 } |
| 84 | + h['org_billing_manager'] = { code: 404 } |
| 85 | + h['no_role'] = { code: 404 } |
87 | 86 | end |
| 87 | + end |
88 | 88 |
|
| 89 | + context 'user is in the original space of the service instance' do |
89 | 90 | it_behaves_like 'permissions for single object endpoint', LOCAL_ROLES |
90 | 91 | end |
91 | 92 |
|
|
96 | 97 | instance.add_shared_space(space) |
97 | 98 | end |
98 | 99 |
|
99 | | - let(:api_call) { ->(user_headers) { get "/v3/service_credential_bindings/#{app_binding.guid}", nil, user_headers } } |
100 | | - |
101 | | - let(:expected_codes_and_responses) do |
102 | | - Hash.new(code: 404) |
| 100 | + context 'the app is in the users space' do |
| 101 | + it_behaves_like 'permissions for single object endpoint', LOCAL_ROLES |
103 | 102 | end |
104 | 103 |
|
105 | | - it_behaves_like 'permissions for single object endpoint', LOCAL_ROLES |
| 104 | + context 'the app is not in the users space' do |
| 105 | + let(:app_to_bind_to) { VCAP::CloudController::AppModel.make(space: other_space) } |
| 106 | + |
| 107 | + let(:expected_codes_and_responses) do |
| 108 | + Hash.new(code: 404) |
| 109 | + end |
| 110 | + |
| 111 | + it_behaves_like 'permissions for single object endpoint', LOCAL_ROLES |
| 112 | + end |
106 | 113 | end |
107 | 114 | end |
108 | 115 | end |
|
0 commit comments