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

Add guest_devices support to the API #7

Merged
merged 3 commits into from
Sep 7, 2017
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
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 @@ -866,6 +866,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