Skip to content

Commit

Permalink
Merge pull request #14260 from AparnaKarve/api_cloud_volumes
Browse files Browse the repository at this point in the history
[api] Collections API for Cloud Volumes
  • Loading branch information
abellotti authored Mar 15, 2017
2 parents b16adc2 + 0bbcd8a commit 765f29d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/cloud_volumes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class CloudVolumesController < BaseController
end
end
18 changes: 18 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,24 @@
:get:
- :name: read
:identifier: miq_cloud_networks_view
:cloud_volumes:
:description: Cloud Volumes
:identifier: cloud_volume
:options:
- :collection
:verbs: *gp
:klass: CloudVolume
:collection_actions:
:get:
- :name: read
:identifier: cloud_volume_show_list
:post:
- :name: query
:identifier: cloud_volume_show_list
:resource_actions:
:get:
- :name: read
:identifier: cloud_volume
:clusters:
:description: Clusters
:identifier: ems_cluster
Expand Down
43 changes: 43 additions & 0 deletions spec/requests/api/cloud_volumes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# REST API Request Tests - Cloud Volumes
#
# Regions primary collections:
# /api/cloud_volumes
#
# Tests for:
# GET /api/cloud_volumes/:id
#

describe "Cloud Volumes API" do
it "forbids access to cloud volumes without an appropriate role" do
api_basic_authorize

run_get(cloud_volumes_url)

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

it "forbids access to a cloud volume resource without an appropriate role" do
api_basic_authorize

cloud_volume = FactoryGirl.create(:cloud_volume)

run_get(cloud_volumes_url(cloud_volume.id))

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

it "allows GETs of a cloud volume" do
api_basic_authorize action_identifier(:cloud_volumes, :read, :resource_actions, :get)

cloud_volume = FactoryGirl.create(:cloud_volume)

run_get(cloud_volumes_url(cloud_volume.id))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(
"href" => a_string_matching(cloud_volumes_url(cloud_volume.id)),
"id" => cloud_volume.id
)
end
end
10 changes: 10 additions & 0 deletions spec/requests/api/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
test_collection_query(:clusters, clusters_url, EmsCluster)
end

it "query CloudVolumes" do
FactoryGirl.create(:cloud_volume)
test_collection_query(:cloud_volumes, cloud_volumes_url, CloudVolume)
end

it "query Conditions" do
FactoryGirl.create(:condition)
test_collection_query(:conditions, conditions_url, Condition)
Expand Down Expand Up @@ -570,5 +575,10 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
FactoryGirl.create(:load_balancer)
test_collection_bulk_query(:load_balancers, load_balancers_url, LoadBalancer)
end

it 'bulk query CloudVolumes' do
FactoryGirl.create(:cloud_volume)
test_collection_bulk_query(:cloud_volumes, cloud_volumes_url, CloudVolume)
end
end
end

0 comments on commit 765f29d

Please sign in to comment.