Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new firmware collection api #14476

Merged
merged 6 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions app/controllers/api/firmwares_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class FirmwaresController < BaseController
end
end
19 changes: 19 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,25 @@
:post:
- :name: assign
- :name: unassign
:firmwares:
:description: Firmwares
:options:
- :collection
- :subcollection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which primary collection is declaring this as a subcollection ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the PhysicalServer collection. The PhysicalServer collection is defined in PR #14028.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodneyhbrown7 it looks like in the linked PR it's not declaring this as a subcollection. It may be best to leave this out in this PR, or until you are ready to add it to the phyical server config

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abellotti @imtayadeway @rodneyhbrown7 I removed the firmwares subcollection option for now. If this PR gets merged before the linked PR (#14028), the linked PR will be updated to add this as a subcollection.

:verbs: *gp
:klass: Firmware
:identifier: firmware
:collection_actions:
:get:
- :name: read
:identifier: firmware_show_list
:post:
- :name: query
:identifier: firmware_show_list
:resource_actions:
:get:
- :name: read
:identifier: firmware_show
:flavors:
:description: Flavors
:identifier: flavor
Expand Down
20 changes: 20 additions & 0 deletions db/fixtures/miq_product_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6419,6 +6419,26 @@
:feature_type: control
:identifier: physical_server_refresh

# Firmwares
- :name: Firmwares
:description: Everything under Firmware
:feature_type: node
:identifier: firmware
:children:
- :name: View
:description: View Firmware
:feature_type: view
:identifier: firmware_view
:children:
- :name: List
:description: Display Lists of Firmware
:feature_type: view
:identifier: firmware_show_list
- :name: Show
:description: Display Individual Firmware
:feature_type: view
:identifier: firmware_show

# Physical Infrastructure Topology
- :name: Physical Infra Topology
:description: Physical Infra Topology
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/firmware.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FactoryGirl.define do
factory :firmware do
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 @@ -303,6 +303,11 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
FactoryGirl.create(:miq_alert_status)
test_collection_query(:alerts, alerts_url, MiqAlertStatus)
end

it 'query Firmwares' do
FactoryGirl.create(:firmware)
test_collection_query(:firmwares, firmwares_url, Firmware)
end
end

context "Collections Bulk Queries" do
Expand Down Expand Up @@ -558,5 +563,10 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
FactoryGirl.create(:cloud_volume)
test_collection_bulk_query(:cloud_volumes, cloud_volumes_url, CloudVolume)
end

it 'bulk query Firmwares' do
FactoryGirl.create(:firmware)
test_collection_bulk_query(:firmwares, firmwares_url, Firmware)
end
end
end
31 changes: 31 additions & 0 deletions spec/requests/api/firmwares_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
RSpec.describe "firmwares API" do
describe "display firmware details" do
context "with a valid role" do
it "shows its properties" do
fw = FactoryGirl.create(:firmware, :id => 1, :name => "UEFI",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't want to set the id here - that's the database's job and could result in some erratic behavior

:version => "D7E152CUS-2.11", :resource_id => 1)

api_basic_authorize action_identifier(:firmwares, :read, :resource_actions, :get)

run_get(firmwares_url(fw.id))

expect_single_resource_query("id" => 1,
"name" => "UEFI",
"version" => "D7E152CUS-2.11",
"resource_id" => 1)
end
end

context "with an invalid role" do
it "fails to show its properties" do
fw = FactoryGirl.create(:firmware, :id => 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above


api_basic_authorize

run_get(firmwares_url(fw.id))

expect(response).to have_http_status(:forbidden)
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test for invalid role and such.

end