-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15450 from gildub/network_router-API-initial
Network Routers REST API
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Api | ||
class NetworkRoutersController < BaseController | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RSpec.describe 'NetworkRouters API' do | ||
describe 'GET /api/network_routers' do | ||
it 'lists all cloud subnets with an appropriate role' do | ||
network_router = FactoryGirl.create(:network_router) | ||
api_basic_authorize collection_action_identifier(:network_routers, :read, :get) | ||
run_get(network_routers_url) | ||
|
||
expected = { | ||
'count' => 1, | ||
'subcount' => 1, | ||
'name' => 'network_routers', | ||
'resources' => [ | ||
hash_including('href' => a_string_matching(network_routers_url(network_router.id))) | ||
] | ||
} | ||
expect(response).to have_http_status(:ok) | ||
expect(response.parsed_body).to include(expected) | ||
end | ||
|
||
it 'forbids access to cloud subnets without an appropriate role' do | ||
api_basic_authorize | ||
run_get(network_routers_url) | ||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
|
||
describe 'GET /api/network_routers/:id' do | ||
it 'will show a cloud subnet with an appropriate role' do | ||
network_router = FactoryGirl.create(:network_router) | ||
api_basic_authorize action_identifier(:network_routers, :read, :resource_actions, :get) | ||
run_get(network_routers_url(network_router.id)) | ||
expect(response.parsed_body).to include('href' => a_string_matching(network_routers_url(network_router.id))) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'forbids access to a cloud tenant without an appropriate role' do | ||
network_router = FactoryGirl.create(:network_router) | ||
api_basic_authorize | ||
run_get(network_routers_url(network_router.id)) | ||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
|
||
describe 'POST /api/network_routers' do | ||
it 'forbids access to network routers without an appropriate role' do | ||
api_basic_authorize | ||
run_post(network_routers_url, gen_request(:query, "")) | ||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
end |