|
7 | 7 | let(:admin_header) { admin_headers_for(user) } |
8 | 8 | let(:org) { VCAP::CloudController::Organization.make(created_at: 3.days.ago) } |
9 | 9 | let(:space) { VCAP::CloudController::Space.make(organization: org) } |
10 | | - let(:app_model) { VCAP::CloudController::AppModel.make(space: space, enable_ssh: true) } |
| 10 | + let(:app_model) { VCAP::CloudController::AppModel.make(space: space, enable_ssh: true, file_based_service_bindings_enabled: true) } |
11 | 11 |
|
12 | 12 | describe 'GET /v3/apps/:guid/features' do |
13 | 13 | context 'getting a list of available features for the app' do |
|
24 | 24 | 'name' => 'revisions', |
25 | 25 | 'description' => 'Enable versioning of an application', |
26 | 26 | 'enabled' => true |
| 27 | + }, |
| 28 | + { |
| 29 | + 'name' => 'file-based-service-bindings', |
| 30 | + 'description' => 'Enable file-based service bindings for the app', |
| 31 | + 'enabled' => true |
27 | 32 | } |
28 | 33 | ], |
29 | 34 | 'pagination' => |
30 | 35 | { |
31 | | - 'total_results' => 2, |
| 36 | + 'total_results' => 3, |
32 | 37 | 'total_pages' => 1, |
33 | 38 | 'first' => { 'href' => "/v3/apps/#{app_model.guid}/features" }, |
34 | 39 | 'last' => { 'href' => "/v3/apps/#{app_model.guid}/features" }, |
|
94 | 99 |
|
95 | 100 | it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS |
96 | 101 | end |
| 102 | + |
| 103 | + context 'file-based-service-bindings app feature' do |
| 104 | + let(:api_call) { ->(user_headers) { get "/v3/apps/#{app_model.guid}/features/file-based-service-bindings", nil, user_headers } } |
| 105 | + let(:feature_response_object) do |
| 106 | + { |
| 107 | + 'name' => 'file-based-service-bindings', |
| 108 | + 'description' => 'Enable file-based service bindings for the app', |
| 109 | + 'enabled' => true |
| 110 | + } |
| 111 | + end |
| 112 | + |
| 113 | + it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS |
| 114 | + end |
97 | 115 | end |
98 | 116 |
|
99 | 117 | describe 'PATCH /v3/apps/:guid/features/:name' do |
|
172 | 190 | it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS |
173 | 191 | end |
174 | 192 | end |
| 193 | + |
| 194 | + context 'file-based-service-bindings app feature' do |
| 195 | + let(:api_call) { ->(user_headers) { patch "/v3/apps/#{app_model.guid}/features/file-based-service-bindings", request_body.to_json, user_headers } } |
| 196 | + let(:feature_response_object) do |
| 197 | + { |
| 198 | + 'name' => 'file-based-service-bindings', |
| 199 | + 'description' => 'Enable file-based service bindings for the app', |
| 200 | + 'enabled' => false |
| 201 | + } |
| 202 | + end |
| 203 | + |
| 204 | + let(:expected_codes_and_responses) do |
| 205 | + h = Hash.new(code: 403, errors: CF_NOT_AUTHORIZED) |
| 206 | + %w[no_role org_auditor org_billing_manager].each { |r| h[r] = { code: 404 } } |
| 207 | + %w[admin space_developer].each { |r| h[r] = { code: 200, response_object: feature_response_object } } |
| 208 | + h |
| 209 | + end |
| 210 | + |
| 211 | + it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS |
| 212 | + |
| 213 | + context 'when organization is suspended' do |
| 214 | + let(:expected_codes_and_responses) do |
| 215 | + h = super() |
| 216 | + h['space_developer'] = { code: 403, errors: CF_ORG_SUSPENDED } |
| 217 | + h |
| 218 | + end |
| 219 | + |
| 220 | + before do |
| 221 | + org.update(status: VCAP::CloudController::Organization::SUSPENDED) |
| 222 | + end |
| 223 | + |
| 224 | + it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS |
| 225 | + end |
| 226 | + end |
175 | 227 | end |
176 | 228 | end |
0 commit comments