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

Add API to get list of COS objects #1221

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class CloudObjectStoreObjectsController < BaseProviderController
end
end
18 changes: 18 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,24 @@
:get:
- :name: read
:identifier: cloud_object_store_container_show
:cloud_object_store_objects:
:description: Cloud Object Store Objects
:identifier: cloud_object_store_object
:options:
- :collection
:verbs: *gp
:klass: CloudObjectStoreObject
:collection_actions:
:get:
- :name: read
:identifier: cloud_object_store_object_show_list
:post:
- :name: query
:identifier: cloud_object_store_object_show_list
:resource_actions:
:get:
- :name: read
:identifier: cloud_object_store_object_show
:cloud_subnets:
:description: Cloud Subnets
:identifier: cloud_subnet
Expand Down
50 changes: 50 additions & 0 deletions spec/requests/cloud_object_store_objects_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe "Cloud Object Store Objects API" do
include Spec::Support::SupportsHelper

context 'GET /api/cloud_object_store_objects' do
it 'forbids access to cloud object store objects without an appropriate role' do
api_basic_authorize

get(api_cloud_object_store_objects_url)

expect(response).to have_http_status(:forbidden)
end

it 'returns cloud object store objects with an appropriate role' do
cloud_object_store_object = FactoryBot.create(:cloud_object_store_object)
api_basic_authorize(collection_action_identifier(:cloud_object_store_objects, :read, :get))

get(api_cloud_object_store_objects_url)

expected = {
'resources' => [{'href' => api_cloud_object_store_object_url(nil, cloud_object_store_object)}]
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end
end

context 'GET /api/cloud_object_store_objects' do
let(:cloud_object_store_object) { FactoryBot.create(:cloud_object_store_object) }

it 'forbids access to a cloud object store object without an appropriate role' do
api_basic_authorize

get(api_cloud_object_store_object_url(nil, cloud_object_store_object))

expect(response).to have_http_status(:forbidden)
end

it 'returns the cloud object store object with an appropriate role' do
api_basic_authorize(action_identifier(:cloud_object_store_objects, :read, :resource_actions, :get))

get(api_cloud_object_store_object_url(nil, cloud_object_store_object))

expected = {
'href' => api_cloud_object_store_object_url(nil, cloud_object_store_object)
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end
end
end