Skip to content

Commit

Permalink
Merge pull request #1221 from jaywcarman/powervs_import_image_from_cos
Browse files Browse the repository at this point in the history
Add API to get list of COS objects
  • Loading branch information
kbrock authored May 3, 2023
2 parents 0eca6d0 + 1b6690c commit 36038d0
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/cloud_object_store_objects_controller.rb
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

0 comments on commit 36038d0

Please sign in to comment.