-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for /api/cloud_object_store_objects
Add a new API to: - Get cloud object store (COS) object - Get a list of cloud object store (COS) objects
- Loading branch information
1 parent
5409e74
commit 1b6690c
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Api | ||
class CloudObjectStoreObjectsController < BaseProviderController | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |