Skip to content

Commit

Permalink
Merge pull request #13626 from jntullo/enhancement/get_ansible_reposi…
Browse files Browse the repository at this point in the history
…tories

Configuration Script Sources API
  • Loading branch information
abellotti authored Feb 7, 2017
2 parents cdae89a + dc84f65 commit a0d42cf
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class ConfigurationScriptSourcesController < BaseController
end
end
14 changes: 14 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
:get:
- :name: read
:identifier: embedded_configuration_script_payload_view
:configuration_script_sources:
:description: Configuration Script Source
:options:
- :collection
:verbs: *g
:klass: ConfigurationScriptSource
:collection_actions:
:get:
- :name: read
:identifier: embedded_configuration_script_source_view
:resource_actions:
:get:
- :name: read
:identifier: embedded_configuration_script_source_view
:auth:
:description: REST API Authentication
:options:
Expand Down
51 changes: 51 additions & 0 deletions spec/requests/api/configuration_script_sources_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
RSpec.describe 'Configuration Script Sources API' do
describe 'GET /api/configuration_script_sources' do
it 'lists all the configuration script sources with an appropriate role' do
repository = FactoryGirl.create(:configuration_script_source)
api_basic_authorize collection_action_identifier(:configuration_script_sources, :read, :get)

run_get(configuration_script_sources_url)

expected = {
'count' => 1,
'subcount' => 1,
'name' => 'configuration_script_sources',
'resources' => [hash_including('href' => a_string_matching(configuration_script_sources_url(repository.id)))]
}
expect(response.parsed_body).to include(expected)
expect(response).to have_http_status(:ok)
end

it 'forbids access to configuration script sources without an appropriate role' do
api_basic_authorize

run_get(configuration_script_sources_url)

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

describe 'GET /api/configuration_script_sources/:id' do
it 'will show a configuration script source with an appropriate role' do
repository = FactoryGirl.create(:configuration_script_source)
api_basic_authorize collection_action_identifier(:configuration_script_sources, :read, :get)

run_get(configuration_script_sources_url(repository.id))

expected = {
'href' => a_string_matching(configuration_script_sources_url(repository.id))
}
expect(response.parsed_body).to include(expected)
expect(response).to have_http_status(:ok)
end

it 'forbids access to a configuration script source without an appropriate role' do
repository = FactoryGirl.create(:configuration_script_source)
api_basic_authorize

run_get(configuration_script_sources_url(repository.id))

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

0 comments on commit a0d42cf

Please sign in to comment.