Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit cc49c78

Browse files
author
Brian Butz
committed
v3(services): Add request test to ensure service credential binding sharing permissions
[#173473714](https://www.pivotaltracker.com/story/show/173473714)
1 parent d766965 commit cc49c78

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

spec/request/service_credential_bindings_spec.rb

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
end
6464

6565
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) }
6768
let(:instance) { VCAP::CloudController::ManagedServiceInstance.make(space: space) }
6869
let(:api_call) { ->(user_headers) { get "/v3/service_credential_bindings/#{app_binding.guid}", nil, user_headers } }
6970
let(:expected_object) { { guid: app_binding.guid, type: 'app' } }
@@ -77,15 +78,15 @@
7778
end
7879

7980
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 }
8786
end
87+
end
8888

89+
context 'user is in the original space of the service instance' do
8990
it_behaves_like 'permissions for single object endpoint', LOCAL_ROLES
9091
end
9192

@@ -96,13 +97,19 @@
9697
instance.add_shared_space(space)
9798
end
9899

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
103102
end
104103

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
106113
end
107114
end
108115
end

0 commit comments

Comments
 (0)