forked from ManageIQ/manageiq-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for fetching configuration scripts
The Ansible Tower Job Template and Ansible Workflows can now be fetched using the REST API.
- Loading branch information
Showing
3 changed files
with
69 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 ConfigurationScriptsController < 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RSpec.describe 'Configuration Scripts API' do | ||
describe 'GET /api/configuration_scripts' do | ||
it 'lists all the configuration scripts with an appropriate role' do | ||
script = FactoryGirl.create(:configuration_script) | ||
api_basic_authorize collection_action_identifier(:configuration_scripts, :read, :get) | ||
|
||
get(api_configuration_scripts_url) | ||
|
||
expected = { | ||
'count' => 1, | ||
'subcount' => 1, | ||
'name' => 'configuration_scripts', | ||
'resources' => [ | ||
hash_including('href' => api_configuration_script_url(nil, script)) | ||
] | ||
} | ||
expect(response.parsed_body).to include(expected) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'forbids access to configuration scripts without an appropriate role' do | ||
api_basic_authorize | ||
|
||
get(api_configuration_scripts_url) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
|
||
describe 'GET /api/configuration_scripts/:id' do | ||
it 'will show an ansible script with an appropriate role' do | ||
script = FactoryGirl.create(:configuration_script) | ||
api_basic_authorize action_identifier(:configuration_scripts, :read, :resource_actions, :get) | ||
|
||
get(api_configuration_script_url(nil, script)) | ||
|
||
expect(response.parsed_body) | ||
.to include('href' => api_configuration_script_url(nil, script)) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'forbids access to an ansible script without an appropriate role' do | ||
script = FactoryGirl.create(:configuration_script) | ||
api_basic_authorize | ||
|
||
get(api_configuration_script_url(nil, script)) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
end |