From f78b0eecf04c1df6ea415476e29a1a993ce5337d Mon Sep 17 00:00:00 2001 From: Nadja Heitmann Date: Thu, 23 Sep 2021 11:31:01 +0000 Subject: [PATCH] Fixes #33550 - Remove Puppet API endpoints --- .../api/v2/config_groups_controller.rb | 27 -------- .../api/v2/environments_controller.rb | 46 -------------- .../api/v2/host_classes_controller.rb | 19 ------ .../api/v2/hostgroup_classes_controller.rb | 19 ------ .../api/v2/override_values_controller.rb | 31 ---------- .../api/v2/puppet_hosts_controller.rb | 26 -------- .../api/v2/puppetclasses_controller.rb | 43 ------------- .../v2/smart_class_parameters_controller.rb | 29 --------- .../api/v2/smart_proxies_controller.rb | 1 - .../import_puppetclasses_common_controller.rb | 29 --------- config/routes/api/v2.rb | 61 ------------------- .../api/v2/config_groups_controller_test.rb | 43 ------------- .../api/v2/environments_controller_test.rb | 45 -------------- .../api/v2/host_classes_controller_test.rb | 27 -------- .../api/v2/hostgroup_class_controller_test.rb | 27 -------- .../api/v2/override_values_controller_test.rb | 43 ------------- .../api/v2/puppetclasses_controller_test.rb | 45 -------------- .../smart_class_parameters_controller_test.rb | 30 --------- 18 files changed, 591 deletions(-) delete mode 100644 app/controllers/api/v2/config_groups_controller.rb delete mode 100644 app/controllers/api/v2/environments_controller.rb delete mode 100644 app/controllers/api/v2/host_classes_controller.rb delete mode 100644 app/controllers/api/v2/hostgroup_classes_controller.rb delete mode 100644 app/controllers/api/v2/override_values_controller.rb delete mode 100644 app/controllers/api/v2/puppet_hosts_controller.rb delete mode 100644 app/controllers/api/v2/puppetclasses_controller.rb delete mode 100644 app/controllers/api/v2/smart_class_parameters_controller.rb delete mode 100644 app/controllers/concerns/api/import_puppetclasses_common_controller.rb delete mode 100644 test/controllers/api/v2/config_groups_controller_test.rb delete mode 100644 test/controllers/api/v2/environments_controller_test.rb delete mode 100644 test/controllers/api/v2/host_classes_controller_test.rb delete mode 100644 test/controllers/api/v2/hostgroup_class_controller_test.rb delete mode 100644 test/controllers/api/v2/override_values_controller_test.rb delete mode 100644 test/controllers/api/v2/puppetclasses_controller_test.rb delete mode 100644 test/controllers/api/v2/smart_class_parameters_controller_test.rb diff --git a/app/controllers/api/v2/config_groups_controller.rb b/app/controllers/api/v2/config_groups_controller.rb deleted file mode 100644 index d076605ece9..00000000000 --- a/app/controllers/api/v2/config_groups_controller.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Api - module V2 - class ConfigGroupsController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/config_groups", N_("List of config groups") - def index - end - - api :GET, "/config_groups/:id/", N_("Show a config group") - def show - end - - api :POST, "/config_groups/", N_("Create a config group") - def create - end - - api :PUT, "/config_groups/:id/", N_("Update a config group") - def update - end - - api :DELETE, "/config_groups/:id/", N_("Delete a config group") - def destroy - end - end - end -end diff --git a/app/controllers/api/v2/environments_controller.rb b/app/controllers/api/v2/environments_controller.rb deleted file mode 100644 index ed11c878df1..00000000000 --- a/app/controllers/api/v2/environments_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Api - module V2 - class EnvironmentsController < V2::BaseController - include Api::ImportPuppetclassesCommonController - include Api::V2::ExtractedPuppetController - - api :GET, "/environments/", N_("List all environments") - api :GET, "/puppetclasses/:puppetclass_id/environments", N_("List environments of Puppet class") - api :GET, "/locations/:location_id/environments", N_("List environments per location") - api :GET, "/organizations/:organization_id/environments", N_("List environments per organization") - def index - end - - api :GET, "/environments/:id/", N_("Show an environment") - param :id, :identifier, :required => true - def show - end - - def_param_group :environment do - param :environment, Hash, :required => true, :action_aware => true do - param :name, String, :required => true - param_group :taxonomies, ::Api::V2::BaseController - end - end - - api :POST, "/environments/", N_("Create an environment") - param_group :environment, :as => :create - - def create - end - - api :PUT, "/environments/:id/", N_("Update an environment") - param :id, :identifier, :required => true - param_group :environment - - def update - end - - api :DELETE, "/environments/:id/", N_("Delete an environment") - param :id, :identifier, :required => true - - def destroy - end - end - end -end diff --git a/app/controllers/api/v2/host_classes_controller.rb b/app/controllers/api/v2/host_classes_controller.rb deleted file mode 100644 index 26025cb428a..00000000000 --- a/app/controllers/api/v2/host_classes_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Api - module V2 - class HostClassesController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/hosts/:host_id/puppetclass_ids/", N_("List all Puppet class IDs for host") - def index - end - - api :POST, "/hosts/:host_id/puppetclass_ids", N_("Add a Puppet class to host") - def create - end - - api :DELETE, "/hosts/:host_id/puppetclass_ids/:id/", N_("Remove a Puppet class from host") - def destroy - end - end - end -end diff --git a/app/controllers/api/v2/hostgroup_classes_controller.rb b/app/controllers/api/v2/hostgroup_classes_controller.rb deleted file mode 100644 index 3adda445454..00000000000 --- a/app/controllers/api/v2/hostgroup_classes_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Api - module V2 - class HostgroupClassesController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/hostgroups/:hostgroup_id/puppetclass_ids/", N_("List all Puppet class IDs for host group") - def index - end - - api :POST, "/hostgroups/:hostgroup_id/puppetclass_ids", N_("Add a Puppet class to host group") - def create - end - - api :DELETE, "/hostgroups/:hostgroup_id/puppetclass_ids/:id/", N_("Remove a Puppet class from host group") - def destroy - end - end - end -end diff --git a/app/controllers/api/v2/override_values_controller.rb b/app/controllers/api/v2/override_values_controller.rb deleted file mode 100644 index 90c2280c933..00000000000 --- a/app/controllers/api/v2/override_values_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Api - module V2 - class OverrideValuesController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/smart_class_parameters/:smart_class_parameter_id/override_values", N_("List of override values for a specific smart class parameter") - def index - end - - api :GET, "/smart_class_parameters/:smart_class_parameter_id/override_values/:id", N_("Show an override value for a specific smart class parameter") - def show - end - - api :POST, "/smart_class_parameters/:smart_class_parameter_id/override_values", N_("Create an override value for a specific smart class parameter") - def create - end - - api :PUT, "/smart_class_parameters/:smart_class_parameter_id/override_values/:id", N_("Update an override value for a specific smart class parameter") - def update - end - - api :DELETE, "/smart_class_parameters/:smart_class_parameter_id/override_values/:id", N_("Delete an override value for a specific smart class parameter") - def destroy - end - - def resource_human_name - _('Override Value') - end - end - end -end diff --git a/app/controllers/api/v2/puppet_hosts_controller.rb b/app/controllers/api/v2/puppet_hosts_controller.rb deleted file mode 100644 index 900ed7631c5..00000000000 --- a/app/controllers/api/v2/puppet_hosts_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Api - module V2 - class PuppetHostsController < V2::BaseController - include Api::Version2 - include HostsControllerExtension - - prepend_before_action :fail_and_inform_about_plugin - - resource_description do - desc 'This resource has been deprecated, to continue using it please install Foreman Remote Execution Plugin.' - deprecated true - end - - api :PUT, "/hosts/:id/puppetrun", N_("Force a Puppet agent run on the host") - description 'This resource has been deprecated, to continue using it, install Foreman Remote Execution Plugin.' - param :id, :identifier_dottable, :required => true - - def puppetrun - end - - def fail_and_inform_about_plugin - render json: { message: _('The puppetrun feature has been removed, however you can use the Remote Execution Plugin to run Puppet commands') }, status: :not_implemented - end - end - end -end diff --git a/app/controllers/api/v2/puppetclasses_controller.rb b/app/controllers/api/v2/puppetclasses_controller.rb deleted file mode 100644 index d50e9177c64..00000000000 --- a/app/controllers/api/v2/puppetclasses_controller.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Api - module V2 - class PuppetclassesController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/puppetclasses/", N_("List all Puppet classes") - api :GET, "/hosts/:host_id/puppetclasses", N_("List all Puppet classes for a host") - api :GET, "/hostgroups/:hostgroup_id/puppetclasses", N_("List all Puppet classes for a host group") - api :GET, "/environments/:environment_id/puppetclasses", N_("List all Puppet classes for an environment") - def index - end - - api :GET, "/puppetclasses/:id", N_("Show a Puppet class") - api :GET, "/hosts/:host_id/puppetclasses/:id", N_("Show a Puppet class for host") - api :GET, "/hostgroups/:hostgroup_id/puppetclasses/:id", N_("Show a Puppet class for a host group") - api :GET, "/environments/:environment_id/puppetclasses/:id", N_("Show a Puppet class for an environment") - def show - end - - def_param_group :puppetclass do - param :puppetclass, Hash, :required => true, :action_aware => true do - param :name, String, :required => true - end - end - - api :POST, "/puppetclasses/", N_("Create a Puppet class") - param_group :puppetclass, :as => :create - def create - end - - api :PUT, "/puppetclasses/:id/", N_("Update a Puppet class") - param :id, String, :required => true - param_group :puppetclass - def update - end - - api :DELETE, "/puppetclasses/:id/", N_("Delete a Puppet class") - param :id, String, :required => true - def destroy - end - end - end -end diff --git a/app/controllers/api/v2/smart_class_parameters_controller.rb b/app/controllers/api/v2/smart_class_parameters_controller.rb deleted file mode 100644 index 604b1060b81..00000000000 --- a/app/controllers/api/v2/smart_class_parameters_controller.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Api - module V2 - class SmartClassParametersController < V2::BaseController - include Api::V2::ExtractedPuppetController - - api :GET, "/smart_class_parameters", N_("List all smart class parameters") - api :GET, "/hosts/:host_id/smart_class_parameters", N_("List of smart class parameters for a specific host") - api :GET, "/hostgroups/:hostgroup_id/smart_class_parameters", N_("List of smart class parameters for a specific host group") - api :GET, "/puppetclasses/:puppetclass_id/smart_class_parameters", N_("List of smart class parameters for a specific Puppet class") - api :GET, "/environments/:environment_id/smart_class_parameters", N_("List of smart class parameters for a specific environment") - api :GET, "/environments/:environment_id/puppetclasses/:puppetclass_id/smart_class_parameters", N_("List of smart class parameters for a specific environment/Puppet class combination") - def index - end - - api :GET, "/smart_class_parameters/:id/", N_("Show a smart class parameter") - - def show - end - - api :PUT, "/smart_class_parameters/:id", N_("Update a smart class parameter") - def update - end - - def resource_human_name - _('Smart Class Parameter') - end - end - end -end diff --git a/app/controllers/api/v2/smart_proxies_controller.rb b/app/controllers/api/v2/smart_proxies_controller.rb index c9b4f0192e6..6e14453f80a 100644 --- a/app/controllers/api/v2/smart_proxies_controller.rb +++ b/app/controllers/api/v2/smart_proxies_controller.rb @@ -2,7 +2,6 @@ module Api module V2 class SmartProxiesController < V2::BaseController include Api::Version2 - include Api::ImportPuppetclassesCommonController include Foreman::Controller::Parameters::SmartProxy before_action :find_resource, :only => %w{show update destroy refresh version logs} diff --git a/app/controllers/concerns/api/import_puppetclasses_common_controller.rb b/app/controllers/concerns/api/import_puppetclasses_common_controller.rb deleted file mode 100644 index 05019d9b180..00000000000 --- a/app/controllers/concerns/api/import_puppetclasses_common_controller.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Api::ImportPuppetclassesCommonController - extend ActiveSupport::Concern - - included do - prepend_before_action :fail_and_inform_about_plugin, only: :import_puppetclasses - end - - def resource_human_name - resource_class.model_name.name - end - - def fail_and_inform_about_plugin - render json: { message: _('To access import_puppetclasses API you need to install the Foreman Puppet plugin')}, status: :not_implemented - end - - extend Apipie::DSL::Concern - - api :POST, "/smart_proxies/:id/import_puppetclasses", N_("Import puppet classes from puppet proxy") - api :POST, "/smart_proxies/:smart_proxy_id/environments/:id/import_puppetclasses", N_("Import puppet classes from puppet proxy for an environment") - api :POST, "/environments/:environment_id/smart_proxies/:id/import_puppetclasses", N_("Import puppet classes from puppet proxy for an environment") - param :id, :identifier, :required => true - param :smart_proxy_id, String, :required => false - param :environment_id, String, :required => false - param :dryrun, :bool, :required => false - param :except, String, :required => false, :desc => N_("Optional comma-delimited string containing either 'new', 'updated', or 'obsolete' that is used to limit the imported Puppet classes") - - def import_puppetclasses - end -end diff --git a/config/routes/api/v2.rb b/config/routes/api/v2.rb index c76c7731600..2be1027b232 100644 --- a/config/routes/api/v2.rb +++ b/config/routes/api/v2.rb @@ -1,7 +1,6 @@ # config/routes/api/v2.rb Foreman::Application.routes.draw do namespace :api, :defaults => {:format => 'json'} do - puppet_plugin = Foreman::Plugin.find(:foreman_puppet) # new v2 routes that point to v2 scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do resources :architectures, :except => [:new, :edit] do @@ -59,26 +58,6 @@ resources :dashboard, :only => [:index] - resources :environments, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' do - resources :locations, :only => [:index, :show] - resources :organizations, :only => [:index, :show] - resources :smart_proxies, :only => [] do - post :import_puppetclasses, :on => :member, :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' - end - constraints(:id => /[^\/]+/) do - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - resources :puppetclasses, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/puppetclasses' do - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - end - end - resources :hosts, :except => [:new, :edit] - resources :template_combinations, :only => [:index, :show, :create, :update] - end - resources :fact_values, :only => [:index] resources :hostgroups, :except => [:new, :edit] do @@ -91,13 +70,6 @@ delete '/', :action => :reset end end - constraints(:id => /[^\/]+/) do - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - end - resources :puppetclasses, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/puppetclasses' - resources :hostgroup_classes, :path => :puppetclass_ids, :only => [:index, :create, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/hostgroup_classes' resources :hosts, :except => [:new, :edit] resources :template_combinations, :only => [:show, :index, :create, :update] end @@ -131,7 +103,6 @@ resources :media, :except => [:new, :edit] resources :ptables, :except => [:new, :edit] resources :architectures, :except => [:new, :edit] - resources :puppetclasses, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/puppetclasses' resources :os_default_templates, :except => [:new, :edit] end @@ -247,7 +218,6 @@ resources :template_kinds, :only => [:index] resources :template_combinations, :only => [:show, :destroy] - resources :config_groups, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/config_groups' resources :compute_attributes, :only => [:index, :show, :create, :update] @@ -322,10 +292,6 @@ put :refresh, :on => :member get :version, :on => :member get :logs, :on => :member - post :import_puppetclasses, :on => :member, :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' - resources :environments, :only => [] do - post :import_puppetclasses, :on => :member, :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' - end resources :autosign, :only => [:index, :create, :destroy] end resources :hosts, :except => [:new, :edit] do @@ -342,41 +308,17 @@ post :facts, :on => :collection resources :audits, :only => :index resources :facts, :only => :index, :controller => :fact_values - resources :host_classes, :path => :puppetclass_ids, :only => [:index, :create, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/host_classes' resources :interfaces, :except => [:new, :edit] resources :parameters, :except => [:new, :edit] do collection do delete '/', :action => :reset end end - resources :puppetclasses, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/puppetclasses' resources :config_reports, :only => [:index, :show] do get :last, :on => :collection end - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - end - - resources :puppetclasses, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/puppetclasses' do - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - resources :environments, :only => [] do - resources :smart_class_parameters, :except => [:new, :edit, :create], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - end - resources :hostgroups, :only => [:index, :show] - resources :environments, :only => [:index, :show], :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' end - - resources :smart_class_parameters, :except => [:new, :edit, :create, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/smart_class_parameters' do - resources :override_values, :except => [:new, :edit], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' - end - - resources :override_values, :only => [:update, :destroy], :controller => puppet_plugin && '/foreman_puppet/api/v2/override_values' end resources :locations, :except => [:new, :edit] do @@ -388,7 +330,6 @@ resources :realms, :only => [:index, :show] resources :subnets, :only => [:index, :show] resources :hostgroups, :only => [:index, :show] - resources :environments, :only => [:index, :show], :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' resources :users, :only => [:index, :show] resources :provisioning_templates, :only => [:index, :show] resources :ptables, :only => [:index, :show] @@ -413,7 +354,6 @@ resources :realms, :only => [:index, :show] resources :subnets, :only => [:index, :show] resources :hostgroups, :only => [:index, :show] - resources :environments, :only => [:index, :show], :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' resources :users, :only => [:index, :show] resources :provisioning_templates, :only => [:index, :show] resources :ptables, :only => [:index, :show] @@ -435,7 +375,6 @@ resources :realms, :only => [:index, :show] resources :subnets, :only => [:index, :show] resources :hostgroups, :only => [:index, :show] - resources :environments, :only => [:index, :show], :controller => puppet_plugin && '/foreman_puppet/api/v2/environments' resources :users, :only => [:index, :show] resources :provisioning_templates, :only => [:index, :show] resources :ptables, :only => [:index, :show] diff --git a/test/controllers/api/v2/config_groups_controller_test.rb b/test/controllers/api/v2/config_groups_controller_test.rb deleted file mode 100644 index 3208cee1bb7..00000000000 --- a/test/controllers/api/v2/config_groups_controller_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'test_helper' - -class Api::V2::ConfigGroupsControllerTest < ActionController::TestCase - test "should not get index" do - skip('Foreman Puppet Enc plugin is installed') if Foreman::Plugin.find(:foreman_puppet_enc) - get :index, params: { smart_class_parameter_id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access ConfigGroup API, you need to install the Foreman Puppet plugin' - end - - test "should not get create" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet_enc) - post :create, params: { smart_class_parameter_id: 213 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access ConfigGroup API, you need to install the Foreman Puppet plugin' - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet_enc) - get :show, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access ConfigGroup API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet_enc) - patch :update, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access ConfigGroup API, you need to install the Foreman Puppet plugin' - end - - test "should not destroy" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet_enc) - delete :destroy, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access ConfigGroup API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/environments_controller_test.rb b/test/controllers/api/v2/environments_controller_test.rb deleted file mode 100644 index d5d7ae2d481..00000000000 --- a/test/controllers/api/v2/environments_controller_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test_helper' - -class Api::V2::EnvironmentsControllerTest < ActionController::TestCase - [{}, { puppetclass_id: 123 }, { location_id: 123 }, { organization_id: 123 }].each do |params| - test "should not get index with #{params.inspect}" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: params - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Environment API, you need to install the Foreman Puppet plugin' - end - - test "should not show with #{params.inspect}" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :show, params: params.merge(id: 121) - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Environment API, you need to install the Foreman Puppet plugin' - end - end - - test "should not create" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :create, params: { name: 'PuppetClassName' } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Environment API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :update, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Environment API, you need to install the Foreman Puppet plugin' - end - - test "should not destroy" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - delete :destroy, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Environment API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/host_classes_controller_test.rb b/test/controllers/api/v2/host_classes_controller_test.rb deleted file mode 100644 index fc43e2965e8..00000000000 --- a/test/controllers/api/v2/host_classes_controller_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'test_helper' - -class Api::V2::HostClassesControllerTest < ActionController::TestCase - test "should not get index" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: { host_id: 123 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostClass API, you need to install the Foreman Puppet plugin' - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :create, params: { host_id: 123 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostClass API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :destroy, params: { host_id: 123, id: 124 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostClass API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/hostgroup_class_controller_test.rb b/test/controllers/api/v2/hostgroup_class_controller_test.rb deleted file mode 100644 index 9efb4a02258..00000000000 --- a/test/controllers/api/v2/hostgroup_class_controller_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'test_helper' - -class Api::V2::HostgroupClassesControllerTest < ActionController::TestCase - test "should not get index" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: { hostgroup_id: 123 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostgroupClass API, you need to install the Foreman Puppet plugin' - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :create, params: { hostgroup_id: 123 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostgroupClass API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :destroy, params: { hostgroup_id: 123, id: 124 } - assert_response :not_implemented - json_response = ActiveSupport::JSON.decode(response.body) - assert_equal json_response['message'], 'To access HostgroupClass API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/override_values_controller_test.rb b/test/controllers/api/v2/override_values_controller_test.rb deleted file mode 100644 index 8f43083f916..00000000000 --- a/test/controllers/api/v2/override_values_controller_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'test_helper' - -class Api::V2::OverrideValuesControllerTest < ActionController::TestCase - test "should not get index" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: { smart_class_parameter_id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Override Value API, you need to install the Foreman Puppet plugin' - end - - test "should not get create" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - post :create, params: { smart_class_parameter_id: 213 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Override Value API, you need to install the Foreman Puppet plugin' - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :show, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Override Value API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :update, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Override Value API, you need to install the Foreman Puppet plugin' - end - - test "should not destroy" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - delete :destroy, params: { smart_class_parameter_id: 213, id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Override Value API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/puppetclasses_controller_test.rb b/test/controllers/api/v2/puppetclasses_controller_test.rb deleted file mode 100644 index c6af16918df..00000000000 --- a/test/controllers/api/v2/puppetclasses_controller_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test_helper' - -class Api::V2::PuppetclassesControllerTest < ActionController::TestCase - [{}, { host_id: 123 }, { hostgroup_id: 123 }, { environment_id: 123 }].each do |params| - test "should not get index with #{params.inspect}" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: params - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Puppetclass API, you need to install the Foreman Puppet plugin' - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :show, params: params.merge(id: 121) - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Puppetclass API, you need to install the Foreman Puppet plugin' - end - end - - test "should not create" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :create, params: { name: 'PuppetClassName' } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Puppetclass API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :update, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Puppetclass API, you need to install the Foreman Puppet plugin' - end - - test "should not destroy" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - delete :destroy, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Puppetclass API, you need to install the Foreman Puppet plugin' - end -end diff --git a/test/controllers/api/v2/smart_class_parameters_controller_test.rb b/test/controllers/api/v2/smart_class_parameters_controller_test.rb deleted file mode 100644 index 28c7d675c20..00000000000 --- a/test/controllers/api/v2/smart_class_parameters_controller_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'test_helper' - -class Api::V2::SmartClassParametersControllerTest < ActionController::TestCase - [{}, { host_id: 123 }, { hostgroup_id: 123 }, { puppetclass_id: 123 }, - { environment_id: 123 }, { puppetclass_id: 123, environment_id: 124 }].each do |params| - test "should not get index with #{params.inspect}" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :index, params: params - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Smart Class Parameter API, you need to install the Foreman Puppet plugin' - end - end - - test "should not show" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - get :show, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Smart Class Parameter API, you need to install the Foreman Puppet plugin' - end - - test "should not update" do - skip('Foreman Puppet plugin is installed') if Foreman::Plugin.find(:foreman_puppet) - patch :update, params: { id: 123 } - assert_response :not_implemented - response = ActiveSupport::JSON.decode(@response.body) - assert_equal response['message'], 'To access Smart Class Parameter API, you need to install the Foreman Puppet plugin' - end -end