Skip to content
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
7 changes: 7 additions & 0 deletions app/controllers/api/service_offerings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Api
class ServiceOfferingsController < BaseController
def service_parameters_sets_query_resource(object)
object.service_parameters_sets
end
end
end
4 changes: 4 additions & 0 deletions app/controllers/api/service_parameters_sets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class ServiceParametersSetsController < BaseController
end
end
32 changes: 32 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,23 @@
:delete:
- :name: delete
:identifier: dialog_delete
:service_offerings:
:description: Service Offerings
:identifier: service_offerings
:options:
- :collection
:verbs: *g
:klass: ServiceOffering
:subcollections:
- :service_parameters_sets
:collection_actions:
:get:
- :name: read
:identifier: service_offerings_view
:resource_actions:
:get:
- :name: read
:identifier: service_offerings_view
:service_orders:
:description: Service Orders
:identifier: svc_catalog_provision
Expand Down Expand Up @@ -2811,6 +2828,21 @@
:delete:
- :name: delete
:identifier: svc_catalog_provision
:service_parameters_sets:
:description: Service Parameters Sets
:identifier: service_parameters_sets
:options:
- :collection
:verbs: *g
:klass: ServiceParametersSet
:collection_actions:
:get:
- :name: read
:identifier: service_parameters_sets_view
:resource_actions:
:get:
- :name: read
:identifier: service_parameters_sets_view
:service_requests:
:description: Service Requests
:identifier: miq_request
Expand Down
56 changes: 56 additions & 0 deletions spec/requests/service_offerings_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
describe "ServiceOfferings API" do
it "forbids access without an appropriate role" do
api_basic_authorize

get(api_service_offerings_url)

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

it "allows access with an appropriate role" do
api_basic_authorize action_identifier(:service_offerings, :read, :collection_actions, :get)

instance = ServiceOffering.create!

get(api_service_offerings_url)

expect(response).to have_http_status(:ok)
expect(response.parsed_body["resources"]).to include("href" => api_service_offering_url(nil, instance))
end

it "forbids access to an instance without an appropriate role" do
api_basic_authorize

instance = ServiceOffering.create!

get(api_service_offering_url(nil, instance))

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

it "allows access to an instance with an appropriate role" do
api_basic_authorize action_identifier(:service_offerings, :read, :resource_actions, :get)

instance = ServiceOffering.create!

get(api_service_offering_url(nil, instance))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(
"href" => api_service_offering_url(nil, instance),
"id" => instance.id.to_s
)
end

it "allows access to an instances service_parameters_sets with an appropriate role" do
api_basic_authorize action_identifier(:service_offerings, :read, :resource_actions, :get)

instance = ServiceOffering.create!
sub_resource = instance.service_parameters_sets.create!

get(api_service_offering_service_parameters_sets_url(nil, instance))

expect(response).to have_http_status(:ok)
expect(response.parsed_body["resources"]).to eq([{"href" => api_service_offering_service_parameters_set_url(nil, instance, sub_resource)}])
end
end
44 changes: 44 additions & 0 deletions spec/requests/service_parameters_sets_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
describe "ServiceParametersSets API" do
it "forbids access without an appropriate role" do
api_basic_authorize

get(api_service_parameters_sets_url)

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

it "allows access with an appropriate role" do
api_basic_authorize action_identifier(:service_parameters_sets, :read, :collection_actions, :get)

instance = ServiceParametersSet.create!

get(api_service_parameters_sets_url)

expect(response).to have_http_status(:ok)
expect(response.parsed_body["resources"]).to include("href" => api_service_parameters_set_url(nil, instance))
end

it "forbids access to an instance without an appropriate role" do
api_basic_authorize

instance = ServiceParametersSet.create!

get(api_service_parameters_set_url(nil, instance))

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

it "allows access to an instance with an appropriate role" do
api_basic_authorize action_identifier(:service_parameters_sets, :read, :resource_actions, :get)

instance = ServiceParametersSet.create!

get(api_service_parameters_set_url(nil, instance))

expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(
"href" => api_service_parameters_set_url(nil, instance),
"id" => instance.id.to_s
)
end
end