Skip to content

Commit

Permalink
Merge pull request #7 from skovic/network-adapter-api
Browse files Browse the repository at this point in the history
Add guest_devices support to the API
  • Loading branch information
abellotti authored Sep 7, 2017
2 parents a74dcea + 25b7d1d commit 4a08be7
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/guest_devices_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class GuestDevicesController < BaseController
end
end
18 changes: 18 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,24 @@
:identifier: rbac_group_tags_edit
- :name: unassign
:identifier: rbac_group_tags_edit
:guest_devices:
:description: Guest Devices
:options:
- :collection
:verbs: *gp
:klass: GuestDevice
:identifier: guest_device
:collection_actions:
:get:
- :name: read
:identifier: guest_device_show_list
:post:
- :name: query
:identifier: guest_device_show_list
:resource_actions:
:get:
- :name: read
:identifier: guest_device_show
:hosts:
:description: Hosts
:identifier: host
Expand Down
10 changes: 10 additions & 0 deletions spec/requests/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
FactoryGirl.create(:physical_server)
test_collection_query(:physical_servers, physical_servers_url, PhysicalServer)
end

it 'query GuestDevices' do
FactoryGirl.create(:guest_device)
test_collection_query(:guest_devices, guest_devices_url, GuestDevice)
end
end

context "Collections Bulk Queries" do
Expand Down Expand Up @@ -600,5 +605,10 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
FactoryGirl.create(:physical_server)
test_collection_bulk_query(:physical_servers, physical_servers_url, PhysicalServer)
end

it 'bulk query GuestDevices' do
FactoryGirl.create(:guest_device)
test_collection_bulk_query(:guest_devices, guest_devices_url, GuestDevice)
end
end
end
32 changes: 32 additions & 0 deletions spec/requests/guest_devices_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
RSpec.describe "guest devices API" do
describe "display guest device details" do
context "with the user authorized" do
it "responds with device properties" do
device = FactoryGirl.create(:guest_device,
:device_name => "Broadcom 2-port 1GbE NIC Card",
:device_type => "ethernet",
:location => "Bay 7")

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

run_get(guest_devices_url(device.id))

expect_single_resource_query("device_name" => "Broadcom 2-port 1GbE NIC Card",
"device_type" => "ethernet",
"location" => "Bay 7")
end
end

context "with the user unauthorized" do
it "responds with a forbidden status" do
device = FactoryGirl.create(:guest_device)

api_basic_authorize

run_get(guest_devices_url(device.id))

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

0 comments on commit 4a08be7

Please sign in to comment.