Skip to content

Commit 36038d0

Browse files
authored
Merge pull request #1221 from jaywcarman/powervs_import_image_from_cos
Add API to get list of COS objects
2 parents 0eca6d0 + 1b6690c commit 36038d0

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Api
2+
class CloudObjectStoreObjectsController < BaseProviderController
3+
end
4+
end

config/api.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,24 @@
608608
:get:
609609
- :name: read
610610
:identifier: cloud_object_store_container_show
611+
:cloud_object_store_objects:
612+
:description: Cloud Object Store Objects
613+
:identifier: cloud_object_store_object
614+
:options:
615+
- :collection
616+
:verbs: *gp
617+
:klass: CloudObjectStoreObject
618+
:collection_actions:
619+
:get:
620+
- :name: read
621+
:identifier: cloud_object_store_object_show_list
622+
:post:
623+
- :name: query
624+
:identifier: cloud_object_store_object_show_list
625+
:resource_actions:
626+
:get:
627+
- :name: read
628+
:identifier: cloud_object_store_object_show
611629
:cloud_subnets:
612630
:description: Cloud Subnets
613631
:identifier: cloud_subnet
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
describe "Cloud Object Store Objects API" do
2+
include Spec::Support::SupportsHelper
3+
4+
context 'GET /api/cloud_object_store_objects' do
5+
it 'forbids access to cloud object store objects without an appropriate role' do
6+
api_basic_authorize
7+
8+
get(api_cloud_object_store_objects_url)
9+
10+
expect(response).to have_http_status(:forbidden)
11+
end
12+
13+
it 'returns cloud object store objects with an appropriate role' do
14+
cloud_object_store_object = FactoryBot.create(:cloud_object_store_object)
15+
api_basic_authorize(collection_action_identifier(:cloud_object_store_objects, :read, :get))
16+
17+
get(api_cloud_object_store_objects_url)
18+
19+
expected = {
20+
'resources' => [{'href' => api_cloud_object_store_object_url(nil, cloud_object_store_object)}]
21+
}
22+
expect(response).to have_http_status(:ok)
23+
expect(response.parsed_body).to include(expected)
24+
end
25+
end
26+
27+
context 'GET /api/cloud_object_store_objects' do
28+
let(:cloud_object_store_object) { FactoryBot.create(:cloud_object_store_object) }
29+
30+
it 'forbids access to a cloud object store object without an appropriate role' do
31+
api_basic_authorize
32+
33+
get(api_cloud_object_store_object_url(nil, cloud_object_store_object))
34+
35+
expect(response).to have_http_status(:forbidden)
36+
end
37+
38+
it 'returns the cloud object store object with an appropriate role' do
39+
api_basic_authorize(action_identifier(:cloud_object_store_objects, :read, :resource_actions, :get))
40+
41+
get(api_cloud_object_store_object_url(nil, cloud_object_store_object))
42+
43+
expected = {
44+
'href' => api_cloud_object_store_object_url(nil, cloud_object_store_object)
45+
}
46+
expect(response).to have_http_status(:ok)
47+
expect(response.parsed_body).to include(expected)
48+
end
49+
end
50+
end

0 commit comments

Comments
 (0)