Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that space application supporter can get/list buildpacks #2319

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 50 additions & 34 deletions spec/request/buildpacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,19 @@
]))
end
end

context 'permissions' do
let(:org) { VCAP::CloudController::Organization.make }
let(:space) { VCAP::CloudController::Space.make(organization: org) }
let(:api_call) { lambda { |user_headers| get '/v3/buildpacks', nil, user_headers } }
let(:expected_codes_and_responses) { Hash.new(code: 200).freeze }

before do
space.organization.add_user(user)
end

it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS + ['space_application_supporter']
end
end

describe 'POST /v3/buildpacks' do
Expand Down Expand Up @@ -843,49 +856,52 @@
end

context 'when authenticated' do
let(:org) { VCAP::CloudController::Organization.make }
let(:space) { VCAP::CloudController::Space.make(organization: org) }
let(:user) { VCAP::CloudController::User.make }
let(:headers) { headers_for(user) }

before do
space.organization.add_user(user)
end

context 'the buildpack does not exist' do
it 'returns 404' do
get '/v3/buildpacks/does-not-exist', params, headers
expect(last_response.status).to eq(404)
end
let(:api_call) { lambda { |user_headers| get '/v3/buildpacks/does-not-exist', nil, user_headers } }

context 'the buildpack exists' do
it 'returns 200' do
get "/v3/buildpacks/#{buildpack.guid}", params, headers
expect(last_response.status).to eq(200)
end
let(:expected_codes_and_responses) { Hash.new(code: 404).freeze }

it 'returns the newly-created buildpack resource' do
get "/v3/buildpacks/#{buildpack.guid}", params, headers
it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS + ['space_application_supporter']
end

expected_response = {
'name' => buildpack.name,
'state' => buildpack.state,
'stack' => buildpack.stack,
'filename' => buildpack.filename,
'position' => buildpack.position,
'enabled' => buildpack.enabled,
'locked' => buildpack.locked,
'guid' => buildpack.guid,
'created_at' => iso8601,
'updated_at' => iso8601,
'metadata' => { 'labels' => {}, 'annotations' => {} },
'links' => {
'self' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack.guid}"
},
'upload' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack.guid}/upload",
'method' => 'POST'
}
context 'the buildpack exists' do
let(:api_call) { lambda { |user_headers| get "/v3/buildpacks/#{buildpack.guid}", nil, user_headers } }
let(:buildpack_response) do
{
'name' => buildpack.name,
'state' => buildpack.state,
'stack' => buildpack.stack,
'filename' => buildpack.filename,
'position' => buildpack.position,
'enabled' => buildpack.enabled,
'locked' => buildpack.locked,
'guid' => buildpack.guid,
'created_at' => iso8601,
'updated_at' => iso8601,
'metadata' => { 'labels' => {}, 'annotations' => {} },
'links' => {
'self' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack.guid}"
},
'upload' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack.guid}/upload",
'method' => 'POST'
}
}
expect(parsed_response).to be_a_response_like(expected_response)
end
}
end

let(:expected_codes_and_responses) { Hash.new(code: 200, response_object: buildpack_response).freeze }

it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS + ['space_application_supporter']
end
end
end
Expand Down