diff --git a/app/services/foreman_openscap/lookup_key_overrider.rb b/app/services/foreman_openscap/lookup_key_overrider.rb index 257eb6b9..31bfa690 100644 --- a/app/services/foreman_openscap/lookup_key_overrider.rb +++ b/app/services/foreman_openscap/lookup_key_overrider.rb @@ -15,9 +15,10 @@ def override def handle_config_not_available(config) return true if config.available? - @policy.errors[:deploy_by] << + @policy.errors.add(:deploy_by, _("%{type} was selected to deploy policy to clients, but %{type} is not available. Are you missing a plugin?") % { :type => config.type.to_s.camelize } + ) false end @@ -25,7 +26,7 @@ def handle_config_item_not_available(config, item) return true if item err = _("Required %{msg_name} %{class} was not found, please ensure it is imported first.") % { :class => config.config_item_name, :msg_name => config.msg_name } - @policy.errors[:base] << err + @policy.errors.add(:base, err) false end @@ -34,7 +35,7 @@ def handle_missing_lookup_keys(config, key_names) err = _("The following %{key_name} were missing for %{item_name}: %{key_names}. Make sure they are imported before proceeding.") % { :key_name => config.lookup_key_plural_name, :key_names => key_names, :item_name => config.config_item_name } - @policy.errors[:base] << err + @policy.errors.add(:base, err) false end @@ -52,9 +53,9 @@ def handle_policies_param_override(config, param) def handle_param_override(config, param) if param.changed? && !param.save - @policy.errors[:base] << + @policy.errors.add(:base, _('Failed to save when overriding parameters for %{config_tool}, cause: %{errors}') % - { :config_tool => config.type, :errors => param.errors.full_messages.join(', ') } + { :config_tool => config.type, :errors => param.errors.full_messages.join(', ') }) return false end true diff --git a/config/routes.rb b/config/routes.rb index ee32102a..fc5b8c8b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -62,7 +62,7 @@ namespace :api, :defaults => { :format => 'json' } do scope "(:apiv)", :module => :v2, :defaults => { :apiv => 'v2' }, - :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do + :apiv => /v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do namespace :compliance do resources :scap_contents, :except => %i[new edit] do member do @@ -95,6 +95,14 @@ post 'arf_reports/:cname/:policy_id/:date', \ :constraints => { :cname => /[^\/]+/ }, :to => 'arf_reports#create' end + + constraints(:id => %r{[^\/]+}) do + resources :hosts, :except => [:new, :edit] do + member do + get :policies_enc + end + end + end end end end @@ -113,19 +121,4 @@ post 'openscap_proxy_changed' end end - - namespace :api do - scope "(:api_version)", :module => :v2, - :defaults => { :api_version => 'v2' }, - :api_version => /v2/, - :constraints => ApiConstraints.new(:version => 2, :default => true) do - constraints(:id => %r{[^\/]+}) do - resources :hosts, :only => [] do - member do - get :policies_enc - end - end - end - end - end end diff --git a/test/functional/openscap_proxies_controller_test.rb b/test/functional/openscap_proxies_controller_test.rb index 706662e0..47506f31 100644 --- a/test/functional/openscap_proxies_controller_test.rb +++ b/test/functional/openscap_proxies_controller_test.rb @@ -1,5 +1,4 @@ require 'test_plugin_helper' -require 'application_helper' class OpenscapProxiesControllerTest < ActionController::TestCase include ActionView::Helpers::DateHelper