diff --git a/app/controllers/api/v1/architectures_controller.rb b/app/controllers/api/v1/architectures_controller.rb
deleted file mode 100644
index 1fa960bc1375..000000000000
--- a/app/controllers/api/v1/architectures_controller.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module Api
- module V1
- class ArchitecturesController < V1::BaseController
- include Foreman::Controller::Parameters::Architecture
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/architectures/", "List all architectures."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @architectures = Architecture.
- authorized(:view_architectures).
- includes(:operatingsystems).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/architectures/:id/", "Show an architecture."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/architectures/", "Create an architecture."
- param :architecture, Hash, :required => true do
- param :name, String, :required => true
- param :operatingsystem_ids, Array, :desc => "Operatingsystem ID's"
- end
-
- def create
- @architecture = Architecture.new(architecture_params)
- process_response @architecture.save
- end
-
- api :PUT, "/architectures/:id/", "Update an architecture."
- param :id, :identifier, :required => true
- param :architecture, Hash, :required => true do
- param :name, String
- param :operatingsystem_ids, Array, :desc => "Operatingsystem ID's"
- end
-
- def update
- process_response @architecture.update_attributes(architecture_params)
- end
-
- api :DELETE, "/architectures/:id/", "Delete an architecture."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @architecture.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/audits_controller.rb b/app/controllers/api/v1/audits_controller.rb
deleted file mode 100644
index f8290073f55a..000000000000
--- a/app/controllers/api/v1/audits_controller.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module Api
- module V1
- class AuditsController < V1::BaseController
- before_action :find_resource, :only => %w{show update destroy}
- before_action :setup_search_options, :only => :index
-
- api :GET, "/audits/", "List all audits."
- api :GET, "/hosts/:host_id/audits/", "List all audits for a given host."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- Audit.unscoped { @audits = Audit.authorized(:view_audit_logs).search_for(*search_options).paginate(paginate_options) }
- end
-
- api :GET, "/audits/:id/", "Show an audit"
- param :id, :identifier, :required => true
-
- def show
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/auth_source_ldaps_controller.rb b/app/controllers/api/v1/auth_source_ldaps_controller.rb
deleted file mode 100644
index edd1fc0b2ee7..000000000000
--- a/app/controllers/api/v1/auth_source_ldaps_controller.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-module Api
- module V1
- class AuthSourceLdapsController < V1::BaseController
- include Foreman::Controller::Parameters::AuthSourceLdap
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/auth_source_ldaps/", "List all authsource ldaps"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @auth_source_ldaps = AuthSourceLdap.paginate(paginate_options)
- end
-
- api :GET, "/auth_source_ldaps/:id/", "Show an authsource ldap."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/auth_source_ldaps/", "Create an auth_source_ldap."
- param :auth_source_ldap, Hash, :required => true do
- param :name, String, :required => true
- param :host, String, :required => true
- param :port, :number, :desc => "defaults to 389"
- param :account, String
- param :base_dn, String
- param :account_password, String, :desc => "required if onthefly_register is true"
- param :attr_login, String, :desc => "required if onthefly_register is true"
- param :attr_firstname, String, :desc => "required if onthefly_register is true"
- param :attr_lastname, String, :desc => "required if onthefly_register is true"
- param :attr_mail, String, :desc => "required if onthefly_register is true"
- param :attr_photo, String
- param :onthefly_register, :bool
- param :usergroup_sync, :bool, :desc => N_("sync external user groups on login")
- param :tls, :bool
- end
-
- def create
- @auth_source_ldap = AuthSourceLdap.new(auth_source_ldap_params)
- process_response @auth_source_ldap.save
- end
-
- api :PUT, "/auth_source_ldaps/:id/", "Update an auth_source_ldap."
- param :id, String, :required => true
- param :auth_source_ldap, Hash, :required => true do
- param :name, String
- param :host, String
- param :port, :number, :desc => "defaults to 389"
- param :account, String
- param :base_dn, String
- param :account_password, String, :desc => "required if onthefly_register is true"
- param :attr_login, String, :desc => "required if onthefly_register is true"
- param :attr_firstname, String, :desc => "required if onthefly_register is true"
- param :attr_lastname, String, :desc => "required if onthefly_register is true"
- param :attr_mail, String, :desc => "required if onthefly_register is true"
- param :attr_photo, String
- param :onthefly_register, :bool
- param :usergroup_sync, :bool, :desc => N_("sync external user groups on login")
- param :tls, :bool
- end
-
- def update
- process_response @auth_source_ldap.update_attributes(auth_source_ldap_params)
- end
-
- api :DELETE, "/auth_source_ldaps/:id/", "Delete an auth_source_ldap."
- param :id, String, :required => true
-
- def destroy
- process_response @auth_source_ldap.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/autosign_controller.rb b/app/controllers/api/v1/autosign_controller.rb
deleted file mode 100644
index 0c59f61a91fe..000000000000
--- a/app/controllers/api/v1/autosign_controller.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module Api
- module V1
- class AutosignController < V1::BaseController
- before_action :find_required_nested_object, :setup_proxy
-
- api :GET, "/smart_proxies/smart_proxy_id/autosign", "List all autosign"
-
- def index
- autosign = @api.autosign
- render :json => autosign
- end
-
- private
-
- def setup_proxy
- @api = ProxyAPI::Puppetca.new({:url => @nested_obj.url})
- end
-
- def allowed_nested_id
- %w(smart_proxy_id)
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb
deleted file mode 100644
index 4561d0b147fe..000000000000
--- a/app/controllers/api/v1/base_controller.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-module Api
- module V1
- class BaseController < Api::BaseController
- include Api::Version1
-
- resource_description do
- api_version "v1"
- app_info N_("Foreman API v1 is deprecated. Please use v2.
If you still need to use v1, you may do so by either passing 'version=1' in the Accept Header or using api/v1/ in the URL.")
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb
deleted file mode 100644
index 490b80190c15..000000000000
--- a/app/controllers/api/v1/bookmarks_controller.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module Api
- module V1
- class BookmarksController < V1::BaseController
- include Foreman::Controller::BookmarkCommon
- include Foreman::Controller::Parameters::Bookmark
-
- before_action :find_resource, :only => [:show, :update, :destroy]
-
- api :GET, "/bookmarks/", "List all bookmarks."
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @bookmarks = Bookmark.my_bookmarks.paginate(paginate_options)
- end
-
- api :GET, "/bookmarks/:id/", "Show a bookmark."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/bookmarks/", "Create a bookmark."
- param :bookmark, Hash, :required => true do
- param :name, String, :required => true
- param :controller, String, :required => true
- param :query, String, :required => true
- param :public, :bool
- end
-
- def create
- @bookmark = Bookmark.new(bookmark_params)
- process_response @bookmark.save
- end
-
- api :PUT, "/bookmarks/:id/", "Update a bookmark."
- param :id, :identifier, :required => true
- param :bookmark, Hash, :required => true do
- param :name, String
- param :controller, String
- param :query, String
- param :public, :bool
- end
-
- def update
- process_response @bookmark.update_attributes(bookmark_params)
- end
-
- api :DELETE, "/bookmarks/:id/", "Delete a bookmark."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @bookmark.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/common_parameters_controller.rb b/app/controllers/api/v1/common_parameters_controller.rb
deleted file mode 100644
index e9d21b25889c..000000000000
--- a/app/controllers/api/v1/common_parameters_controller.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-module Api
- module V1
- class CommonParametersController < V1::BaseController
- include Foreman::Controller::Parameters::Parameter
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/common_parameters/", "List all common parameters."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @common_parameters = CommonParameter.
- authorized(:view_params, Parameter).where(:type => 'CommonParameter').
- search_for(*search_options).
- paginate(paginate_options)
- end
-
- api :GET, "/common_parameters/:id/", "Show a common parameter."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/common_parameters/", "Create a common_parameter"
- param :common_parameter, Hash, :required => true do
- param :name, String, :required => true
- param :value, String, :required => true
- param :hidden_value, [true, false]
- end
-
- def create
- @common_parameter = CommonParameter.new(parameter_params(::CommonParameter))
- process_response @common_parameter.save
- end
-
- api :PUT, "/common_parameters/:id/", "Update a common_parameter"
- param :id, :identifier, :required => true
- param :common_parameter, Hash, :required => true do
- param :name, String
- param :value, String
- param :hidden_value, [true, false]
- end
-
- def update
- process_response @common_parameter.update_attributes(parameter_params(::CommonParameter))
- end
-
- api :DELETE, "/common_parameters/:id/", "Delete a common_parameter"
- param :id, :identifier, :required => true
-
- def destroy
- process_response @common_parameter.destroy
- end
-
- private
-
- def controller_permission
- 'params'
- end
-
- def resource_scope(*args, &block)
- super.where(:type => 'CommonParameter')
- end
-
- def resource_class
- Parameter
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/compute_resources_controller.rb b/app/controllers/api/v1/compute_resources_controller.rb
deleted file mode 100644
index ff38813e1078..000000000000
--- a/app/controllers/api/v1/compute_resources_controller.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-module Api
- module V1
- class ComputeResourcesController < V1::BaseController
- include Foreman::Controller::Parameters::ComputeResource
-
- before_action :find_resource, :only => [:show, :update, :destroy]
-
- api :GET, "/compute_resources/", "List all compute resources."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @compute_resources = ComputeResource.
- authorized(:view_compute_resources).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/compute_resources/:id/", "Show an compute resource."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/compute_resources/", "Create a compute resource."
- param :compute_resource, Hash, :required => true do
- param :name, String, :required => true
- param :provider, String, :desc => "Providers include #{ComputeResource.providers.keys.join(', ')}"
- param :url, String, :desc => "URL for Libvirt, oVirt, and OpenStack"
- param :description, String
- param :user, String, :desc => "Username for oVirt, EC2, VMware, OpenStack. Access Key for EC2."
- param :password, String, :desc => "Password for oVirt, EC2, VMware, OpenStack. Secret key for EC2"
- param :uuid, String, :desc => "for oVirt, VMware Datacenter"
- param :region, String, :desc => "for EC2 only"
- param :tenant, String, :desc => "for OpenStack only"
- param :server, String, :desc => "for VMware"
- param :set_console_password, :bool, :desc => N_("for Libvirt and VMware only")
- end
-
- def create
- @compute_resource = ComputeResource.new_provider(compute_resource_params)
- process_response @compute_resource.save
- end
-
- api :PUT, "/compute_resources/:id/", "Update a compute resource."
- param :id, String, :required => true
- param :compute_resource, Hash, :required => true do
- param :name, String
- param :provider, String, :desc => "Providers include #{ComputeResource.providers.keys.join(', ')}"
- param :url, String, :desc => "URL for Libvirt, oVirt, and OpenStack"
- param :description, String
- param :user, String, :desc => "Username for oVirt, EC2, VMware, OpenStack. Access Key for EC2."
- param :password, String, :desc => "Password for oVirt, EC2, VMware, OpenStack. Secret key for EC2"
- param :uuid, String, :desc => "for oVirt, VMware Datacenter"
- param :region, String, :desc => "for EC2 only"
- param :tenant, String, :desc => "for OpenStack only"
- param :server, String, :desc => "for VMware"
- end
-
- def update
- process_response @compute_resource.update_attributes(compute_resource_params)
- end
-
- api :DELETE, "/compute_resources/:id/", "Delete a compute resource."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @compute_resource.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/config_templates_controller.rb b/app/controllers/api/v1/config_templates_controller.rb
deleted file mode 100644
index 969443b2c817..000000000000
--- a/app/controllers/api/v1/config_templates_controller.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-module Api
- module V1
- class ConfigTemplatesController < V1::BaseController
- include Foreman::Renderer
- include Foreman::Controller::ProvisioningTemplates
- include Foreman::Controller::Parameters::ProvisioningTemplate
-
- before_action :deprecated
-
- before_action :find_resource, :only => %w{show update destroy}
- before_action :handle_template_upload, :only => [:create, :update]
- before_action :process_template_kind, :only => [:create, :update]
-
- api :GET, "/config_templates/", "List templates"
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @config_templates = ProvisioningTemplate.
- authorized(:view_provisioning_templates).
- search_for(*search_options).paginate(paginate_options).
- includes(:operatingsystems, :template_combinations, :template_kind)
- end
-
- api :GET, "/config_templates/:id", "Show template details"
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/config_templates/", "Create a template"
- param :config_template, Hash, :required => true do
- param :name, String, :required => true, :desc => "template name"
- param :template, String, :required => true
- param :snippet, :bool, :allow_nil => true
- param :audit_comment, String, :allow_nil => true
- param :template_kind_id, :number, :allow_nil => true, :desc => "not relevant for snippet"
- param :template_combinations_attributes, Array,
- :desc => "Array of template combinations (hostgroup_id, environment_id)"
- param :operatingsystem_ids, Array, :desc => "Array of operating systems ID to associate the template with"
- end
-
- def create
- @config_template = ProvisioningTemplate.new(provisioning_template_params)
- process_response @config_template.save
- end
-
- api :PUT, "/config_templates/:id", "Update a template"
- param :id, :identifier, :required => true
- param :config_template, Hash, :required => true do
- param :name, String, :desc => "template name"
- param :template, String
- param :snippet, :bool
- param :audit_comment, String, :allow_nil => true
- param :template_kind_id, :number, :allow_nil => true, :desc => "not relevant for snippet"
- param :template_combinations_attributes, Array, :desc => "Array of template combinations (hostgroup_id, environment_id)"
- param :operatingsystem_ids, Array, :desc => "Array of operating systems ID to associate the template with"
- end
-
- def update
- process_response @config_template.update_attributes(provisioning_template_params)
- end
-
- api :GET, "/config_templates/revision"
- param :version, String, :desc => "template version"
-
- def revision
- audit = Audit.authorized(:view_audit_logs).find(params[:version])
- render :json => audit.revision.template
- end
-
- api :DELETE, "/config_templates/:id", "Delete a template"
- param :id, :identifier, :required => true
-
- def destroy
- process_response @config_template.destroy
- end
-
- api :GET, "/config_templates/build_pxe_default", "Change the default PXE menu on all configured TFTP servers"
-
- def build_pxe_default
- status, msg = ProvisioningTemplate.authorized(:deploy_provisioning_templates).build_pxe_default(self)
- render :json => msg, :status => status
- end
-
- private
-
- def type_name_singular
- @type_name_singular ||= resource_name
- end
-
- def resource_class
- ProvisioningTemplate
- end
-
- def deprecated
- Foreman::Deprecation.api_deprecation_warning("Config templates were renamed to provisioning templates")
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/dashboard_controller.rb b/app/controllers/api/v1/dashboard_controller.rb
deleted file mode 100644
index d29b709f5d08..000000000000
--- a/app/controllers/api/v1/dashboard_controller.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Api
- module V1
- class DashboardController < V1::BaseController
- param :search, String, :desc => "filter results", :required => false
- api :GET, "/dashboard/", "Get Dashboard results"
-
- def index
- status = Dashboard::Data.status(params[:search])
- respond_to do |format|
- format.yaml { render :plain => status.to_yaml }
- format.json { render :json => status }
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/domains_controller.rb b/app/controllers/api/v1/domains_controller.rb
deleted file mode 100644
index 369ff72ee8b3..000000000000
--- a/app/controllers/api/v1/domains_controller.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-module Api
- module V1
- class DomainsController < V1::BaseController
- include Foreman::Controller::Parameters::Domain
-
- resource_description do
- # TRANSLATORS: API documentation - do not translate
- desc <<-DOC
- Foreman considers a domain and a DNS zone as the same thing. That is, if you
- are planning to manage a site where all the machines are of the form
- hostname.somewhere.com then the domain is somewhere.com.
- This allows Foreman to associate a puppet variable with a domain/site
- and automatically append this variable to all external node requests made
- by machines at that site.
- DOC
- end
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/domains/", "List of domains"
- param :search, String, :desc => "Filter results"
- param :order, String, :desc => "Sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @domains = Domain.
- authorized(:view_domains).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/domains/:id/", "Show a domain."
- param :id, :identifier, :required => true, :desc => "May be numerical id or domain name"
-
- def show
- end
-
- api :POST, "/domains/", "Create a domain."
- # TRANSLATORS: API documentation - do not translate
- description <<-DOC
- The fullname field is used for human readability in reports
- and other pages that refer to domains, and also available as
- an external node parameter
- DOC
- param :domain, Hash, :required => true do
- param :name, String, :required => true, :desc => "The full DNS Domain name"
- param :fullname, String, :required => false, :allow_nil => true, :desc => "Full name describing the domain"
- param :dns_id, :number, :required => false, :allow_nil => true, :desc => "DNS Proxy to use within this domain"
- param :domain_parameters_attributes, Array, :required => false, :desc => "Array of parameters (name, value)"
- end
-
- def create
- @domain = Domain.new(domain_params)
- process_response @domain.save
- end
-
- api :PUT, "/domains/:id/", "Update a domain."
- param :id, :identifier, :required => true
- param :domain, Hash, :required => true do
- param :name, String, :allow_nil => true, :desc => "The full DNS Domain name"
- param :fullname, String, :allow_nil => true, :desc => "Full name describing the domain"
- param :dns_id, :number, :allow_nil => true, :desc => "DNS Proxy to use within this domain"
- param :domain_parameters_attributes, Array, :desc => "Array of parameters (name, value)"
- end
-
- def update
- process_response @domain.update_attributes(domain_params)
- end
-
- api :DELETE, "/domains/:id/", "Delete a domain."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @domain.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/environments_controller.rb b/app/controllers/api/v1/environments_controller.rb
deleted file mode 100644
index 0cba4e7a568a..000000000000
--- a/app/controllers/api/v1/environments_controller.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-module Api
- module V1
- class EnvironmentsController < V1::BaseController
- include Api::ImportPuppetclassesCommonController
- include Foreman::Controller::Parameters::Environment
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/environments/", "List all environments."
- param :search, String, :desc => "Filter results"
- param :order, String, :desc => "Sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @environments = Environment.
- authorized(:view_environments).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/environments/:id/", "Show an environment."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/environments/", "Create an environment."
- param :environment, Hash, :required => true do
- param :name, String, :required => true
- end
-
- def create
- @environment = Environment.new(environment_params)
- process_response @environment.save
- end
-
- api :PUT, "/environments/:id/", "Update an environment."
- param :id, :identifier, :required => true
- param :environment, Hash, :required => true do
- param :name, String
- end
-
- def update
- process_response @environment.update_attributes(environment_params)
- end
-
- api :DELETE, "/environments/:id/", "Delete an environment."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @environment.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/fact_values_controller.rb b/app/controllers/api/v1/fact_values_controller.rb
deleted file mode 100644
index eee45bc1d36f..000000000000
--- a/app/controllers/api/v1/fact_values_controller.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module Api
- module V1
- class FactValuesController < V1::BaseController
- before_action :setup_search_options, :only => :index
-
- api :GET, "/fact_values/", "List all fact values."
- api :GET, "/hosts/:host_id/facts/", "List all fact values of a given host."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- values = FactValue.
- authorized(:view_facts).
- my_facts.
- no_timestamp_facts.
- search_for(*search_options).paginate(paginate_options).
- preload(:fact_name, :host)
- render :json => FactValue.build_facts_hash(values.all)
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/home_controller.rb b/app/controllers/api/v1/home_controller.rb
deleted file mode 100644
index c0ba6f36e81c..000000000000
--- a/app/controllers/api/v1/home_controller.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Api
- module V1
- class HomeController < V1::BaseController
- before_action :require_admin, :only => [:index]
-
- api :GET, "/", "Show available links."
-
- def index
- # we need to load apipie documentation to show all the links.
- Apipie.reload_documentation if Apipie.configuration.reload_controllers?
- end
-
- api :GET, "/status/", "Show status."
-
- def status
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/hostgroups_controller.rb b/app/controllers/api/v1/hostgroups_controller.rb
deleted file mode 100644
index eedee32301ae..000000000000
--- a/app/controllers/api/v1/hostgroups_controller.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-module Api
- module V1
- class HostgroupsController < V1::BaseController
- include Foreman::Controller::Parameters::Hostgroup
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/hostgroups/", "List all hostgroups."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @hostgroups = Hostgroup.
- authorized(:view_hostgroups).
- includes(:hostgroup_classes, :group_parameters).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/hostgroups/:id/", "Show a hostgroup."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/hostgroups/", "Create an hostgroup."
- param :hostgroup, Hash, :required => true do
- param :name, String, :required => true
- param :parent_id, :number
- param :environment_id, :number
- param :operatingsystem_id, :number
- param :architecture_id, :number
- param :medium_id, :number
- param :ptable_id, :number
- param :puppet_ca_proxy_id, :number
- param :subnet_id, :number
- param :domain_id, :number
- param :puppet_proxy_id, :number
- end
-
- def create
- @hostgroup = Hostgroup.new(hostgroup_params)
- @hostgroup.suggest_default_pxe_loader if params[:hostgroup] && params[:hostgroup][:pxe_loader].nil?
-
- process_response @hostgroup.save
- end
-
- api :PUT, "/hostgroups/:id/", "Update an hostgroup."
- param :id, :identifier, :required => true
- param :hostgroup, Hash, :required => true do
- param :name, String
- param :parent_id, :number
- param :environment_id, :number
- param :operatingsystem_id, :number
- param :architecture_id, :number
- param :medium_id, :number
- param :pxe_loader, Operatingsystem.all_loaders, :desc => N_("DHCP filename option")
- param :ptable_id, :number
- param :puppet_ca_proxy_id, :number
- param :subnet_id, :number
- param :domain_id, :number
- param :puppet_proxy_id, :number
- end
-
- def update
- process_response @hostgroup.update_attributes(hostgroup_params)
- end
-
- api :DELETE, "/hostgroups/:id/", "Delete an hostgroup."
- param :id, :identifier, :required => true
-
- def destroy
- if @hostgroup.has_children?
- render :json => {'message'=> _("Cannot delete group %{current} because it has nested groups.") % { :current => @hostgroup.title } }, :status => :conflict
- else
- process_response @hostgroup.destroy
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/hosts_controller.rb b/app/controllers/api/v1/hosts_controller.rb
deleted file mode 100644
index 3e225ff720df..000000000000
--- a/app/controllers/api/v1/hosts_controller.rb
+++ /dev/null
@@ -1,157 +0,0 @@
-module Api
- module V1
- class HostsController < V1::BaseController
- include Api::CompatibilityChecker
- include Foreman::Controller::Parameters::Host
-
- before_action :check_create_host_nested, :only => [:create, :update]
- before_action :find_resource, :only => %w{show update destroy status}
-
- api :GET, "/hosts/", "List all hosts."
- param :search, String, :desc => "Filter results"
- param :order, String, :desc => "Sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @hosts = Host.
- authorized(:view_hosts, Host).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/hosts/:id/", "Show a host."
- param :id, :identifier_dottable, :required => true
-
- def show
- end
-
- api :POST, "/hosts/", "Create a host."
- param :host, Hash, :required => true do
- param :name, String, :required => true
- param :location_id, :number, :required => true, :desc => "required if locations are enabled" if SETTINGS[:locations_enabled]
- param :organization_id, :number, :required => true, :desc => "required if organizations are enabled" if SETTINGS[:organizations_enabled]
- param :environment_id, String, :desc => "required if host is managed and value is not inherited from host group"
- param :ip, String, :desc => "IPv4 address"
- param :ip6, String, :desc => "IPv6 address"
- param :mac, String, :desc => "required for managed host that is bare metal, not required if it's a virtual machine"
- param :architecture_id, :number, :desc => "required if host is managed and value is not inherited from host group"
- param :domain_id, :number, :desc => "required if host is managed and value is not inherited from host group"
- param :realm_id, :number
- param :puppet_proxy_id, :number
- param :puppetclass_ids, Array
- param :operatingsystem_id, String, :desc => "required if host is managed and value is not inherited from host group"
- param :medium_id, String, :desc => "required if not imaged based provisioning and host is managed and value is not inherited from host group"
- param :pxe_loader, Operatingsystem.all_loaders, :desc => N_("DHCP filename option")
- param :ptable_id, :number, :desc => "required if host is managed and custom partition has not been defined"
- param :subnet_id, :number, :desc => "IPv4 subnet"
- param :subnet6_id, :number, :desc => "IPv6 subnet"
- param :compute_resource_id, :number, :desc => "nil means host is bare metal"
- param :root_pass, String, :desc => "required if host is managed and value is not inherited from host group or default password in settings"
- param :model_id, :number
- param :hostgroup_id, :number
- param :owner_id, :number
- param :puppet_ca_proxy_id, :number
- param :image_id, :number
- param :host_parameters_attributes, Array, :desc => "Host's parameters (array or indexed hash)" do
- param :name, String, :desc => "Name of the parameter", :required => true
- param :value, String, :desc => "Parameter value", :required => true
- end
- param :build, :bool
- param :enabled, :bool, :desc => "Include this host within Foreman reporting"
- param :provision_method, String
- param :managed, :bool, :desc => "True/False flag whether a host is managed or unmanaged. Note: this value also determines whether several parameters are required or not"
- param :progress_report_id, String, :desc => "UUID to track orchestration tasks status, GET /api/orchestration/:UUID/tasks"
- param :comment, String, :desc => "Additional information about this host"
- param :capabilities, String
- param :compute_profile_id, :number
- param :compute_attributes, Hash do
- end
- end
-
- def create
- @host = Host.new(host_params)
- @host.managed = true if (params[:host] && params[:host][:managed].nil?)
- @host.suggest_default_pxe_loader if params[:host] && params[:host][:pxe_loader].nil?
- forward_request_url
- process_response @host.save
- end
-
- api :PUT, "/hosts/:id/", "Update a host."
- param :id, :identifier, :required => true
- param :host, Hash, :required => true do
- param :name, String
- param :environment_id, String
- param :ip, String, :desc => "IPv4 address, not required if using a subnet with dhcp proxy"
- param :ip6, String, :desc => "IPv6 address"
- param :mac, String, :desc => "not required if its a virtual machine"
- param :architecture_id, :number
- param :domain_id, :number
- param :puppet_proxy_id, :number
- param :operatingsystem_id, String
- param :puppetclass_ids, Array
- param :medium_id, :number
- param :ptable_id, :number
- param :subnet_id, :number, :desc => "IPv4 subnet"
- param :subnet6_id, :number, :desc => "IPv6 subnet"
- param :compute_resource_id, :number
- param :sp_subnet_id, :number
- param :model_id, :number
- param :hostgroup_id, :number
- param :owner_id, :number
- param :puppet_ca_proxy_id, :number
- param :image_id, :number
- param :host_parameters_attributes, Array
- param :build, :bool
- param :enabled, :bool
- param :provision_method, String
- param :managed, :bool
- param :progress_report_id, String, :desc => 'UUID to track orchestration tasks status, GET /api/orchestration/:UUID/tasks'
- param :capabilities, String
- param :compute_attributes, Hash do
- end
- end
-
- def update
- process_response @host.update_attributes(host_params)
- end
-
- api :DELETE, "/hosts/:id/", "Delete an host."
- param :id, :identifier, :required => true
-
- def destroy
- process_response @host.destroy
- end
-
- api :GET, "/hosts/:id/status", "Get status of host"
- param :id, :identifier_dottable, :required => true
- # TRANSLATORS: API documentation - do not translate
- description <<-eos
-Return value may either be one of the following:
-
-* missing
-* failed
-* pending
-* changed
-* unchanged
-* unreported
-
- eos
-
- def status
- Foreman::Deprecation.api_deprecation_warning('The /status route is deprecated, please use the new /status/configuration instead')
- render :json => { :status => @host.get_status(HostStatus::ConfigurationStatus).to_label }.to_json if @host
- end
-
- private
-
- def resource_class
- Host::Managed
- end
-
- # this is required for template generation (such as pxelinux) which is not done via a web request
- def forward_request_url
- @host.request_url = request.host_with_port if @host.respond_to?(:request_url)
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/images_controller.rb b/app/controllers/api/v1/images_controller.rb
deleted file mode 100644
index dd174aaf327d..000000000000
--- a/app/controllers/api/v1/images_controller.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-module Api
- module V1
- class ImagesController < V1::BaseController
- include Foreman::Controller::Parameters::Image
-
- before_action :find_resource, :only => %w{show update destroy}
- before_action :find_compute_resource
-
- api :GET, "/compute_resources/:compute_resource_id/images/", "List all images for compute resource"
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
- param :compute_resource_id, :identifier, :required => true
-
- def index
- @images = @compute_resource.
- images.
- authorized(:view_images).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/compute_resources/:compute_resource_id/images/:id/", "Show an image"
- param :id, :identifier, :required => true
- param :compute_resource_id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/compute_resources/:compute_resource_id/images/", "Create a image"
- param :compute_resource_id, :identifier, :required => true
- param :image, Hash, :required => true do
- param :name, String, :required => true
- param :username, String, :required => true
- param :uuid, String, :required => true
- param :compute_resource_id, :number, :required => true
- param :architecture_id, :number, :required => true
- param :operatingsystem_id, :number, :required => true
- end
-
- def create
- @image = @compute_resource.images.new(image_params)
- process_response @image.save, @compute_resource
- end
-
- api :PUT, "/compute_resources/:compute_resource_id/images/:id/", "Update a image."
- param :compute_resource_id, :identifier, :required => true
- param :id, :identifier, :required => true
- param :image, Hash, :required => true do
- param :name, String
- param :username, String
- param :uuid, String
- param :compute_resource_id, :number
- param :architecture_id, :number
- param :operatingsystem_id, :number
- end
-
- def update
- process_response @image.update_attributes(image_params)
- end
-
- api :DELETE, "/compute_resources/:compute_resource_id/images/:id/", "Delete an image."
- param :compute_resource_id, :identifier, :required => true
- param :id, :identifier, :required => true
-
- def destroy
- process_response @image.destroy
- end
-
- private
-
- def find_compute_resource
- @compute_resource = ComputeResource.authorized(:view_compute_resources).find(params[:compute_resource_id])
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/lookup_keys_controller.rb b/app/controllers/api/v1/lookup_keys_controller.rb
deleted file mode 100644
index 01d8c1439d08..000000000000
--- a/app/controllers/api/v1/lookup_keys_controller.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-module Api
- module V1
- class LookupKeysController < V1::BaseController
- include Foreman::Controller::Parameters::PuppetclassLookupKey
- include Foreman::Controller::Parameters::VariableLookupKey
-
- before_action :find_resource, :only => %w{show update destroy}
- before_action :setup_search_options, :only => :index
-
- api :GET, "/lookup_keys/", "List all lookup_keys."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @lookup_keys = PuppetclassLookupKey.authorized(:view_external_parameters).
- search_for(*search_options).paginate(paginate_options).to_a +
- VariableLookupKey.authorized(:view_external_variables).
- search_for(*search_options).paginate(paginate_options).to_a
- end
-
- api :GET, "/lookup_keys/:id/", "Show a lookup key."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/lookup_keys/", "Create a lookup key."
- param :lookup_key, Hash, :required => true do
- param :key, String, :required => true
- param :puppetclass_id, :number
- param :default_value, String
- param :path, String
- param :description, String
- end
-
- def create
- @lookup_key = LookupKey.new(variable_lookup_key_params)
- process_response @lookup_key.save
- end
-
- api :PUT, "/lookup_keys/:id/", "Update a lookup key."
- param :id, :identifier, :required => true
- param :lookup_key, Hash, :required => true do
- param :key, String
- param :puppetclass_id, :number
- param :default_value, String
- param :path, String
- param :description, String
- end
-
- def update
- lk_params = @lookup_key.is_a?(PuppetclassLookupKey) ? puppetclass_lookup_key_params : variable_lookup_key_params
- process_response @lookup_key.update_attributes(lk_params)
- end
-
- api :DELETE, "/lookup_keys/:id/", "Delete a lookup key."
- param :id, :identifier, :required => true
-
- def destroy
- if @lookup_key.type == "PuppetclassLookupKey"
- render_message 'Smart class parameters cannot be destroyed',
- :status => :unprocessable_entity
- else
- process_response @lookup_key.destroy
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/media_controller.rb b/app/controllers/api/v1/media_controller.rb
deleted file mode 100644
index feb93b80cc4b..000000000000
--- a/app/controllers/api/v1/media_controller.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-module Api
- module V1
- class MediaController < V1::BaseController
- include Foreman::Controller::Parameters::Medium
-
- before_action :find_resource, :only => %w{show update destroy}
-
- # TRANSLATORS: API documentation - do not translate
- PATH_INFO = <<-eos
-The path to the medium, can be a URL or a valid NFS server (exclusive of the architecture).
-
-for example http://mirror.centos.org/centos/$version/os/$arch
-where $arch will be substituted for the host\'s actual OS architecture and $version, $major and $minor
-will be substituted for the version of the operating system.
-
-Solaris and Debian media may also use $release.
- eos
-
- # TRANSLATORS: API documentation - do not translate
- OS_FAMILY_INFO = <<-eos
-The family that the operating system belongs to.
-
-Available families:
-
-#{Operatingsystem.families.map { |f| '* ' + f }.join("\n")}
- eos
-
- api :GET, "/media/", "List all media."
- param :search, String, :desc => "filter results", :required => false
- param :order, String, :desc => "sort results", :required => false
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @media = Medium.
- authorized(:view_media).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/media/:id/", "Show a medium."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/media/", "Create a medium."
- param :medium, Hash, :required => true do
- param :name, String, :required => true, :desc => "Name of media"
- param :path, String, :required => true, :desc => PATH_INFO
- param :os_family, String, :require => false, :desc => OS_FAMILY_INFO
- param :operatingsystem_ids, Array, :require => false
- end
-
- def create
- @medium = Medium.new(medium_params)
- process_response @medium.save
- end
-
- param :id, String, :required => true
- param :medium, Hash, :required => true do
- param :name, String, :desc => "Name of media"
- param :path, String, :desc => PATH_INFO
- param :os_family, String, :allow_nil => true, :desc => OS_FAMILY_INFO
- param :operatingsystem_ids, Array, :require => false
- end
- api :PUT, "/media/:id/", "Update a medium."
-
- def update
- process_response @medium.update_attributes(medium_params)
- end
-
- param :id, :identifier, :required => true
- api :DELETE, "/media/:id/", "Delete a medium."
-
- def destroy
- process_response @medium.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/models_controller.rb b/app/controllers/api/v1/models_controller.rb
deleted file mode 100644
index 244364025592..000000000000
--- a/app/controllers/api/v1/models_controller.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-module Api
- module V1
- class ModelsController < V1::BaseController
- include Foreman::Controller::Parameters::Model
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/models/", "List all models."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @models = Model.
- authorized(:view_models).
- search_for(*search_options).
- paginate(paginate_options)
- end
-
- api :GET, "/models/:id/", "Show a model."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/models/", "Create a model."
- param :model, Hash, :required => true do
- param :name, String, :required => true
- param :info, String, :required => false
- param :vendor_class, String, :required => false
- param :hardware_model, String, :required => false
- end
-
- def create
- @model = Model.new(model_params)
- process_response @model.save
- end
-
- api :PUT, "/models/:id/", "Update a model."
- param :id, String, :required => true
- param :model, Hash, :required => true do
- param :name, String
- param :info, String
- param :vendor_class, String
- param :hardware_model, String
- end
-
- def update
- process_response @model.update_attributes(model_params)
- end
-
- api :DELETE, "/models/:id/", "Delete a model."
- param :id, String, :required => true
-
- def destroy
- process_response @model.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/operatingsystems_controller.rb b/app/controllers/api/v1/operatingsystems_controller.rb
deleted file mode 100644
index 07ed13b97d16..000000000000
--- a/app/controllers/api/v1/operatingsystems_controller.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-module Api
- module V1
- class OperatingsystemsController < V1::BaseController
- include Foreman::Controller::Parameters::Operatingsystem
-
- resource_description do
- name 'Operating systems'
- end
-
- before_action :rename_config_templates, :only => %w{update create}
- before_action :find_resource, :only => %w{show edit update destroy bootfiles}
-
- api :GET, "/operatingsystems/", "List all operating systems."
- param :search, String, :desc => "filter results", :required => false
- param :order, String, :desc => "sort results", :required => false
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @operatingsystems = Operatingsystem.
- authorized(:view_operatingsystems).
- includes(:media, :architectures, :ptables, :provisioning_templates, :os_default_templates).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/operatingsystems/:id/", "Show an OS."
- param :id, String, :required => true
-
- def show
- end
-
- api :POST, "/operatingsystems/", "Create an OS."
- param :operatingsystem, Hash, :required => true do
- param :name, /\A(\S+)\Z/, :required => true
- param :major, String, :required => true
- param :minor, String
- param :description, String
- param :family, String
- param :release_name, String
- param :password_hash, String, :desc => 'Root password hash function to use, one of MD5, SHA256, SHA512, Base64'
- param :config_template_ids, Array, :desc => "IDs of associated provisioning templates" # FIXME: deprecated
- param :provisioning_template_ids, Array, :desc => "IDs of associated provisioning templates"
- end
-
- def create
- @operatingsystem = Operatingsystem.new(operatingsystem_params)
- process_response @operatingsystem.save
- end
-
- api :PUT, "/operatingsystems/:id/", "Update an OS."
- param :id, String, :required => true
- param :operatingsystem, Hash, :required => true do
- param :name, /\A(\S+)\Z/
- param :major, String
- param :minor, String
- param :description, String
- param :family, String
- param :release_name, String
- param :password_hash, String, :desc => 'Root password hash function to use, one of MD5, SHA256, SHA512, Base64'
- param :config_template_ids, Array, :desc => "IDs of associated provisioning templates" # FIXME: deprecated
- param :provisioning_template_ids, Array, :desc => "IDs of associated provisioning templates"
- end
-
- def update
- process_response @operatingsystem.update_attributes(operatingsystem_params)
- end
-
- api :DELETE, "/operatingsystems/:id/", "Delete an OS."
- param :id, String, :required => true
-
- def destroy
- process_response @operatingsystem.destroy
- end
-
- api :GET, "/operatingsystems/:id/bootfiles/", "List boot files an OS."
- param :id, String, :required => true
- param :medium, String
- param :architecture, String
-
- def bootfiles
- medium = Medium.authorized(:view_media).find(params[:medium])
- arch = Architecture.authorized(:view_architectures).find(params[:architecture])
- render :json => @operatingsystem.pxe_files(medium, arch)
- rescue => e
- render :json => e.to_s, :status => :unprocessable_entity
- end
-
- private
-
- def rename_config_templates
- if params[:operatingsystem] && params[:operatingsystem][:config_template_ids].present?
- params[:operatingsystem][:provisioning_template_ids] = params[:operatingsystem].delete(:config_template_ids)
- Foreman::Deprecation.api_deprecation_warning('Config templates were renamed to provisioning templates')
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/ptables_controller.rb b/app/controllers/api/v1/ptables_controller.rb
deleted file mode 100644
index 7d1c40f854dc..000000000000
--- a/app/controllers/api/v1/ptables_controller.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-module Api
- module V1
- class PtablesController < V1::BaseController
- include Foreman::Controller::Parameters::Ptable
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/ptables/", "List all ptables."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @ptables = Ptable.
- authorized(:view_ptables).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/ptables/:id/", "Show a ptable."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/ptables/", "Create a ptable."
- param :ptable, Hash, :required => true do
- param :name, String, :required => true
- param :layout, String, :required => true
- param :os_family, String, :required => false
- end
-
- def create
- @ptable = Ptable.new(ptable_params)
- process_response @ptable.save
- end
-
- api :PUT, "/ptables/:id/", "Update a ptable."
- param :id, String, :required => true
- param :ptable, Hash, :required => true do
- param :name, String
- param :layout, String
- param :os_family, String
- end
-
- def update
- process_response @ptable.update_attributes(ptable_params)
- end
-
- api :DELETE, "/ptables/:id/", "Delete a ptable."
- param :id, String, :required => true
-
- def destroy
- process_response @ptable.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/puppetclasses_controller.rb b/app/controllers/api/v1/puppetclasses_controller.rb
deleted file mode 100644
index 6772262750b8..000000000000
--- a/app/controllers/api/v1/puppetclasses_controller.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-module Api
- module V1
- class PuppetclassesController < V1::BaseController
- include Foreman::Controller::Parameters::Puppetclass
-
- before_action :find_resource, :only => %w{show update destroy}
- before_action :setup_search_options, :only => :index
-
- api :GET, "/puppetclasses/", "List all puppetclasses."
- api :GET, "/hosts/:host_id/puppetclasses/", "List all puppetclasses of a given host."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- values = Puppetclass.
- authorized(:view_puppetclasses).
- search_for(*search_options).paginate(paginate_options).
- select([:name, :id]).
- includes(:lookup_keys)
- render :json => Puppetclass.classes2hash(values.all)
- end
-
- api :GET, "/puppetclasses/:id/", "Show a puppetclass."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/puppetclasses/", "Create a puppetclass."
- param :puppetclass, Hash, :required => true do
- param :name, String, :required => true
- end
-
- def create
- @puppetclass = Puppetclass.new(puppetclass_params)
- process_response @puppetclass.save
- end
-
- api :PUT, "/puppetclasses/:id/", "Update a puppetclass."
- param :id, String, :required => true
- param :puppetclass, Hash, :required => true do
- param :name, String
- end
-
- def update
- process_response @puppetclass.update_attributes(puppetclass_params)
- end
-
- api :DELETE, "/puppetclasses/:id/", "Delete a puppetclass."
- param :id, String, :required => true
-
- def destroy
- process_response @puppetclass.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/reports_controller.rb b/app/controllers/api/v1/reports_controller.rb
deleted file mode 100644
index ed9250ab5e57..000000000000
--- a/app/controllers/api/v1/reports_controller.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-module Api
- module V1
- class ReportsController < V1::BaseController
- before_action :deprecated
- before_action :find_resource, :only => %w{show destroy}
- before_action :setup_search_options, :only => [:index, :last]
-
- api :GET, "/reports/", "List all reports."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @reports = ConfigReport.
- authorized(:view_config_reports).
- my_reports.
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/reports/:id/", "Show a report."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :DELETE, "/reports/:id/", "Delete a report."
- param :id, String, :required => true
-
- def destroy
- process_response @report.destroy
- end
-
- api :GET, "/hosts/:host_id/reports/last", "Show the last report for a given host."
- param :id, :identifier, :required => true
-
- def last
- conditions = { :host_id => Host.authorized(:view_hosts).friendly.find(params[:host_id]).try(:id) } if params[:host_id].present?
- max_id = resource_scope.where(conditions).maximum(:id)
- @report = resource_scope.includes(:logs => [:message, :source]).find(max_id)
- render :show
- end
-
- private
-
- def deprecated
- Foreman::Deprecation.api_deprecation_warning("Reports were renamed to ConfigReports")
- end
-
- def resource_scope(options = {})
- options[:permission] = :view_config_reports
- super(options).my_reports
- end
-
- def resource_class
- ConfigReport
- end
-
- def action_permission
- case params[:action]
- when 'last'
- 'view'
- else
- super
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/roles_controller.rb b/app/controllers/api/v1/roles_controller.rb
deleted file mode 100644
index 97237f58f3dc..000000000000
--- a/app/controllers/api/v1/roles_controller.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-module Api
- module V1
- class RolesController < V1::BaseController
- include Foreman::Controller::Parameters::Role
-
- before_action :require_admin
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/roles/", "List all roles."
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- params[:order] ||= 'name'
- @roles = Role.authorized(:view_roles).search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/roles/:id/", "Show an role."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/roles/", "Create an role."
- param :role, Hash, :required => true do
- param :name, String, :required => true
- end
-
- def create
- @role = Role.new(role_params)
- process_response @role.save
- end
-
- api :PUT, "/roles/:id/", "Update an role."
- param :id, String, :required => true
- param :role, Hash, :required => true do
- param :name, String
- end
-
- def update
- process_response @role.update_attributes(role_params)
- end
-
- api :DELETE, "/roles/:id/", "Delete an role."
- param :id, String, :required => true
-
- def destroy
- process_response @role.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/settings_controller.rb b/app/controllers/api/v1/settings_controller.rb
deleted file mode 100644
index ba9500319a45..000000000000
--- a/app/controllers/api/v1/settings_controller.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Api
- module V1
- class SettingsController < V1::BaseController
- before_action :require_admin
- before_action :find_resource, :only => %w{show update}
-
- api :GET, "/settings/", "List all settings."
- param :search, String, :desc => "Filter results"
- param :order, String, :desc => "Sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @settings = Setting.live_descendants.search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/settings/:id/", "Show an setting."
- param :id, String, :required => true
-
- def show
- end
-
- api :PUT, "/settings/:id/", "Update a setting."
- param :id, String, :required => true
- param :setting, Hash, :required => true do
- param :value, String
- end
-
- def update
- process_response (@setting.parse_string_value(params[:setting][:value]) && @setting.save)
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/smart_proxies_controller.rb b/app/controllers/api/v1/smart_proxies_controller.rb
deleted file mode 100644
index b6e8a49dea3a..000000000000
--- a/app/controllers/api/v1/smart_proxies_controller.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-module Api
- module V1
- class SmartProxiesController < V1::BaseController
- include Api::ImportPuppetclassesCommonController
- include Foreman::Controller::Parameters::SmartProxy
-
- before_action :find_resource, :only => %w{show update destroy refresh}
- before_action :check_feature_type, :only => :index
-
- api :GET, "/smart_proxies/", "List all smart_proxies."
- param :type, String, :desc => "filter by type"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @smart_proxies = proxies_by_type(params[:type]).paginate(paginate_options)
- end
-
- api :GET, "/smart_proxies/:id/", "Show a smart proxy."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/smart_proxies/", "Create a smart proxy."
- param :smart_proxy, Hash, :required => true do
- param :name, String, :required => true
- param :url, String, :required => true
- end
-
- def create
- @smart_proxy = SmartProxy.new(smart_proxy_params)
- process_response @smart_proxy.save
- end
-
- api :PUT, "/smart_proxies/:id/", "Update a smart proxy."
- param :id, String, :required => true
- param :smart_proxy, Hash, :required => true do
- param :name, String
- param :url, String
- end
-
- def update
- process_response @smart_proxy.update_attributes(smart_proxy_params)
- end
-
- api :DELETE, "/smart_proxies/:id/", "Delete a smart_proxy."
- param :id, String, :required => true
-
- def destroy
- process_response @smart_proxy.destroy
- end
-
- api :PUT, "/smart_proxies/:id/refresh", "Refresh smart proxy features"
- param :id, String, :required => true
-
- def refresh
- process_response @smart_proxy.refresh.blank? && @smart_proxy.save
- end
-
- private
-
- def action_permission
- case params[:action]
- when 'refresh'
- :edit
- else
- super
- end
- end
-
- def proxies_by_type(type)
- return SmartProxy.authorized(:view_smart_proxies).includes(:features).with_features(type) if type.present?
- SmartProxy.authorized(:view_smart_proxies).includes(:features).all
- end
-
- def check_feature_type
- return if params[:type].nil?
-
- allowed_types = Feature.name_map.keys
-
- if !allowed_types.include? params[:type].downcase
- raise ArgumentError, "Invalid feature type. Select one of: #{allowed_types.join(', ')}."
- end
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/statistics_controller.rb b/app/controllers/api/v1/statistics_controller.rb
deleted file mode 100644
index fb128fd599fc..000000000000
--- a/app/controllers/api/v1/statistics_controller.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-module Api
- module V1
- class StatisticsController < V1::BaseController
- api :GET, "/statistics/", "Get statistics"
-
- def index
- @os_count = Host.authorized(:view_hosts).count_distribution :operatingsystem
- @arch_count = Host.authorized(:view_hosts).count_distribution :architecture
- @env_count = Host.authorized(:view_hosts).count_distribution :environment
- @klass_count = Host.authorized(:view_hosts).count_habtm "puppetclass"
- @cpu_count = FactValue.authorized(:view_facts).my_facts.count_each "processorcount"
- @model_count = FactValue.authorized(:view_facts).my_facts.count_each "manufacturer"
- @mem_size = FactValue.authorized(:view_facts).my_facts.mem_average "memorysize"
- @mem_free = FactValue.authorized(:view_facts).my_facts.mem_average "memoryfree"
- @swap_size = FactValue.authorized(:view_facts).my_facts.mem_average "swapsize"
- @swap_free = FactValue.authorized(:view_facts).my_facts.mem_average "swapfree"
- @mem_totsize = FactValue.authorized(:view_facts).my_facts.mem_sum "memorysize"
- @mem_totfree = FactValue.authorized(:view_facts).my_facts.mem_sum "memoryfree"
- render :json => { :os_count => @os_count, :arch_count => @arch_count, :swap_size => @swap_size,
- :env_count => @env_count, :klass_count => @klass_count, :cpu_count => @cpu_count,
- :model_count => @model_count, :mem_size => @mem_size, :mem_free => @mem_free,
- :swap_free => @swap_free, :mem_totsize => @mem_totsize, :mem_totfree => @mem_totfree }
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/subnets_controller.rb b/app/controllers/api/v1/subnets_controller.rb
deleted file mode 100644
index 844cac41494b..000000000000
--- a/app/controllers/api/v1/subnets_controller.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-module Api
- module V1
- class SubnetsController < V1::BaseController
- include Foreman::Controller::Parameters::Subnet
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, '/subnets', 'List of subnets'
- param :search, String, :desc => 'Filter results'
- param :order, String, :desc => 'Sort results'
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @subnets = Subnet.
- authorized(:view_subnets).
- includes(:tftp, :dhcp, :dns).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/subnets/:id/", "Show a subnet."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, '/subnets', 'Create a subnet'
- param :subnet, Hash, :required => true do
- param :name, String, :desc => 'Subnet name', :required => true
- param :network_type, Subnet::SUBNET_TYPES.values, :desc => 'Type or protocol, IPv4 or IPv6, defaults to IPv4'
- param :network, String, :desc => 'Subnet network', :required => true
- param :mask, String, :desc => 'Netmask for this subnet', :required => true
- param :gateway, String, :desc => 'Primary DNS for this subnet'
- param :dns_primary, String, :desc => 'Primary DNS for this subnet'
- param :dns_secondary, String, :desc => 'Secondary DNS for this subnet'
- param :ipam, :bool, :desc => 'Enable IP Address auto suggestion for this subnet'
- param :from, String, :desc => 'Starting IP Address for IP auto suggestion'
- param :to, String, :desc => 'Ending IP Address for IP auto suggestion'
- param :vlanid, String, :desc => 'VLAN ID for this subnet'
- param :domain_ids, Array, :desc => 'Domains in which this subnet is part'
- param :dhcp_id, :number, :desc => 'DHCP Proxy to use within this subnet'
- param :tftp_id, :number, :desc => 'TFTP Proxy to use within this subnet'
- param :dns_id, :number, :desc => 'DNS Proxy to use within this subnet'
- end
-
- def create
- @subnet = Subnet.new_network_type(subnet_params)
- process_response @subnet.save
- end
-
- api :PUT, '/subnets/:id', 'Update a subnet'
- param :id, :number, :desc => 'Subnet numeric identifier', :required => true
- param :subnet, Hash, :required => true do
- param :name, String, :desc => 'Subnet name'
- param :network, String, :desc => 'Subnet network'
- param :mask, String, :desc => 'Netmask for this subnet'
- param :gateway, String, :allow_nil => true, :desc => 'Primary DNS for this subnet'
- param :dns_primary, String, :allow_nil => true, :desc => 'Primary DNS for this subnet'
- param :dns_secondary, String, :allow_nil => true, :desc => 'Secondary DNS for this subnet'
- param :from, String, :allow_nil => true, :desc => 'Starting IP Address for IP auto suggestion'
- param :to, String, :allow_nil => true, :desc => ' Ending IP Address for IP auto suggestion'
- param :vlanid, String, :allow_nil => true, :desc => 'VLAN ID for this subnet'
- param :domain_ids, Array, :allow_nil => true, :desc => 'Domains in which this subnet is part'
- param :dhcp_id, :number, :allow_nil => true, :desc => 'DHCP Proxy to use within this subnet'
- param :tftp_id, :number, :allow_nil => true, :desc => 'TFTP Proxy to use within this subnet'
- param :dns_id, :number, :allow_nil => true, :desc => 'DNS Proxy to use within this subnet'
- end
-
- def update
- process_response @subnet.update_attributes(subnet_params)
- end
-
- api :DELETE, '/subnets/:id', 'Delete a subnet'
- param :id, :number, :desc => 'Subnet numeric identifier', :required => true
-
- def destroy
- process_response @subnet.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/template_kinds_controller.rb b/app/controllers/api/v1/template_kinds_controller.rb
deleted file mode 100644
index 0f95fa7ce134..000000000000
--- a/app/controllers/api/v1/template_kinds_controller.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Api
- module V1
- class TemplateKindsController < V1::BaseController
- api :GET, "/template_kinds/", "List all template kinds."
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @template_kinds = TemplateKind.paginate(paginate_options)
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/usergroups_controller.rb b/app/controllers/api/v1/usergroups_controller.rb
deleted file mode 100644
index 6cc4e3f32c91..000000000000
--- a/app/controllers/api/v1/usergroups_controller.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-module Api
- module V1
- class UsergroupsController < V1::BaseController
- include Foreman::Controller::Parameters::Usergroup
-
- before_action :find_resource, :only => %w{show update destroy}
-
- api :GET, "/usergroups/", "List all user groups."
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
-
- def index
- @usergroups = Usergroup.
- authorized(:view_usergroups).
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/usergroups/:id/", "Show a user group."
- param :id, :identifier, :required => true
-
- def show
- end
-
- api :POST, "/usergroups/", "Create a user group."
- param :usergroup, Hash, :required => true do
- param :name, String, :required => true
- end
-
- def create
- @usergroup = Usergroup.new(usergroup_params)
- process_response @usergroup.save
- end
-
- api :PUT, "/usergroups/:id/", "Update a user group."
- param :id, String, :required => true
- param :usergroup, Hash, :required => true do
- param :name, String
- end
-
- def update
- process_response @usergroup.update_attributes(usergroup_params)
- end
-
- api :DELETE, "/usergroups/:id/", "Delete a user group."
- param :id, String, :required => true
-
- def destroy
- process_response @usergroup.destroy
- end
- end
- end
-end
diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb
deleted file mode 100644
index eb714a834fd3..000000000000
--- a/app/controllers/api/v1/users_controller.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-module Api
- module V1
- class UsersController < V1::BaseController
- before_action :find_resource, :only => %w{show update destroy}
- # find_resource needs to be defined prior to UsersMixin is included, it depends on @user
- include Foreman::Controller::UsersMixin
- include Foreman::Controller::Parameters::User
-
- api :GET, "/users/", "List all users."
- param :search, String, :desc => "filter results"
- param :order, String, :desc => "sort results"
- param :page, String, :desc => "paginate results"
- param :per_page, String, :desc => "number of entries per request"
-
- def index
- @users = User.
- authorized(:view_users).except_hidden.
- search_for(*search_options).paginate(paginate_options)
- end
-
- api :GET, "/users/:id/", "Show an user."
- param :id, String, :required => true
-
- def show
- end
-
- api :POST, "/users/", "Create an user."
- # TRANSLATORS: API documentation - do not translate
- description <<-DOC
- Adds role 'Default role' to the user by default
- DOC
- param :user, Hash, :required => true do
- param :login, String, :required => true
- param :firstname, String, :required => false
- param :lastname, String, :required => false
- param :mail, String, :required => true
- param :admin, :bool, :required => false, :desc => "Is an admin account?"
- param :password, String, :required => true
- param :auth_source_id, Integer, :required => true
- end
-
- def create
- @user = User.new(user_params)
- if @user.save
- process_success
- else
- process_resource_error
- end
- end
-
- api :PUT, "/users/:id/", "Update an user."
- # TRANSLATORS: API documentation - do not translate
- description <<-DOC
- Adds role 'Default role' to the user if it is not already present.
- Only admin can set admin account.
- DOC
- param :id, String, :required => true
- param :user, Hash, :required => true do
- param :login, String
- param :firstname, String, :allow_nil => true
- param :lastname, String, :allow_nil => true
- param :mail, String
- param :admin, :bool, :desc => "Is an admin account?"
- param :password, String
- end
-
- def update
- if @user.update_attributes(user_params)
- update_sub_hostgroups_owners
-
- process_success
- else
- process_resource_error
- end
- end
-
- api :DELETE, "/users/:id/", "Delete an user."
- param :id, String, :required => true
-
- def destroy
- if @user == User.current
- deny_access "You are trying to delete your own account"
- else
- process_response @user.destroy
- end
- end
-
- private
-
- def find_resource
- editing_self? ? @user = User.find(User.current.id) : super
- end
-
- def parameter_filter_context
- Foreman::Controller::Parameters::User::Context.new(:api, controller_name, params[:action], editing_self?)
- end
- end
- end
-end
diff --git a/app/controllers/concerns/api/version1.rb b/app/controllers/concerns/api/version1.rb
deleted file mode 100644
index 24cd733c5f70..000000000000
--- a/app/controllers/concerns/api/version1.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Api
- module Version1
- extend ActiveSupport::Concern
-
- def api_version
- '1'
- end
- end
-end
diff --git a/app/registries/foreman/access_permissions.rb b/app/registries/foreman/access_permissions.rb
index b98340dc4efd..1762a0d15f19 100644
--- a/app/registries/foreman/access_permissions.rb
+++ b/app/registries/foreman/access_permissions.rb
@@ -6,45 +6,37 @@
map.permission :user_logout, { :users => [:logout] }, :public => true
map.permission :my_account, { :users => [:edit],
:notification_recipients => [:index, :update, :destroy, :update_group_as_read] }, :public => true
- map.permission :api_status, { :"api/v1/home" => [:status], :"api/v2/home" => [:status]}, :public => true
+ map.permission :api_status, { :"api/v2/home" => [:status]}, :public => true
map.permission :about_index, { :about => [:index] }, :public => true
end
permission_set.security_block :architectures do |map|
map.permission :view_architectures,
:architectures => [:index, :show, :auto_complete_search, :welcome],
- :"api/v1/architectures" => [:index, :show],
:"api/v2/architectures" => [:index, :show]
map.permission :create_architectures,
:architectures => [:new, :create],
- :"api/v1/architectures" => [:create],
:"api/v2/architectures" => [:create]
map.permission :edit_architectures,
:architectures => [:edit, :update],
- :"api/v1/architectures" => [:update],
:"api/v2/architectures" => [:update]
map.permission :destroy_architectures,
:architectures => [:destroy],
- :"api/v1/architectures" => [:destroy],
:"api/v2/architectures" => [:destroy]
end
permission_set.security_block :authentication_providers do |map|
ajax_actions = [:test_connection]
map.permission :view_authenticators, {:auth_source_ldaps => [:index, :show],
- :"api/v1/auth_source_ldaps" => [:index, :show],
:"api/v2/auth_source_ldaps" => [:index, :show]
}
map.permission :create_authenticators, {:auth_source_ldaps => [:new, :create].push(*ajax_actions),
- :"api/v1/auth_source_ldaps" => [:create],
:"api/v2/auth_source_ldaps" => [:create]
}
map.permission :edit_authenticators, {:auth_source_ldaps => [:edit, :update].push(*ajax_actions),
- :"api/v1/auth_source_ldaps" => [:update],
:"api/v2/auth_source_ldaps" => [:update, :test]
}
map.permission :destroy_authenticators, {:auth_source_ldaps => [:destroy],
- :"api/v1/auth_source_ldaps" => [:destroy],
:"api/v2/auth_source_ldaps" => [:destroy]
}
end
@@ -52,19 +44,15 @@
permission_set.security_block :bookmarks do |map|
map.permission :view_bookmarks,
:bookmarks => [:index, :show, :auto_complete_search],
- :"api/v1/bookmarks" => [:index, :show],
:"api/v2/bookmarks" => [:index, :show]
map.permission :create_bookmarks,
:bookmarks => [:new, :create],
- :"api/v1/bookmarks" => [:new, :create],
:"api/v2/bookmarks" => [:new, :create]
map.permission :edit_bookmarks,
:bookmarks => [:edit, :update],
- :"api/v1/bookmarks" => [:edit, :update],
:"api/v2/bookmarks" => [:edit, :update]
map.permission :destroy_bookmarks,
:bookmarks => [:destroy],
- :"api/v1/bookmarks" => [:destroy],
:"api/v2/bookmarks" => [:destroy]
end
@@ -82,24 +70,20 @@
permission_set.security_block :compute_resources do |map|
ajax_actions = [:test_connection]
map.permission :view_compute_resources, {:compute_resources => [:index, :show, :auto_complete_search, :ping, :available_images, :refresh_cache],
- :"api/v1/compute_resources" => [:index, :show],
:"api/v2/compute_resources" => [:index, :show, :available_images, :available_clusters, :available_folders,
:available_flavors, :available_networks, :available_resource_pools,
:available_security_groups, :available_storage_domains, :available_zones,
:available_storage_pods, :refresh_cache]
}
map.permission :create_compute_resources, {:compute_resources => [:new, :create].push(*ajax_actions),
- :"api/v1/compute_resources" => [:create],
:"api/v2/compute_resources" => [:create]
}
map.permission :edit_compute_resources, {:compute_resources => [:edit, :update].push(*ajax_actions),
:compute_attributes => [:new, :create, :edit, :update],
- :"api/v1/compute_resources" => [:update],
:"api/v2/compute_resources" => [:update],
:"api/v2/compute_attributes" => [:create, :update]
}
map.permission :destroy_compute_resources, {:compute_resources => [:destroy],
- :"api/v1/compute_resources" => [:destroy],
:"api/v2/compute_resources" => [:destroy]
}
end
@@ -115,33 +99,27 @@
permission_set.security_block :provisioning_templates do |map|
map.permission :view_provisioning_templates, {:provisioning_templates => [:index, :show, :revision, :auto_complete_search, :preview, :export],
- :"api/v1/config_templates" => [:index, :show, :revision],
:"api/v2/config_templates" => [:index, :show, :revision],
:"api/v2/provisioning_templates" => [:index, :show, :revision, :export],
:"api/v2/template_combinations" => [:index, :show],
- :"api/v1/template_kinds" => [:index],
:"api/v2/template_kinds" => [:index]
}
map.permission :create_provisioning_templates, {:provisioning_templates => [:new, :create, :clone_template],
- :"api/v1/config_templates" => [:create],
:"api/v2/config_templates" => [:create, :clone],
:"api/v2/provisioning_templates" => [:create, :clone],
:"api/v2/template_combinations" => [:create]
}
map.permission :edit_provisioning_templates, {:provisioning_templates => [:edit, :update],
- :"api/v1/config_templates" => [:update],
:"api/v2/config_templates" => [:update],
:"api/v2/provisioning_templates" => [:update],
:"api/v2/template_combinations" => [:update]
}
map.permission :destroy_provisioning_templates, {:provisioning_templates => [:destroy],
- :"api/v1/config_templates" => [:destroy],
:"api/v2/config_templates" => [:destroy],
:"api/v2/provisioning_templates" => [:destroy],
:"api/v2/template_combinations" => [:destroy]
}
map.permission :deploy_provisioning_templates, {:provisioning_templates => [:build_pxe_default],
- :"api/v1/config_templates" => [:build_pxe_default],
:"api/v2/config_templates" => [:build_pxe_default],
:"api/v2/provisioning_templates" => [:build_pxe_default]
}
@@ -184,44 +162,34 @@
permission_set.security_block :domains do |map|
map.permission :view_domains, {:domains => [:index, :show, :auto_complete_search, :welcome],
- :"api/v1/domains" => [:index, :show],
:"api/v2/domains" => [:index, :show]
}
map.permission :create_domains, {:domains => [:new, :create],
- :"api/v1/domains" => [:create],
:"api/v2/domains" => [:create]
}
map.permission :edit_domains, {:domains => [:edit, :update],
- :"api/v1/domains" => [:update],
:"api/v2/domains" => [:update]
}
map.permission :destroy_domains, {:domains => [:destroy],
- :"api/v1/domains" => [:destroy],
:"api/v2/domains" => [:destroy]
}
end
permission_set.security_block :environments do |map|
map.permission :view_environments, {:environments => [:index, :show, :auto_complete_search, :welcome],
- :"api/v1/environments" => [:index, :show],
:"api/v2/environments" => [:index, :show]
}
map.permission :create_environments, {:environments => [:new, :create],
- :"api/v1/environments" => [:create],
:"api/v2/environments" => [:create]
}
map.permission :edit_environments, {:environments => [:edit, :update],
- :"api/v1/environments" => [:update],
:"api/v2/environments" => [:update]
}
map.permission :destroy_environments, {:environments => [:destroy],
- :"api/v1/environments" => [:destroy],
:"api/v2/environments" => [:destroy]
}
map.permission :import_environments, {:environments => [:import_environments, :obsolete_and_new],
- :"api/v1/environments" => [:import_puppetclasses],
:"api/v2/environments" => [:import_puppetclasses],
- :"api/v1/smart_proxies" => [:import_puppetclasses],
:"api/v2/smart_proxies" => [:import_puppetclasses]
}
end
@@ -230,49 +198,41 @@
map.permission :view_external_variables, {:lookup_keys => [:index, :show, :auto_complete_search],
:variable_lookup_keys => [:index, :show, :auto_complete_search],
:lookup_values => [:index],
- :"api/v1/lookup_keys" => [:index, :show],
:"api/v2/smart_variables" => [:index, :show],
:"api/v2/override_values" => [:index, :show]}
map.permission :create_external_variables, {:lookup_keys => [:new, :create],
:variable_lookup_keys => [:new, :create],
:lookup_values => [:create],
- :"api/v1/lookup_keys" => [:create],
:"api/v2/smart_variables" => [:create],
:"api/v2/override_values" => [:create]}
map.permission :edit_external_variables, {:lookup_keys => [:edit, :update],
:variable_lookup_keys => [:edit, :update],
:lookup_values => [:create, :update, :destroy],
- :"api/v1/lookup_keys" => [:update],
:"api/v2/smart_variables" => [:update],
:"api/v2/override_values" => [:create, :update, :destroy]}
map.permission :destroy_external_variables, {:lookup_keys => [:destroy],
:variable_lookup_keys => [:destroy],
:lookup_values => [:destroy],
- :"api/v1/lookup_keys" => [:destroy],
:"api/v2/smart_variables" => [:destroy],
:"api/v2/override_values" => [:create, :update, :destroy]}
map.permission :view_external_parameters, {:lookup_keys => [:index, :show, :auto_complete_search],
:puppetclass_lookup_keys => [:index, :show, :auto_complete_search],
:lookup_values => [:index],
- :"api/v1/lookup_keys" => [:index, :show],
:"api/v2/smart_class_parameters" => [:index, :show],
:"api/v2/override_values" => [:index, :show]}
map.permission :create_external_parameters, {:lookup_keys => [:new, :create],
:puppetclass_lookup_keys => [:new, :create],
:lookup_values => [:create],
- :"api/v1/lookup_keys" => [:create],
:"api/v2/smart_class_parameters" => [:create],
:"api/v2/override_values" => [:create]}
map.permission :edit_external_parameters, {:lookup_keys => [:edit, :update],
:puppetclass_lookup_keys => [:edit, :update],
:lookup_values => [:create, :update, :destroy],
- :"api/v1/lookup_keys" => [:update],
:"api/v2/smart_class_parameters" => [:update],
:"api/v2/override_values" => [:create, :update, :destroy]}
map.permission :destroy_external_parameters, {:lookup_keys => [:destroy],
:puppetclass_lookup_keys => [:destroy],
:lookup_values => [:destroy],
- :"api/v1/lookup_keys" => [:destroy],
:"api/v2/smart_class_parameters" => [:destroy],
:"api/v2/override_values" => [:create, :update, :destroy]}
end
@@ -296,24 +256,20 @@
pc_ajax_actions = [:parameters]
map.permission :view_hostgroups, {:hostgroups => [:index, :show, :auto_complete_search],
- :"api/v1/hostgroups" => [:index, :show],
:"api/v2/hostgroups" => [:index, :show]
}
map.permission :create_hostgroups, {:hostgroups => [:new, :create, :clone, :nest, :process_hostgroup].push(*ajax_actions),
:host => host_ajax_actions,
:puppetclasses => pc_ajax_actions,
- :"api/v1/hostgroups" => [:create, :clone],
:"api/v2/hostgroups" => [:create, :clone]
}
map.permission :edit_hostgroups, {:hostgroups => [:edit, :update, :architecture_selected, :process_hostgroup].push(*ajax_actions),
:host => host_ajax_actions,
:puppetclasses => pc_ajax_actions,
- :"api/v1/hostgroups" => [:update],
:"api/v2/hostgroups" => [:update, :rebuild_config],
:"api/v2/hostgroup_classes" => [:index, :create, :destroy]
}
map.permission :destroy_hostgroups, {:hostgroups => [:destroy],
- :"api/v1/hostgroups" => [:destroy],
:"api/v2/hostgroups" => [:destroy]
}
end
@@ -348,7 +304,6 @@
:runtime, :resources, :templates, :overview, :nics, :get_power_state, :preview_host_collection],
:dashboard => [:OutOfSync, :errors, :active],
:unattended => [:host_template, :hostgroup_template],
- :"api/v1/hosts" => [:index, :show, :status],
:"api/v2/hosts" => [:index, :show, :status, :get_status, :vm_compute_attributes, :template, :enc],
:"api/v2/interfaces" => [:index, :show],
:locations => [:mismatches],
@@ -360,7 +315,6 @@
:puppetclasses => pc_ajax_actions,
:subnets => subnets_ajax_actions,
:interfaces => [:new, :random_name],
- :"api/v1/hosts" => [:create],
:"api/v2/hosts" => [:create],
:"api/v2/interfaces" => [:create],
:"api/v2/tasks" => [:index]
@@ -381,13 +335,11 @@
:puppetclasses => pc_ajax_actions,
:subnets => subnets_ajax_actions,
:interfaces => [:new, :random_name],
- :"api/v1/hosts" => [:update],
:"api/v2/hosts" => [:update, :disassociate],
:"api/v2/interfaces" => [:create, :update, :destroy],
:"api/v2/compute_resources" => [:associate]
}
map.permission :destroy_hosts, {:hosts => [:destroy, :multiple_actions, :reset_multiple, :multiple_destroy, :submit_multiple_destroy],
- :"api/v1/hosts" => [:destroy],
:"api/v2/hosts" => [:destroy],
:"api/v2/interfaces" => [:destroy]
}
@@ -413,25 +365,21 @@
map.permission :view_params, { :host_editing => [:view_params],
:parameters => [:index, :auto_complete_search],
:common_parameters => [:index, :show, :auto_complete_search],
- :"api/v1/common_parameters" => [:index, :show],
:"api/v2/common_parameters" => [:index, :show],
:"api/v2/parameters" => [:index, :show]
}
map.permission :create_params, { :host_editing => [:create_params],
:common_parameters => [:new, :create],
- :"api/v1/common_parameters" => [:create],
:"api/v2/common_parameters" => [:create],
:"api/v2/parameters" => [:create]
}
map.permission :edit_params, { :host_editing => [:edit_params],
:common_parameters => [:edit, :update],
- :"api/v1/common_parameters" => [:update],
:"api/v2/common_parameters" => [:update],
:"api/v2/parameters" => [:update]
}
map.permission :destroy_params, { :host_editing => [:destroy_params],
:common_parameters => [:destroy],
- :"api/v1/common_parameters" => [:destroy],
:"api/v2/common_parameters" => [:destroy],
:"api/v2/parameters" => [:destroy, :reset]
}
@@ -439,19 +387,15 @@
permission_set.security_block :images do |map|
map.permission :view_images, {:images => [:index, :show, :auto_complete_search],
- :"api/v1/images" => [:index, :show],
:"api/v2/images" => [:index, :show]
}
map.permission :create_images, {:images => [:new, :create],
- :"api/v1/images" => [:create],
:"api/v2/images" => [:create]
}
map.permission :edit_images, {:images => [:edit, :update],
- :"api/v1/images" => [:update],
:"api/v2/images" => [:update]
}
map.permission :destroy_images, {:images => [:destroy],
- :"api/v1/images" => [:destroy],
:"api/v2/images" => [:destroy]
}
end
@@ -464,19 +408,15 @@
if SETTINGS[:locations_enabled]
permission_set.security_block :locations do |map|
map.permission :view_locations, {:locations => [:index, :show, :auto_complete_search],
- :"api/v1/locations" => [:index, :show],
:"api/v2/locations" => [:index, :show]
}
map.permission :create_locations, {:locations => [:new, :create, :clone_taxonomy, :step2, :nest],
- :"api/v1/locations" => [:create],
:"api/v2/locations" => [:create]
}
map.permission :edit_locations, {:locations => [:edit, :update, :import_mismatches, :parent_taxonomy_selected],
- :"api/v1/locations" => [:update],
:"api/v2/locations" => [:update]
}
map.permission :destroy_locations, {:locations => [:destroy],
- :"api/v1/locations" => [:destroy],
:"api/v2/locations" => [:destroy]
}
map.permission :assign_locations, {:locations => [:assign_all_hosts, :assign_hosts, :assign_selected_hosts]}
@@ -490,60 +430,48 @@
permission_set.security_block :media do |map|
map.permission :view_media, {:media => [:index, :show, :auto_complete_search, :welcome],
- :"api/v1/media" => [:index, :show],
:"api/v2/media" => [:index, :show]
}
map.permission :create_media, {:media => [:new, :create],
- :"api/v1/media" => [:create],
:"api/v2/media" => [:create]
}
map.permission :edit_media, {:media => [:edit, :update],
- :"api/v1/media" => [:update],
:"api/v2/media" => [:update]
}
map.permission :destroy_media, {:media => [:destroy],
- :"api/v1/media" => [:destroy],
:"api/v2/media" => [:destroy]
}
end
permission_set.security_block :models do |map|
map.permission :view_models, {:models => [:index, :show, :auto_complete_search],
- :"api/v1/models" => [:index, :show],
:"api/v2/models" => [:index, :show]
}
map.permission :create_models, {:models => [:new, :create],
- :"api/v1/models" => [:create],
:"api/v2/models" => [:create]
}
map.permission :edit_models, {:models => [:edit, :update],
- :"api/v1/models" => [:update],
:"api/v2/models" => [:update]
}
map.permission :destroy_models, {:models => [:destroy],
- :"api/v1/models" => [:destroy],
:"api/v2/models" => [:destroy]
}
end
permission_set.security_block :operatingsystems do |map|
map.permission :view_operatingsystems, { :operatingsystems => [:index, :show, :bootfiles, :auto_complete_search],
- :"api/v1/operatingsystems" => [:index, :show, :bootfiles],
:"api/v2/operatingsystems" => [:index, :show, :bootfiles],
:"api/v2/os_default_templates" => [:index, :show]
}
map.permission :create_operatingsystems, {:operatingsystems => [:new, :create],
- :"api/v1/operatingsystems" => [:create],
:"api/v2/operatingsystems" => [:create],
:"api/v2/os_default_templates" => [:create]
}
map.permission :edit_operatingsystems, {:operatingsystems => [:edit, :update],
- :"api/v1/operatingsystems" => [:update],
:"api/v2/operatingsystems" => [:update],
:"api/v2/os_default_templates" => [:create, :update, :destroy]
}
map.permission :destroy_operatingsystems, {:operatingsystems => [:destroy],
- :"api/v1/operatingsystems" => [:destroy],
:"api/v2/operatingsystems" => [:destroy],
:"api/v2/os_default_templates" => [:create]
}
@@ -551,19 +479,15 @@
permission_set.security_block :partition_tables do |map|
map.permission :view_ptables, {:ptables => [:index, :show, :auto_complete_search, :revision, :preview, :welcome, :export],
- :"api/v1/ptables" => [:index, :show],
:"api/v2/ptables" => [:index, :show, :revision, :export]
}
map.permission :create_ptables, {:ptables => [:new, :create, :clone_template],
- :"api/v1/ptables" => [:create],
:"api/v2/ptables" => [:create, :clone]
}
map.permission :edit_ptables, {:ptables => [:edit, :update],
- :"api/v1/ptables" => [:update],
:"api/v2/ptables" => [:update]
}
map.permission :destroy_ptables, {:ptables => [:destroy],
- :"api/v1/ptables" => [:destroy],
:"api/v2/ptables" => [:destroy]
}
map.permission :lock_ptables, {:ptables => [:lock, :unlock],
@@ -573,31 +497,23 @@
permission_set.security_block :puppetclasses do |map|
map.permission :view_puppetclasses, {:puppetclasses => [:index, :show, :auto_complete_search],
- :"api/v1/puppetclasses" => [:index, :show],
:"api/v2/puppetclasses" => [:index, :show],
- :"api/v1/lookup_keys" => [:index, :show],
:"api/v2/smart_variables" => [:index, :show],
:"api/v2/smart_class_parameters" => [:index, :show]
}
map.permission :create_puppetclasses, {:puppetclasses => [:new, :create],
- :"api/v1/puppetclasses" => [:create],
:"api/v2/puppetclasses" => [:create]
}
map.permission :edit_puppetclasses, {:puppetclasses => [:edit, :update, :override ],
- :"api/v1/puppetclasses" => [:update],
:"api/v2/puppetclasses" => [:update],
- :"api/v1/lookup_keys" => [:create, :update, :destroy],
:"api/v2/smart_variables" => [:create, :update, :destroy],
:"api/v2/smart_class_parameters" => [:create, :update, :destroy]
}
map.permission :destroy_puppetclasses, {:puppetclasses => [:destroy],
- :"api/v1/puppetclasses" => [:destroy],
:"api/v2/puppetclasses" => [:destroy]
}
map.permission :import_puppetclasses, {:puppetclasses => [:import_environments, :obsolete_and_new],
- :"api/v1/environments" => [:import_puppetclasses],
:"api/v2/environments" => [:import_puppetclasses],
- :"api/v1/smart_proxies" => [:import_puppetclasses],
:"api/v2/smart_proxies" => [:import_puppetclasses]
}
end
@@ -618,26 +534,21 @@
:show, :plugin_version, :tftp_server, :puppet_environments,
:puppet_dashboard, :log_pane, :failed_modules, :errors_card,
:modules_card],
- :"api/v1/smart_proxies" => [:index, :show],
:"api/v2/smart_proxies" => [:index, :show, :version, :logs]
}
map.permission :create_smart_proxies, {:smart_proxies => [:new, :create],
- :"api/v1/smart_proxies" => [:create],
:"api/v2/smart_proxies" => [:create]
}
map.permission :edit_smart_proxies, {:smart_proxies => [:edit, :update, :refresh, :expire_logs],
- :"api/v1/smart_proxies" => [:update, :refresh],
:"api/v2/smart_proxies" => [:update, :refresh]
}
map.permission :destroy_smart_proxies, {:smart_proxies => [:destroy],
- :"api/v1/smart_proxies" => [:destroy],
:"api/v2/smart_proxies" => [:destroy]
}
end
permission_set.security_block :smart_proxies_autosign do |map|
map.permission :view_smart_proxies_autosign, {:autosign => [:index, :show, :counts],
- :"api/v1/autosign" => [:index],
:"api/v2/autosign" => [:index]
}
map.permission :create_smart_proxies_autosign, {:autosign => [:new, :create],
@@ -654,19 +565,15 @@
permission_set.security_block :subnets do |map|
map.permission :view_subnets, {:subnets => [:index, :show, :auto_complete_search],
- :"api/v1/subnets" => [:index, :show],
:"api/v2/subnets" => [:index, :show, :freeip]
}
map.permission :create_subnets, {:subnets => [:new, :create],
- :"api/v1/subnets" => [:create],
:"api/v2/subnets" => [:create]
}
map.permission :edit_subnets, {:subnets => [:edit, :update],
- :"api/v1/subnets" => [:update],
:"api/v2/subnets" => [:update]
}
map.permission :destroy_subnets, {:subnets => [:destroy],
- :"api/v1/subnets" => [:destroy],
:"api/v2/subnets" => [:destroy]
}
map.permission :import_subnets, {:subnets => [:import, :create_multiple]}
@@ -675,19 +582,15 @@
if SETTINGS[:organizations_enabled]
permission_set.security_block :organizations do |map|
map.permission :view_organizations, {:organizations => [:index, :show, :auto_complete_search],
- :"api/v1/organizations" => [:index, :show],
:"api/v2/organizations" => [:index, :show]
}
map.permission :create_organizations, {:organizations => [:new, :create, :clone_taxonomy, :step2, :nest],
- :"api/v1/organizations" => [:create],
:"api/v2/organizations" => [:create]
}
map.permission :edit_organizations, {:organizations => [:edit, :update, :import_mismatches, :parent_taxonomy_selected],
- :"api/v1/organizations" => [:update],
:"api/v2/organizations" => [:update]
}
map.permission :destroy_organizations, {:organizations => [:destroy],
- :"api/v1/organizations" => [:destroy],
:"api/v2/organizations" => [:destroy]
}
map.permission :assign_organizations, {:organizations => [:assign_all_hosts, :assign_hosts, :assign_selected_hosts]}
@@ -696,19 +599,15 @@
permission_set.security_block :usergroups do |map|
map.permission :view_usergroups, {:usergroups => [:index, :show, :auto_complete_search],
- :"api/v1/usergroups" => [:index, :show],
:"api/v2/usergroups" => [:index, :show]
}
map.permission :create_usergroups, {:usergroups => [:new, :create],
- :"api/v1/usergroups" => [:create],
:"api/v2/usergroups" => [:create]
}
map.permission :edit_usergroups, {:usergroups => [:edit, :update],
- :"api/v1/usergroups" => [:update],
:"api/v2/usergroups" => [:update]
}
map.permission :destroy_usergroups, {:usergroups => [:destroy],
- :"api/v1/usergroups" => [:destroy],
:"api/v2/usergroups" => [:destroy]
}
end
@@ -729,37 +628,30 @@
map.permission :view_users,
:users => [:index, :show, :auto_complete_search, :test_mail],
- :"api/v1/users" => [:index, :show],
:"api/v2/users" => [:index, :show]
map.permission :create_users,
:users => [:new, :create].push(*ajax_actions),
- :"api/v1/users" => [:create],
:"api/v2/users" => [:create]
map.permission :edit_users,
:users => [:edit, :update].push(*ajax_actions),
- :"api/v1/users" => [:update],
:"api/v2/users" => [:update]
map.permission :destroy_users,
:users => [:destroy],
- :"api/v1/users" => [:destroy],
:"api/v2/users" => [:destroy]
end
permission_set.security_block :dashboard do |map|
map.permission :access_dashboard, {:dashboard => [:index, :show, :save_positions, :reset_default, :create, :destroy],
- :"api/v1/dashboard" => [:index],
:"api/v2/dashboard" => [:index]
}
end
permission_set.security_block :config_reports do |map|
- map.permission :view_config_reports, {:"api/v1/reports" => [:index, :show, :last],
- :"api/v2/reports" => [:index, :show, :last],
+ map.permission :view_config_reports, {"api/v2/reports" => [:index, :show, :last],
:config_reports => [:index, :show, :auto_complete_search],
:"api/v2/config_reports" => [:index, :show, :last]
}
map.permission :destroy_config_reports, {:config_reports => [:destroy],
- :"api/v1/reports" => [:destroy],
:"api/v2/reports" => [:destroy],
:"api/v2/config_reports" => [:destroy]
}
@@ -770,7 +662,6 @@
permission_set.security_block :facts do |map|
map.permission :view_facts, {:facts => [:index, :show],
:fact_values => [:index, :show, :auto_complete_search],
- :"api/v1/fact_values" => [:index, :show],
:"api/v2/fact_values" => [:index, :show]
}
map.permission :upload_facts, {:"api/v2/hosts" => [:facts] }
@@ -778,14 +669,12 @@
permission_set.security_block :audit_logs do |map|
map.permission :view_audit_logs, {:audits => [:index, :show, :auto_complete_search],
- :"api/v1/audits" => [:index, :show],
:"api/v2/audits" => [:index, :show]
}
end
permission_set.security_block :statistics do |map|
map.permission :view_statistics, {:statistics => [:index, :show],
- :"api/v1/statistics" => [:index],
:"api/v2/statistics" => [:index]
}
end
diff --git a/app/views/api/v1/architectures/create.json.rabl b/app/views/api/v1/architectures/create.json.rabl
deleted file mode 100644
index b8359b4e8b06..000000000000
--- a/app/views/api/v1/architectures/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @architecture
-
-extends "api/v1/architectures/show"
diff --git a/app/views/api/v1/architectures/index.json.rabl b/app/views/api/v1/architectures/index.json.rabl
deleted file mode 100644
index c9bf037122fd..000000000000
--- a/app/views/api/v1/architectures/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @architectures
-
-extends "api/v1/architectures/show"
diff --git a/app/views/api/v1/architectures/show.json.rabl b/app/views/api/v1/architectures/show.json.rabl
deleted file mode 100644
index db780027329c..000000000000
--- a/app/views/api/v1/architectures/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @architecture
-
-attributes :name, :id, :created_at, :operatingsystem_ids, :updated_at
diff --git a/app/views/api/v1/audits/index.json.rabl b/app/views/api/v1/audits/index.json.rabl
deleted file mode 100644
index 75fb6c4c9181..000000000000
--- a/app/views/api/v1/audits/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @audits
-
-extends "api/v1/audits/show"
diff --git a/app/views/api/v1/audits/show.json.rabl b/app/views/api/v1/audits/show.json.rabl
deleted file mode 100644
index 6e5f171d169c..000000000000
--- a/app/views/api/v1/audits/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @audit
-
-attributes :id, :auditable_id, :auditable_type, :user_id, :user_type, :user_name, :action, :audited_changes, :version, :comment, :associated_id, :associated_type, :created_at, :remote_address, :auditable_name, :associated_name, :updated_at
diff --git a/app/views/api/v1/auth_source_ldaps/index.json.rabl b/app/views/api/v1/auth_source_ldaps/index.json.rabl
deleted file mode 100644
index 6155aa0fd898..000000000000
--- a/app/views/api/v1/auth_source_ldaps/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @auth_source_ldaps
-
-extends "api/v1/auth_source_ldaps/show"
diff --git a/app/views/api/v1/auth_source_ldaps/show.json.rabl b/app/views/api/v1/auth_source_ldaps/show.json.rabl
deleted file mode 100644
index b590c7cd4569..000000000000
--- a/app/views/api/v1/auth_source_ldaps/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @auth_source_ldap
-
-attributes :id, :type, :name, :host, :port, :account, :base_dn, :ldap_filter, :attr_login, :attr_firstname, :attr_lastname, :attr_mail, :attr_photo, :onthefly_register, :tls, :created_at, :updated_at
diff --git a/app/views/api/v1/bookmarks/create.json.rabl b/app/views/api/v1/bookmarks/create.json.rabl
deleted file mode 120000
index bbec79eb9653..000000000000
--- a/app/views/api/v1/bookmarks/create.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-./show.json.rabl
\ No newline at end of file
diff --git a/app/views/api/v1/bookmarks/index.json.rabl b/app/views/api/v1/bookmarks/index.json.rabl
deleted file mode 100644
index 8e4544dfb3f4..000000000000
--- a/app/views/api/v1/bookmarks/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @bookmarks
-
-extends "api/v1/bookmarks/show"
diff --git a/app/views/api/v1/bookmarks/show.json.rabl b/app/views/api/v1/bookmarks/show.json.rabl
deleted file mode 100644
index 37cbbbae734f..000000000000
--- a/app/views/api/v1/bookmarks/show.json.rabl
+++ /dev/null
@@ -1,2 +0,0 @@
-object @bookmark
-attributes :name, :controller, :query, :public, :id, :owner_id, :owner_type
diff --git a/app/views/api/v1/bookmarks/update.json.rabl b/app/views/api/v1/bookmarks/update.json.rabl
deleted file mode 100644
index bdf487195cbd..000000000000
--- a/app/views/api/v1/bookmarks/update.json.rabl
+++ /dev/null
@@ -1,7 +0,0 @@
-object @bookmark
-attributes :name, :controller, :query, :public, :id
-child :owner do
- attributes :name
- attributes :login
- attributes :mail, :as => :email
-end
diff --git a/app/views/api/v1/common_parameters/create.json.rabl b/app/views/api/v1/common_parameters/create.json.rabl
deleted file mode 100644
index c3dceaa6e130..000000000000
--- a/app/views/api/v1/common_parameters/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @common_parameter
-
-extends "api/v1/common_parameters/show"
diff --git a/app/views/api/v1/common_parameters/index.json.rabl b/app/views/api/v1/common_parameters/index.json.rabl
deleted file mode 100644
index cf7d5c424b33..000000000000
--- a/app/views/api/v1/common_parameters/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @common_parameters
-
-extends "api/v1/common_parameters/show"
diff --git a/app/views/api/v1/common_parameters/show.json.rabl b/app/views/api/v1/common_parameters/show.json.rabl
deleted file mode 100644
index 4c3a3b2d5136..000000000000
--- a/app/views/api/v1/common_parameters/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @common_parameter
-
-attributes :id, :name, :value, :hidden_value
diff --git a/app/views/api/v1/compute_resources/create.json.rabl b/app/views/api/v1/compute_resources/create.json.rabl
deleted file mode 100644
index 009f7c92677f..000000000000
--- a/app/views/api/v1/compute_resources/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @compute_resource
-
-extends "api/v1/compute_resources/show"
diff --git a/app/views/api/v1/compute_resources/ec2.json.rabl b/app/views/api/v1/compute_resources/ec2.json.rabl
deleted file mode 100644
index 16dade5478fc..000000000000
--- a/app/views/api/v1/compute_resources/ec2.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :user, :region
diff --git a/app/views/api/v1/compute_resources/gce.json.rabl b/app/views/api/v1/compute_resources/gce.json.rabl
deleted file mode 100644
index dbe21529df58..000000000000
--- a/app/views/api/v1/compute_resources/gce.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :email, :zone, :project, :key_path
diff --git a/app/views/api/v1/compute_resources/index.json.rabl b/app/views/api/v1/compute_resources/index.json.rabl
deleted file mode 100644
index 463164db6594..000000000000
--- a/app/views/api/v1/compute_resources/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @compute_resources
-
-extends "api/v1/compute_resources/show"
diff --git a/app/views/api/v1/compute_resources/libvirt.json.rabl b/app/views/api/v1/compute_resources/libvirt.json.rabl
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/app/views/api/v1/compute_resources/openstack.json.rabl b/app/views/api/v1/compute_resources/openstack.json.rabl
deleted file mode 100644
index 61f86b8d1979..000000000000
--- a/app/views/api/v1/compute_resources/openstack.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :user, :tenant
diff --git a/app/views/api/v1/compute_resources/ovirt.json.rabl b/app/views/api/v1/compute_resources/ovirt.json.rabl
deleted file mode 100644
index e8c1c0f361fc..000000000000
--- a/app/views/api/v1/compute_resources/ovirt.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :user, :uuid
diff --git a/app/views/api/v1/compute_resources/rackspace.json.rabl b/app/views/api/v1/compute_resources/rackspace.json.rabl
deleted file mode 100644
index 16dade5478fc..000000000000
--- a/app/views/api/v1/compute_resources/rackspace.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :user, :region
diff --git a/app/views/api/v1/compute_resources/show.json.rabl b/app/views/api/v1/compute_resources/show.json.rabl
deleted file mode 100644
index 647f822f3ec9..000000000000
--- a/app/views/api/v1/compute_resources/show.json.rabl
+++ /dev/null
@@ -1,8 +0,0 @@
-object @compute_resource
-
-attributes :id, :name, :description, :url, :created_at, :updated_at
-attribute :provider_friendly_name => 'provider'
-
-node do |r|
- partial("api/v1/compute_resources/#{r.provider.downcase}.json", :object => r)
-end
diff --git a/app/views/api/v1/compute_resources/vmware.json.rabl b/app/views/api/v1/compute_resources/vmware.json.rabl
deleted file mode 100644
index 28a6f33a073d..000000000000
--- a/app/views/api/v1/compute_resources/vmware.json.rabl
+++ /dev/null
@@ -1 +0,0 @@
-attributes :user, :uuid, :server
diff --git a/app/views/api/v1/config_templates/create.json.rabl b/app/views/api/v1/config_templates/create.json.rabl
deleted file mode 100644
index e7cb736d6b90..000000000000
--- a/app/views/api/v1/config_templates/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @config_template => :config_template
-
-extends "api/v1/config_templates/show"
diff --git a/app/views/api/v1/config_templates/index.json.rabl b/app/views/api/v1/config_templates/index.json.rabl
deleted file mode 100644
index acb0fd238f26..000000000000
--- a/app/views/api/v1/config_templates/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @config_templates => :config_templates
-
-extends "api/v1/config_templates/show"
diff --git a/app/views/api/v1/config_templates/show.json.rabl b/app/views/api/v1/config_templates/show.json.rabl
deleted file mode 100644
index efa09ad0830a..000000000000
--- a/app/views/api/v1/config_templates/show.json.rabl
+++ /dev/null
@@ -1,11 +0,0 @@
-object @config_template => :config_template
-
-attributes :name, :template, :snippet, :audit_comment, :id
-
-node do |template|
- unless template.snippet?
- child :template_kind do
- attributes :name, :id
- end
- end
-end
diff --git a/app/views/api/v1/domains/index.json.rabl b/app/views/api/v1/domains/index.json.rabl
deleted file mode 100644
index 22e5335f47b0..000000000000
--- a/app/views/api/v1/domains/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @domains
-
-extends "api/v1/domains/show"
diff --git a/app/views/api/v1/domains/show.json.rabl b/app/views/api/v1/domains/show.json.rabl
deleted file mode 100644
index 994c73197499..000000000000
--- a/app/views/api/v1/domains/show.json.rabl
+++ /dev/null
@@ -1,2 +0,0 @@
-object @domain
-attributes :id, :name, :fullname, :dns_id, :created_at, :updated_at
diff --git a/app/views/api/v1/environments/create.json.rabl b/app/views/api/v1/environments/create.json.rabl
deleted file mode 100644
index abe86192daa4..000000000000
--- a/app/views/api/v1/environments/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @environment
-
-extends "api/v1/environments/show"
diff --git a/app/views/api/v1/environments/index.json.rabl b/app/views/api/v1/environments/index.json.rabl
deleted file mode 100644
index d08a17ab341f..000000000000
--- a/app/views/api/v1/environments/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @environments
-
-extends "api/v1/environments/show"
diff --git a/app/views/api/v1/environments/show.json.rabl b/app/views/api/v1/environments/show.json.rabl
deleted file mode 100644
index 5ab504d344ea..000000000000
--- a/app/views/api/v1/environments/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @environment
-
-attributes :name, :id, :created_at, :updated_at
diff --git a/app/views/api/v1/errors/access_denied.json.rabl b/app/views/api/v1/errors/access_denied.json.rabl
deleted file mode 100644
index 35a57cc23caa..000000000000
--- a/app/views/api/v1/errors/access_denied.json.rabl
+++ /dev/null
@@ -1,4 +0,0 @@
-object false => :error
-
-node(:message) {'Access denied'}
-node(:details) {locals[:details]}
diff --git a/app/views/api/v1/errors/custom_error.json.rabl b/app/views/api/v1/errors/custom_error.json.rabl
deleted file mode 100644
index 28cc0a131c7d..000000000000
--- a/app/views/api/v1/errors/custom_error.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-node :message do
- locals[:message]
-end
diff --git a/app/views/api/v1/errors/not_found.json.rabl b/app/views/api/v1/errors/not_found.json.rabl
deleted file mode 100644
index 2d5243df4538..000000000000
--- a/app/views/api/v1/errors/not_found.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object false
-
-node(:message) { "Resource #{controller.resource_name} not found by id '#{controller.params[:id]}'" }
diff --git a/app/views/api/v1/errors/param_error.json.rabl b/app/views/api/v1/errors/param_error.json.rabl
deleted file mode 100644
index a8bc4c29edc2..000000000000
--- a/app/views/api/v1/errors/param_error.json.rabl
+++ /dev/null
@@ -1,7 +0,0 @@
-exception = locals[:exception]
-
-object exception => :error
-
-attributes :message
-node(:class) { exception.class.to_s }
-node(:parameter_name) { exception.param } if exception.respond_to? :param
diff --git a/app/views/api/v1/errors/standard_error.json.rabl b/app/views/api/v1/errors/standard_error.json.rabl
deleted file mode 100644
index 49b3c14d688c..000000000000
--- a/app/views/api/v1/errors/standard_error.json.rabl
+++ /dev/null
@@ -1,5 +0,0 @@
-exception = locals[:exception]
-
-object exception => :error
-
-attributes :message
diff --git a/app/views/api/v1/errors/unauthorized.json.rabl b/app/views/api/v1/errors/unauthorized.json.rabl
deleted file mode 100644
index 43309a774c9c..000000000000
--- a/app/views/api/v1/errors/unauthorized.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object false
-
-node(:message) { "Unable to authenticate user %s" % locals[:user_login] }
diff --git a/app/views/api/v1/errors/unprocessable_entity.json.rabl b/app/views/api/v1/errors/unprocessable_entity.json.rabl
deleted file mode 100644
index 4e47563e3117..000000000000
--- a/app/views/api/v1/errors/unprocessable_entity.json.rabl
+++ /dev/null
@@ -1,6 +0,0 @@
-object resource = controller.get_resource
-
-attributes :id
-
-node(:errors) { resource.errors.to_hash }
-node(:full_messages) { resource.errors.full_messages }
diff --git a/app/views/api/v1/home/index.json.rabl b/app/views/api/v1/home/index.json.rabl
deleted file mode 100644
index 42051a51314c..000000000000
--- a/app/views/api/v1/home/index.json.rabl
+++ /dev/null
@@ -1,24 +0,0 @@
-object false
-child(:links => "links") do
- # gather index methods of resources
- index_method_description_apis = Apipie.app.resource_descriptions[Apipie.configuration.default_version]
- .map do |name, resource_description|
- if (description = Apipie.app["#{name}#index"])
- description.method_apis_to_json.first
- end
- end.compact
-
- # add additional actions
- %w(home#status).each do |additional_action|
- if (description = Apipie.app[additional_action]) &&
- (api = description.method_apis_to_json.first)
- index_method_description_apis << api
- end
- end
-
- # render links
- index_method_description_apis.each do |api|
- url, description = api[:api_url], api[:short_description]
- node(description.chomp(".")) { url }
- end
-end
diff --git a/app/views/api/v1/home/status.json.rabl b/app/views/api/v1/home/status.json.rabl
deleted file mode 100644
index e5b1a2af2e85..000000000000
--- a/app/views/api/v1/home/status.json.rabl
+++ /dev/null
@@ -1,5 +0,0 @@
-object false
-node(:result) {"ok"}
-node(:status) {200}
-node(:version) {SETTINGS[:version].full}
-node(:api_version) {1}
diff --git a/app/views/api/v1/hostgroups/create.json.rabl b/app/views/api/v1/hostgroups/create.json.rabl
deleted file mode 100644
index 51efe6db6faf..000000000000
--- a/app/views/api/v1/hostgroups/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @hostgroup
-
-extends "api/v1/hostgroups/show"
diff --git a/app/views/api/v1/hostgroups/index.json.rabl b/app/views/api/v1/hostgroups/index.json.rabl
deleted file mode 100644
index bee95408959d..000000000000
--- a/app/views/api/v1/hostgroups/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @hostgroups
-
-extends "api/v1/hostgroups/show"
diff --git a/app/views/api/v1/hostgroups/show.json.rabl b/app/views/api/v1/hostgroups/show.json.rabl
deleted file mode 100644
index a8f01c248dc7..000000000000
--- a/app/views/api/v1/hostgroups/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @hostgroup
-
-attributes :name, :id, :subnet_id, :operatingsystem_id, :domain_id, :environment_id, :ancestry, :label, :parameters, :puppetclass_ids
diff --git a/app/views/api/v1/hosts/create.json.rabl b/app/views/api/v1/hosts/create.json.rabl
deleted file mode 100644
index 1b77d7aec2fc..000000000000
--- a/app/views/api/v1/hosts/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @host
-
-extends "api/v1/hosts/show"
diff --git a/app/views/api/v1/hosts/index.json.rabl b/app/views/api/v1/hosts/index.json.rabl
deleted file mode 100644
index 3544c78eba9e..000000000000
--- a/app/views/api/v1/hosts/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @hosts
-
-attributes :name, :id, :hostgroup_id, :operatingsystem_id
diff --git a/app/views/api/v1/hosts/show.json.rabl b/app/views/api/v1/hosts/show.json.rabl
deleted file mode 100644
index 6418026db769..000000000000
--- a/app/views/api/v1/hosts/show.json.rabl
+++ /dev/null
@@ -1,27 +0,0 @@
-object @host
-
-attributes :name, :id, :ip, :environment_id, :last_report, :updated_at, :created_at, :mac,
- :sp_mac, :sp_ip, :sp_name, :domain_id, :architecture_id, :operatingsystem_id,
- :environment_id, :subnet_id, :sp_subnet_id, :ptable_id, :medium_id, :build,
- :comment, :disk, :installed_at, :model_id, :hostgroup_id, :owner_id, :owner_type,
- :enabled, :puppet_ca_proxy_id, :managed, :use_image, :image_file, :uuid, :compute_resource_id,
- :puppet_proxy_id, :certname, :image_id, :created_at, :updated_at,
- :last_compile, :root_pass
-
-# for compatibility, :puppet_status was moved to host statuses
-attributes :configuration_status => :puppet_status
-
-attribute :organization_id if SETTINGS[:organizations_enabled]
-attribute :location_id if SETTINGS[:locations_enabled]
-
-node :environment do |host|
- {:environment => {:id => host.environment_id, :name => host.environment_name}}
-end
-
-child :host_parameters do
- attributes :id, :name, :value, :priority, :is_property, :reference_id, :created_at, :updated_at
-end
-
-node do |host|
- { :interfaces => partial("api/v1/interfaces/show", :object => host.interfaces) }
-end
diff --git a/app/views/api/v1/images/index.json.rabl b/app/views/api/v1/images/index.json.rabl
deleted file mode 100644
index a522e1ad6003..000000000000
--- a/app/views/api/v1/images/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @images
-
-extends "api/v1/images/show"
diff --git a/app/views/api/v1/images/show.json.rabl b/app/views/api/v1/images/show.json.rabl
deleted file mode 100644
index dee4f83a36c8..000000000000
--- a/app/views/api/v1/images/show.json.rabl
+++ /dev/null
@@ -1,4 +0,0 @@
-object @image
-
-attributes :id, :operatingsystem_id, :compute_resource_id, :architecture_id, :uuid, :username, :name, :created_at, :updated_at
-attribute :iam_role, :if => ->(img) { img.compute_resource.is_a? Foreman::Model::EC2 }
diff --git a/app/views/api/v1/import_puppetclasses/index.json.rabl b/app/views/api/v1/import_puppetclasses/index.json.rabl
deleted file mode 100644
index 3ab7bdb789e2..000000000000
--- a/app/views/api/v1/import_puppetclasses/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @environments, :root => false, :object_root => false
-
-extends "api/v1/import_puppetclasses/show"
diff --git a/app/views/api/v1/import_puppetclasses/show.json.rabl b/app/views/api/v1/import_puppetclasses/show.json.rabl
deleted file mode 100644
index 4c66ae1535e6..000000000000
--- a/app/views/api/v1/import_puppetclasses/show.json.rabl
+++ /dev/null
@@ -1,27 +0,0 @@
-object @environment => nil
-
-attributes :name
-
-node(:actions) do |environment|
- actions = []
- actions << 'new' if @changed['new'][environment.name].present?
- actions << 'updated' if @changed['updated'][environment.name].present?
- actions << 'obsolete' if @changed['obsolete'][environment.name].present?
- actions.as_json
-end
-
-node(:new_puppetclasses, :if => ->(environment) { @changed['new'][environment.name].present? }) do |environment|
- JSON.parse(@changed['new'][environment.name]).keys
-end
-
-node(:updated_puppetclasses, :if => ->(environment) { @changed['updated'][environment.name].present? }) do |environment|
- JSON.parse(@changed['updated'][environment.name]).keys
-end
-
-node(:obsolete_puppetclasses, :if => ->(environment) { @changed['obsolete'][environment.name].present? && !@changed['obsolete'][environment.name].match(/_destroy_/) }) do |environment|
- JSON.parse(@changed['obsolete'][environment.name])
-end
-
-node(:removed_environment, :if => ->(environment) { @changed['obsolete'][environment.name].present? && @changed['obsolete'][environment.name].match(/_destroy_/) }) do |environment|
- environment.name
-end
diff --git a/app/views/api/v1/interfaces/show.json.rabl b/app/views/api/v1/interfaces/show.json.rabl
deleted file mode 100644
index 89960811f6a8..000000000000
--- a/app/views/api/v1/interfaces/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @interface
-
-attributes :id, :ip, :mac, :attrs, :name, :type, :username, :password, :provider, :subnet_id, :domain_id, :created_at, :updated_at
diff --git a/app/views/api/v1/lookup_keys/index.json.rabl b/app/views/api/v1/lookup_keys/index.json.rabl
deleted file mode 100644
index d2c7df419feb..000000000000
--- a/app/views/api/v1/lookup_keys/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @lookup_keys, :object_root => "lookup_key"
-
-extends "api/v1/lookup_keys/show"
diff --git a/app/views/api/v1/lookup_keys/show.json.rabl b/app/views/api/v1/lookup_keys/show.json.rabl
deleted file mode 100644
index 655b5d595fbc..000000000000
--- a/app/views/api/v1/lookup_keys/show.json.rabl
+++ /dev/null
@@ -1,5 +0,0 @@
-object @lookup_key => :lookup_key
-
-attributes :key, :required, :override, :description, :default_value, :id
-
-node(:is_param) { |key| key.puppet? }
diff --git a/app/views/api/v1/media/index.json.rabl b/app/views/api/v1/media/index.json.rabl
deleted file mode 100644
index c2a8c773ac9a..000000000000
--- a/app/views/api/v1/media/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @media
-
-extends "api/v1/media/show"
diff --git a/app/views/api/v1/media/show.json.rabl b/app/views/api/v1/media/show.json.rabl
deleted file mode 100644
index 1a756e8fad90..000000000000
--- a/app/views/api/v1/media/show.json.rabl
+++ /dev/null
@@ -1,9 +0,0 @@
-object @medium
-
-attributes :id, :name, :path, :os_family, :created_at, :updated_at, :operatingsystem_ids
-
-node do |medium|
- if medium.os_family == 'Solaris'
- attributes :media_path, :config_path, :image_path
- end
-end
diff --git a/app/views/api/v1/models/index.rabl b/app/views/api/v1/models/index.rabl
deleted file mode 100644
index 1a6bc503dcd1..000000000000
--- a/app/views/api/v1/models/index.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @models
-
-extends "api/v1/models/show"
diff --git a/app/views/api/v1/models/show.rabl b/app/views/api/v1/models/show.rabl
deleted file mode 100644
index 1ad67c0849ac..000000000000
--- a/app/views/api/v1/models/show.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @model
-
-attributes :id, :name, :info, :created_at, :updated_at, :vendor_class, :hardware_model
diff --git a/app/views/api/v1/operatingsystems/create.json.rabl b/app/views/api/v1/operatingsystems/create.json.rabl
deleted file mode 100644
index 63c31d409e9e..000000000000
--- a/app/views/api/v1/operatingsystems/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @operatingsystem
-
-extends "api/v1/operatingsystems/show"
diff --git a/app/views/api/v1/operatingsystems/index.json.rabl b/app/views/api/v1/operatingsystems/index.json.rabl
deleted file mode 100644
index cc29843e3fb3..000000000000
--- a/app/views/api/v1/operatingsystems/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @operatingsystems
-
-extends "api/v1/operatingsystems/show"
diff --git a/app/views/api/v1/operatingsystems/show.json.rabl b/app/views/api/v1/operatingsystems/show.json.rabl
deleted file mode 100644
index 35a5683d6410..000000000000
--- a/app/views/api/v1/operatingsystems/show.json.rabl
+++ /dev/null
@@ -1,22 +0,0 @@
-object @operatingsystem
-attributes :id, :name, :major, :minor, :family, :release_name, :password_hash
-
-child :media do
- attributes :id, :name
-end
-
-child :architectures do
- attributes :id, :name
-end
-
-child :ptables => :ptables do
- attributes :id, :name
-end
-
-child :provisioning_templates => :config_templates do
- attributes :name, :id
-end
-
-child :os_default_templates do
- attributes :id => :id, :provisioning_template_id => :config_template_id, :template_kind_id => :template_kind_id
-end
diff --git a/app/views/api/v1/operatingsystems/update.json.rabl b/app/views/api/v1/operatingsystems/update.json.rabl
deleted file mode 100644
index 63c31d409e9e..000000000000
--- a/app/views/api/v1/operatingsystems/update.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @operatingsystem
-
-extends "api/v1/operatingsystems/show"
diff --git a/app/views/api/v1/ptables/index.json.rabl b/app/views/api/v1/ptables/index.json.rabl
deleted file mode 100644
index e4e17f91201c..000000000000
--- a/app/views/api/v1/ptables/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @ptables
-
-extends "api/v1/ptables/show"
diff --git a/app/views/api/v1/ptables/show.json.rabl b/app/views/api/v1/ptables/show.json.rabl
deleted file mode 100644
index 58a083d3fba4..000000000000
--- a/app/views/api/v1/ptables/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @ptable
-
-attributes :name, :id, :layout, :os_family, :created_at, :updated_at
diff --git a/app/views/api/v1/reports/index.json.rabl b/app/views/api/v1/reports/index.json.rabl
deleted file mode 100644
index fb9fbf713d26..000000000000
--- a/app/views/api/v1/reports/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @reports
-
-extends "api/v1/reports/show"
diff --git a/app/views/api/v1/reports/show.json.rabl b/app/views/api/v1/reports/show.json.rabl
deleted file mode 100644
index 2aaa1b8fd90e..000000000000
--- a/app/views/api/v1/reports/show.json.rabl
+++ /dev/null
@@ -1,17 +0,0 @@
-object @report
-
-attributes :id, :reported_at, :status, :metrics
-
-child :logs do
- child :source => :sources do
- attribute :value => :source
- end
- child :message => :messages do
- attribute :value => :message
- end
- attribute :level
-end
-
-node :summary do |report|
- report.summary_status
-end
diff --git a/app/views/api/v1/roles/create.json.rabl b/app/views/api/v1/roles/create.json.rabl
deleted file mode 100644
index 46bb9dc58909..000000000000
--- a/app/views/api/v1/roles/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @role
-
-extends "api/v1/roles/show"
diff --git a/app/views/api/v1/roles/index.json.rabl b/app/views/api/v1/roles/index.json.rabl
deleted file mode 100644
index 3cc6b482b1de..000000000000
--- a/app/views/api/v1/roles/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @roles
-
-extends "api/v1/roles/show"
diff --git a/app/views/api/v1/roles/show.json.rabl b/app/views/api/v1/roles/show.json.rabl
deleted file mode 100644
index 517bea64f0f5..000000000000
--- a/app/views/api/v1/roles/show.json.rabl
+++ /dev/null
@@ -1,7 +0,0 @@
-object @role
-
-attributes :name, :id, :builtin
-
-node :permissions do |r|
- r.permissions.map(&:name)
-end
diff --git a/app/views/api/v1/settings/index.json.rabl b/app/views/api/v1/settings/index.json.rabl
deleted file mode 100644
index da92f2cfff83..000000000000
--- a/app/views/api/v1/settings/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @settings
-
-extends "api/v1/settings/show"
diff --git a/app/views/api/v1/settings/show.json.rabl b/app/views/api/v1/settings/show.json.rabl
deleted file mode 100644
index 7e069fbf538e..000000000000
--- a/app/views/api/v1/settings/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @setting
-
-attributes :id, :name, :value, :description, :category, :settings_type, :default, :created_at, :updated_at
diff --git a/app/views/api/v1/smart_proxies/index.json.rabl b/app/views/api/v1/smart_proxies/index.json.rabl
deleted file mode 100644
index 1ccb519ae2c3..000000000000
--- a/app/views/api/v1/smart_proxies/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @smart_proxies
-
-attributes :name, :id, :url, :created_at, :updated_at
diff --git a/app/views/api/v1/smart_proxies/show.json.rabl b/app/views/api/v1/smart_proxies/show.json.rabl
deleted file mode 100644
index 87c7469330ff..000000000000
--- a/app/views/api/v1/smart_proxies/show.json.rabl
+++ /dev/null
@@ -1,7 +0,0 @@
-object @smart_proxy
-
-attributes :name, :id, :url, :created_at, :updated_at
-
-child :features do
- attributes :name, :id, :url
-end
diff --git a/app/views/api/v1/subnets/create.json.rabl b/app/views/api/v1/subnets/create.json.rabl
deleted file mode 100644
index 988a1e551c7d..000000000000
--- a/app/views/api/v1/subnets/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @subnet
-
-extends "api/v1/subnets/show"
diff --git a/app/views/api/v1/subnets/index.json.rabl b/app/views/api/v1/subnets/index.json.rabl
deleted file mode 100644
index 200a6f707b32..000000000000
--- a/app/views/api/v1/subnets/index.json.rabl
+++ /dev/null
@@ -1,5 +0,0 @@
-collection @subnets
-
-attributes :id, :name, :network, :mask, :priority, :vlanid,
- :gateway, :dns_primary, :dns_secondary, :from, :to, :domain_ids,
- :dns_id, :dhcp_id, :tftp_id, :ipam
diff --git a/app/views/api/v1/subnets/show.json.rabl b/app/views/api/v1/subnets/show.json.rabl
deleted file mode 100644
index 4a8fab22a856..000000000000
--- a/app/views/api/v1/subnets/show.json.rabl
+++ /dev/null
@@ -1,17 +0,0 @@
-object @subnet
-
-attributes :id, :name, :network_type, :network, :mask, :priority, :vlanid,
- :gateway, :dns_primary, :dns_secondary, :from, :to, :domain_ids,
- :dns_id, :dhcp_id, :tftp_id, :cidr, :ipam
-
-child :dhcp => :dhcp do
- attributes :id, :name, :url
-end
-
-child :tftp => :tftp do
- attributes :id, :name, :url
-end
-
-child :dns => :dns do
- attributes :id, :name, :url
-end
diff --git a/app/views/api/v1/subnets/update.json.rabl b/app/views/api/v1/subnets/update.json.rabl
deleted file mode 100644
index 988a1e551c7d..000000000000
--- a/app/views/api/v1/subnets/update.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @subnet
-
-extends "api/v1/subnets/show"
diff --git a/app/views/api/v1/template_kinds/index.json.rabl b/app/views/api/v1/template_kinds/index.json.rabl
deleted file mode 100644
index 6d9e01e9c843..000000000000
--- a/app/views/api/v1/template_kinds/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @template_kinds
-
-extends "api/v1/template_kinds/show"
diff --git a/app/views/api/v1/template_kinds/show.json.rabl b/app/views/api/v1/template_kinds/show.json.rabl
deleted file mode 100644
index 6a33274e4ca7..000000000000
--- a/app/views/api/v1/template_kinds/show.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @template_kind
-
-attributes :name, :id
diff --git a/app/views/api/v1/usergroups/index.json.rabl b/app/views/api/v1/usergroups/index.json.rabl
deleted file mode 100644
index e9dcc3e3ecca..000000000000
--- a/app/views/api/v1/usergroups/index.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-collection @usergroups
-
-extends "api/v1/usergroups/show"
diff --git a/app/views/api/v1/usergroups/show.json.rabl b/app/views/api/v1/usergroups/show.json.rabl
deleted file mode 100644
index 2647379185a3..000000000000
--- a/app/views/api/v1/usergroups/show.json.rabl
+++ /dev/null
@@ -1,7 +0,0 @@
-object @usergroup
-
-attributes :name, :id, :created_at, :updated_at
-
-node do |ug|
- { :usergroup_members => ug.usergroup_member_ids }
-end
diff --git a/app/views/api/v1/users/create.json.rabl b/app/views/api/v1/users/create.json.rabl
deleted file mode 100644
index 5e05a5ed990a..000000000000
--- a/app/views/api/v1/users/create.json.rabl
+++ /dev/null
@@ -1,3 +0,0 @@
-object @user
-
-extends "api/v1/users/show"
diff --git a/app/views/api/v1/users/index.json.rabl b/app/views/api/v1/users/index.json.rabl
deleted file mode 100644
index d52517714027..000000000000
--- a/app/views/api/v1/users/index.json.rabl
+++ /dev/null
@@ -1,10 +0,0 @@
-collection @users
-
-attributes :id, :login, :firstname, :lastname, :mail, :admin, :auth_source_id, :role_id, :last_login_on,
- :created_at, :updated_at
-
-node(:domains_andor) { 'or' }
-node(:hostgroups_andor) { 'or' }
-node(:facts_andor) { 'or' }
-node(:compute_resources_andor) { 'or' }
-node(:filter_on_owner) { nil }
diff --git a/app/views/api/v1/users/show.json.rabl b/app/views/api/v1/users/show.json.rabl
deleted file mode 100644
index b0a3440ef5e8..000000000000
--- a/app/views/api/v1/users/show.json.rabl
+++ /dev/null
@@ -1,18 +0,0 @@
-object @user
-
-attributes :id, :login, :firstname, :lastname, :mail, :admin, :auth_source_id, :role_id, :timezone, :last_login_on,
- :created_at, :updated_at
-
-node(:domains_andor) { 'or' }
-node(:hostgroups_andor) { 'or' }
-node(:facts_andor) { 'or' }
-node(:compute_resources_andor) { 'or' }
-node(:filter_on_owner) { nil }
-
-child :auth_source do
- extends "api/v1/auth_source_ldaps/show"
-end
-
-child :roles do
- extends "api/v1/roles/show"
-end
diff --git a/config/initializers/rabl_init.rb b/config/initializers/rabl_init.rb
index d37b277b947e..60c470e61d46 100644
--- a/config/initializers/rabl_init.rb
+++ b/config/initializers/rabl_init.rb
@@ -11,12 +11,11 @@ class Configuration
module Foreman
module RablEngineExt
def api_version
- respond_to?(:response) ? response.headers["Foreman_api_version"] : '1'
+ respond_to?(:response) ? response.headers["Foreman_api_version"] : '2'
end
def default_options
- return {:root => false, :object_root => false} if api_version.to_i > 1
- {}
+ {:root => false, :object_root => false}
end
def collection(data, options = default_options)
@@ -30,10 +29,6 @@ def collection(data, options = default_options)
def data_name(data_token)
# custom object root
return params['root_name'] if respond_to?(:params) && params['root_name'].present? && !['false', false].include?(params['root_name'])
- # no object root for v2
- return nil if !respond_to?(:params) || api_version.to_i > 1 || ['false', false].include?(params['root_name'])
- # otherwise return super since v1 has object root (config.include_child_root = true)
- super
end
end
end
diff --git a/config/routes/api/v1.rb b/config/routes/api/v1.rb
deleted file mode 100644
index 2bb91e276742..000000000000
--- a/config/routes/api/v1.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# config/routes/api/v1.rb
-Foreman::Application.routes.draw do
- namespace :api, :defaults => {:format => 'json'} do
- scope "(:apiv)", :module => :v1, :defaults => {:apiv => 'v1'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 1) do
- resources :architectures, :except => [:new, :edit]
- resources :audits, :only => [:index, :show]
- resources :auth_source_ldaps, :except => [:new, :edit]
- resources :bookmarks, :except => [:new, :edit]
- resources :common_parameters, :except => [:new, :edit]
- # add "constraint" that unconstrained and allows :id to have dot notation ex. sat.redhat.com
- constraints(:id => /[^\/]+/) do
- resources :domains, :except => [:new, :edit]
- resources :hosts, :except => [:new, :edit] do
- resources :reports, :only => [:index, :show] do
- get :last, :on => :collection
- end
- resources :audits, :only => :index
- resources :facts, :only => :index, :controller => :fact_values
- resources :puppetclasses, :only => :index
- get :status, :on => :member
- end
- resources :compute_resources, :except => [:new, :edit] do
- resources :images, :except => [:new, :edit]
- end
- resources :smart_proxies, :except => [:new, :edit] do
- put :refresh, :on => :member
- post :import_puppetclasses, :on => :member
- resources :environments, :only => [] do
- post :import_puppetclasses, :on => :member
- end
- resources :autosign, :only => [:index]
- end
- end
- resources :config_templates, :except => [:new, :edit] do
- collection do
- get 'build_pxe_default'
- get 'revision'
- end
- end
- resources :dashboard, :only => [:index]
- resources :statistics, :only => [:index]
- resources :environments, :except => [:new, :edit] do
- resources :smart_proxies, :only => [] do
- post :import_puppetclasses, :on => :member
- end
- end
- resources :fact_values, :only => [:index]
- resources :hostgroups, :except => [:new, :edit]
- resources :lookup_keys, :except => [:new, :edit]
- resources :media, :except => [:new, :edit]
- resources :models, :except => [:new, :edit]
- resources :operatingsystems, :except => [:new, :edit] do
- member do
- get 'bootfiles'
- end
- end
- resources :ptables, :except => [:new, :edit]
- resources :puppetclasses, :except => [:new, :edit]
- resources :roles, :except => [:new, :edit]
- resources :reports, :only => [:index, :show, :destroy] do
- get :last, :on => :collection
- end
- resources :settings, :only => [:index, :show, :update]
- resources :subnets, :except => [:new, :edit]
- resources :usergroups, :except => [:new, :edit]
- # add "constraint" that unconstrained and allows :id to have dot notation ex. first.lastname
- constraints(:id => /[^\/]+/) do
- resources :users, :except => [:new, :edit]
- end
- resources :template_kinds, :only => [:index]
-
- get '/', :to => 'home#index'
- get 'status', :to => 'home#status', :as => "status"
- end
- end
-end
diff --git a/config/routes/api/v2.rb b/config/routes/api/v2.rb
index b1e97a2d0974..4e5d4fb03553 100644
--- a/config/routes/api/v2.rb
+++ b/config/routes/api/v2.rb
@@ -2,7 +2,7 @@
Foreman::Application.routes.draw do
namespace :api, :defaults => {:format => 'json'} do
# new v2 routes that point to v2
- scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
+ scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
resources :architectures, :except => [:new, :edit] do
constraints(:id => /[^\/]+/) do
resources :hosts, :except => [:new, :edit]
diff --git a/config/routes/puppet/api/v2.rb b/config/routes/puppet/api/v2.rb
index 9a9e009e5252..061f37e3dfe8 100644
--- a/config/routes/puppet/api/v2.rb
+++ b/config/routes/puppet/api/v2.rb
@@ -1,7 +1,7 @@
Foreman::Application.routes.draw do
namespace :api, :defaults => {:format => 'json'} do
# new v2 routes that point to v2
- scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
+ scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
constraints(:id => /[^\/]+/) do
resources :hosts, :except => [:new, :edit] do
put :puppetrun, :on => :member, :to => 'puppet_hosts#puppetrun'
diff --git a/test/controllers/api/base_controller_subclass_test.rb b/test/controllers/api/base_controller_subclass_test.rb
index 4d7ae6fbf9bc..f7b90085324f 100644
--- a/test/controllers/api/base_controller_subclass_test.rb
+++ b/test/controllers/api/base_controller_subclass_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class Api::TestableController < Api::V1::BaseController
+class Api::TestableController < Api::V2::BaseController
before_action :find_required_nested_object, :only => [:required_nested_values, :nested_values]
before_action :find_optional_nested_object, :only => [:optional_nested_values]
before_action :find_resource, :only => [:nested_values]
diff --git a/test/controllers/api/v1/architectures_controller_test.rb b/test/controllers/api/v1/architectures_controller_test.rb
deleted file mode 100644
index 85042d73b2d3..000000000000
--- a/test/controllers/api/v1/architectures_controller_test.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'test_helper'
-
-class Api::V1::ArchitecturesControllerTest < ActionController::TestCase
- arch_i386 = { :name => 'i386' }
-
- def user_one_as_anonymous_viewer
- users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
- end
-
- def user_one_as_manager
- users(:one).roles = [Role.default, Role.find_by_name('Manager')]
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:architectures)
- architectures = ActiveSupport::JSON.decode(@response.body)
- assert !architectures.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => architectures(:x86_64).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create architecture" do
- assert_difference('Architecture.count') do
- post :create, { :architecture => arch_i386 }
- end
- assert_response :success
- end
-
- test "should update architecture" do
- put :update, { :id => architectures(:x86_64).to_param, :architecture => arch_i386 }
- assert_response :success
- end
-
- test "should destroy architecture" do
- assert_difference('Architecture.count', -1) do
- delete :destroy, { :id => architectures(:s390).to_param }
- end
- assert_response :success
- end
-
- test "should not destroy used architecture" do
- assert_difference('Architecture.count', 0) do
- delete :destroy, { :id => architectures(:x86_64).to_param }
- end
- assert_response :unprocessable_entity
- end
-
- test "user with viewer rights should fail to update an architecture" do
- user_one_as_anonymous_viewer
- as_user :one do
- put :update, { :id => architectures(:x86_64).to_param, :architecture => arch_i386 }
- end
- assert_response :forbidden
- end
-
- test "user with manager rights should success to update an architecture" do
- user_one_as_manager
- as_user :one do
- put :update, { :id => architectures(:x86_64).to_param, :architecture => arch_i386 }
- end
- assert_response :success
- end
-
- test "user with viewer rights should succeed in viewing architectures" do
- user_one_as_anonymous_viewer
- as_user :one do
- get :index, { }
- end
- assert_response :success
- end
-
- test "403 response contains missing permissions" do
- as_user :one do
- get :index, { }
- end
- assert_response :forbidden
- assert_includes @response.body, 'view_architectures'
- end
-end
diff --git a/test/controllers/api/v1/audits_controller_test.rb b/test/controllers/api/v1/audits_controller_test.rb
deleted file mode 100644
index 869fcc92cc71..000000000000
--- a/test/controllers/api/v1/audits_controller_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'test_helper'
-
-class Api::V1::AuditsControllerTest < ActionController::TestCase
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:audits)
- audits = ActiveSupport::JSON.decode(@response.body)
- assert !audits.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => audits(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-end
diff --git a/test/controllers/api/v1/auth_source_ldaps_controller_test.rb b/test/controllers/api/v1/auth_source_ldaps_controller_test.rb
deleted file mode 100644
index f67273e495b6..000000000000
--- a/test/controllers/api/v1/auth_source_ldaps_controller_test.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require 'test_helper'
-
-class Api::V1::AuthSourceLdapsControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'ldap2', :host => 'ldap2', :server_type => 'posix' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:auth_source_ldaps)
- auth_source_ldaps = ActiveSupport::JSON.decode(@response.body)
- assert !auth_source_ldaps.empty?
- end
-
- test "should show auth_source_ldap" do
- get :show, { :id => auth_sources(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create auth_source_ldap" do
- assert_difference('AuthSourceLdap.unscoped.count', 1) do
- post :create, { :auth_source_ldap => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update auth_source_ldap" do
- put :update, { :id => auth_sources(:one).to_param, :auth_source_ldap => { :host => "ldap3" } }
- assert_response :success
- end
-
- test "should destroy auth_source_ldap" do
- assert_difference('AuthSourceLdap.unscoped.count', -1) do
- auth = auth_sources(:one)
- User.where(:auth_source_id => auth.id).update_all(:auth_source_id => nil)
- delete :destroy, { :id => auth.id }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/autosign_controller_test.rb b/test/controllers/api/v1/autosign_controller_test.rb
deleted file mode 100644
index 6b1aa3d766b7..000000000000
--- a/test/controllers/api/v1/autosign_controller_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'test_helper'
-
-class Api::V1::AutosignControllerTest < ActionController::TestCase
- setup do
- ProxyAPI::Puppetca.any_instance.stubs(:autosign).returns(["a5809524-82fe-a8a4f3d6ebf4", "5eed0cb7-9aa-00b7b9780f20"])
- end
-
- test "should get index and return json" do
- get :index, { :smart_proxy_id => smart_proxies(:puppetmaster).id }
- assert_response :success
- assert_equal 'http://else.where:4567/puppet/ca', ProxyAPI::Puppetca.new(:url => smart_proxies(:puppetmaster).url).url
- results = ActiveSupport::JSON.decode(@response.body)
- assert_equal 2, results.length
- end
-end
diff --git a/test/controllers/api/v1/bookmarks_controller_test.rb b/test/controllers/api/v1/bookmarks_controller_test.rb
deleted file mode 100644
index 70440ad6b55c..000000000000
--- a/test/controllers/api/v1/bookmarks_controller_test.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'test_helper'
-
-class Api::V1::BookmarksControllerTest < ActionController::TestCase
- bookmark_base = {
- :public => false,
- :controller => "hosts"
- }
-
- simple_bookmark = bookmark_base.merge({
- :name => "foo-bar",
- :query => "bar"
- })
-
- dot_bookmark = bookmark_base.merge({
- :name => "facts.architecture",
- :query => " facts.architecture = x86_64"
- })
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:bookmarks)
- end
-
- test "should show bookmark" do
- get :show, { :id => bookmarks(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create bookmark" do
- assert_difference('Bookmark.count') do
- post :create, { :bookmark => simple_bookmark }
- end
- assert_response :success
- end
-
- test "should create bookmark with a dot" do
- assert_difference('Bookmark.count') do
- post :create, { :bookmark => dot_bookmark }
- end
- assert_response :success
- end
-
- test "should update bookmark" do
- put :update, { :id => bookmarks(:one).to_param, :bookmark => bookmark_base }
- assert_response :success
- end
-
- test "should destroy bookmark" do
- assert_difference('Bookmark.count', -1) do
- delete :destroy, { :id => bookmarks(:one).to_param }
- end
- assert_response :success
- end
-
- test "should only show public and user's bookmarks" do
- get :index, {}, set_session_user
- assert_response :success
- assert_includes assigns(:bookmarks), bookmarks(:one)
- refute_includes assigns(:bookmarks), bookmarks(:two)
- end
-
- test "should not allow actions on non public/non user bookmarks" do
- put :update, {:id => bookmarks(:two).to_param, :bookmark => { :name => 'bar' }}, set_session_user
- assert_response 404
- end
-end
diff --git a/test/controllers/api/v1/common_parameters_controller_test.rb b/test/controllers/api/v1/common_parameters_controller_test.rb
deleted file mode 100644
index dc6dc6e8322b..000000000000
--- a/test/controllers/api/v1/common_parameters_controller_test.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'test_helper'
-
-class Api::V1::CommonParametersControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'special_key', :value => '123' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:common_parameters)
- common_parameters = ActiveSupport::JSON.decode(@response.body)
- assert !common_parameters.empty?
- end
-
- test "should show parameter" do
- get :show, { :id => parameters(:common).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create common_parameter" do
- assert_difference('CommonParameter.count') do
- post :create, { :common_parameter => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update common_parameter" do
- put :update, { :id => parameters(:common).to_param, :common_parameter => valid_attrs }
- assert_response :success
- end
-
- test "should destroy common_parameter" do
- assert_difference('CommonParameter.count', -1) do
- delete :destroy, { :id => parameters(:common).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/compute_resources_controller_test.rb b/test/controllers/api/v1/compute_resources_controller_test.rb
deleted file mode 100644
index 2659f8ad203b..000000000000
--- a/test/controllers/api/v1/compute_resources_controller_test.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-require 'test_helper'
-
-class Api::V1::ComputeResourcesControllerTest < ActionController::TestCase
- def setup
- Fog.mock!
- end
-
- def teardown
- Fog.unmock!
- end
-
- valid_attrs = { :name => 'special_compute', :provider => 'EC2', :region => 'eu-west-1', :user => 'user@example.com', :password => 'secret' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:compute_resources)
- compute_resources = ActiveSupport::JSON.decode(@response.body)
- assert !compute_resources.empty?
- end
-
- test "should show compute_resource" do
- get :show, { :id => compute_resources(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create valid compute resource" do
- post :create, { :compute_resource => valid_attrs }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should update compute resource" do
- put :update, { :id => compute_resources(:mycompute).to_param, :compute_resource => { :description => "new_description" } }
- assert_equal "new_description",
- ComputeResource.unscoped.find_by_name('mycompute').description
- assert_response :success
- end
-
- test "should destroy compute resource" do
- assert_difference('ComputeResource.unscoped.count', -1) do
- delete :destroy, { :id => compute_resources(:yourcompute).id }
- end
- assert_response :success
- end
-
- test "should get index of owned" do
- setup_user 'view', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- get :index, {}
- assert_response :success
- assert_not_nil assigns(:compute_resources)
- compute_resources = ActiveSupport::JSON.decode(@response.body)
- ids = compute_resources.map { |hash| hash['compute_resource']['id'] }
- assert_includes ids, compute_resources(:mycompute).id
- refute_includes ids, compute_resources(:yourcompute).id
- end
-
- test "should allow access to a compute resource for owner" do
- setup_user 'view', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- get :show, { :id => compute_resources(:mycompute).to_param }
- assert_response :success
- end
-
- test "should update compute resource for owner" do
- setup_user 'edit', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- put :update, { :id => compute_resources(:mycompute).to_param, :compute_resource => { :description => "new_description" } }
- assert_equal "new_description",
- ComputeResource.unscoped.find_by_name('mycompute').description
- assert_response :success
- end
-
- test "should destroy compute resource for owner" do
- assert_difference('ComputeResource.unscoped.count', -1) do
- setup_user 'destroy', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- delete :destroy, { :id => compute_resources(:mycompute).id }
- end
- assert_response :success
- end
-
- test "should not allow access to a compute resource out of users compute resources scope" do
- setup_user 'view', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- get :show, { :id => compute_resources(:one).to_param }
- assert_response :not_found
- end
-
- test "should not update compute resource for restricted" do
- setup_user 'edit', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- put :update, { :id => compute_resources(:yourcompute).to_param, :compute_resource => { :description => "new_description" } }
- assert_response :not_found
- end
-
- test "should not destroy compute resource for restricted" do
- setup_user 'destroy', 'compute_resources', "id = #{compute_resources(:mycompute).id}"
- delete :destroy, { :id => compute_resources(:yourcompute).id }
- assert_response :not_found
- end
-end
diff --git a/test/controllers/api/v1/config_templates_controller_test.rb b/test/controllers/api/v1/config_templates_controller_test.rb
deleted file mode 100644
index 1a5794602425..000000000000
--- a/test/controllers/api/v1/config_templates_controller_test.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'test_helper'
-
-class Api::V1::ConfigTemplatesControllerTest < ActionController::TestCase
- setup do
- Foreman::Deprecation.expects(:api_deprecation_warning).with('Config templates were renamed to provisioning templates')
- end
-
- test "should get index" do
- get :index
- templates = ActiveSupport::JSON.decode(@response.body)
- assert_not_empty templates
- assert_response :success
- end
-
- test "should get template detail" do
- get :show, { :id => templates(:pxekickstart).to_param }
- assert_response :success
- template = ActiveSupport::JSON.decode(@response.body)
- assert_not_empty template
- assert_equal template["config_template"]["name"], templates(:pxekickstart).name
- end
-
- test "should create valid" do
- ProvisioningTemplate.any_instance.stubs(:valid?).returns(true)
- valid_attrs = { :template => "This is a test template", :template_kind_id => template_kinds(:ipxe).id, :name => "RandomName" }
- post :create, { :config_template => valid_attrs }
- template = ActiveSupport::JSON.decode(@response.body)
- assert template["config_template"]["name"] == "RandomName"
- assert_response :success
- end
-
- test "should not create invalid" do
- post :create, {:config_template => {:name => ""}}
- assert_response :unprocessable_entity
- end
-
- test "should update valid" do
- ProvisioningTemplate.any_instance.stubs(:valid?).returns(true)
- put :update, { :id => templates(:pxekickstart).to_param,
- :config_template => { :template => "blah" } }
- assert_response :success
- end
-
- test "should not update invalid" do
- put :update, { :id => templates(:pxekickstart).to_param,
- :config_template => { :name => "" } }
- assert_response :unprocessable_entity
- end
-
- test "should not destroy template with associated hosts" do
- config_template = templates(:pxekickstart)
- delete :destroy, { :id => config_template.to_param }
- assert_response :unprocessable_entity
- assert ProvisioningTemplate.unscoped.exists?(config_template.id)
- end
-
- test "should destroy" do
- config_template = templates(:pxekickstart)
- config_template.os_default_templates.clear
- delete :destroy, { :id => config_template.to_param }
- assert_response :success
- refute ProvisioningTemplate.unscoped.exists?(config_template.id)
- end
-
- test "should build pxe menu" do
- ProxyAPI::TFTP.any_instance.stubs(:create_default).returns(true)
- ProxyAPI::TFTP.any_instance.stubs(:fetch_boot_file).returns(true)
- get :build_pxe_default
- assert_response :success
- end
-
- test "should add audit comment" do
- ProvisioningTemplate.auditing_enabled = true
- ProvisioningTemplate.any_instance.stubs(:valid?).returns(true)
- put :update, { :id => templates(:pxekickstart).to_param,
- :config_template => { :audit_comment => "aha", :template => "tmp" } }
- assert_response :success
- assert_equal "aha", templates(:pxekickstart).audits.last.comment
- end
-end
diff --git a/test/controllers/api/v1/dashboard_controller_test.rb b/test/controllers/api/v1/dashboard_controller_test.rb
deleted file mode 100644
index 2daafd1e8dad..000000000000
--- a/test/controllers/api/v1/dashboard_controller_test.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'test_helper'
-
-class Api::V1::DashboardControllerTest < ActionController::TestCase
- test "should get index with json result" do
- get :index, { }
- assert_response :success
- dashboard = ActiveSupport::JSON.decode(@response.body)
- assert_operator(dashboard.length, :>, 0)
- end
-end
diff --git a/test/controllers/api/v1/domains_controller_test.rb b/test/controllers/api/v1/domains_controller_test.rb
deleted file mode 100644
index e5981ed359dc..000000000000
--- a/test/controllers/api/v1/domains_controller_test.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'test_helper'
-
-class Api::V1::DomainsControllerTest < ActionController::TestCase
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:domains)
- end
-
- test "should show domain" do
- get :show, { :id => Domain.first.to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create valid domain" do
- post :create, { :domain => { :name => "domain.net" } }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should not create invalid domain" do
- post :create, { :domain => { :fullname => "" } }
- assert_response :unprocessable_entity
- end
-
- test "should update valid domain" do
- put :update, { :id => Domain.unscoped.first.to_param, :domain => { :name => "domain.new" } }
- assert_equal "domain.new", Domain.unscoped.first.name
- assert_response :success
- end
-
- test "should not update invalid domain" do
- put :update, { :id => Domain.first.to_param, :domain => { :name => "" } }
- assert_response :unprocessable_entity
- end
-
- test "should destroy domain" do
- domain = Domain.first
- domain.hosts.clear
- domain.hostgroups.clear
- domain.subnets.clear
- delete :destroy, { :id => domain.to_param }
- domain = ActiveSupport::JSON.decode(@response.body)
- assert_response :ok
- assert !Domain.exists?(:name => domain['id'])
- end
-end
diff --git a/test/controllers/api/v1/environments_controller_test.rb b/test/controllers/api/v1/environments_controller_test.rb
deleted file mode 100644
index 81e509e34d15..000000000000
--- a/test/controllers/api/v1/environments_controller_test.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'test_helper'
-
-class Api::V1::EnvironmentsControllerTest < ActionController::TestCase
- development_environment = { :name => 'Development' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:environments)
- envs = ActiveSupport::JSON.decode(@response.body)
- assert !envs.empty?
- end
-
- test "should show environment" do
- get :show, { :id => environments(:production).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create environment" do
- assert_difference('Environment.unscoped.count') do
- post :create, { :environment => development_environment }
- end
- assert_response :success
- end
-
- test "should update environment" do
- put :update, { :id => environments(:production).to_param, :environment => development_environment }
- assert_response :success
- end
-
- test "should destroy environments" do
- assert_difference('Environment.unscoped.count', -1) do
- delete :destroy, { :id => environments(:testing).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/fact_values_controller_test.rb b/test/controllers/api/v1/fact_values_controller_test.rb
deleted file mode 100644
index 5990bb352fe8..000000000000
--- a/test/controllers/api/v1/fact_values_controller_test.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'test_helper'
-
-class Api::V1::FactValuesControllerTest < ActionController::TestCase
- def setup
- @host = FactoryBot.create(:host)
- FactoryBot.create(:fact_value, :value => '2.6.9',:host => @host,
- :fact_name => FactoryBot.create(:fact_name, :name => 'kernelversion'))
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- fact_values = ActiveSupport::JSON.decode(@response.body)
- refute_empty fact_values
- end
-
- test "should get facts for given host only" do
- get :index, {:host_id => @host.name }
- assert_response :success
- fact_values = ActiveSupport::JSON.decode(@response.body)
- expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
- assert_equal expected_hash, fact_values
- end
-
- test "should get facts for given host id" do
- get :index, {:host_id => @host.id }
- assert_response :success
- fact_values = ActiveSupport::JSON.decode(@response.body)
- expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
- assert_equal expected_hash, fact_values
- end
-
- test "should get facts as non-admin user with joined search" do
- setup_user
- @host.update_attribute(:hostgroup, FactoryBot.create(:hostgroup))
- as_user(users(:one)) do
- get :index, {:search => "host.hostgroup = #{@host.hostgroup.name}"}
- end
- assert_response :success
- fact_values = ActiveSupport::JSON.decode(@response.body)
- expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
- assert_equal expected_hash, fact_values
- end
-
- private
-
- def setup_user
- @request.session[:user] = users(:one).id
- users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
- end
-end
diff --git a/test/controllers/api/v1/home_controller_test.rb b/test/controllers/api/v1/home_controller_test.rb
deleted file mode 100644
index 4f2b4cebabdc..000000000000
--- a/test/controllers/api/v1/home_controller_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class Api::V1::HomeControllerTest < ActionController::TestCase
- test "should get index" do
- get :index, { }
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/hostgroups_controller_test.rb b/test/controllers/api/v1/hostgroups_controller_test.rb
deleted file mode 100644
index 451d3530be0f..000000000000
--- a/test/controllers/api/v1/hostgroups_controller_test.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'test_helper'
-require 'controllers/shared/pxe_loader_test'
-
-class Api::V1::HostgroupsControllerTest < ActionController::TestCase
- include ::PxeLoaderTest
-
- def basic_attrs
- {
- :architecture_id => Architecture.find_by_name('x86_64').id,
- :operatingsystem_id => Operatingsystem.find_by_name('Redhat').id
- }
- end
-
- def valid_attrs
- { :name => 'TestHostgroup' }
- end
-
- def valid_attrs_with_root(extra_attrs = {})
- { :hostgroup => valid_attrs.merge(extra_attrs) }
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:hostgroups)
- hostgroups = ActiveSupport::JSON.decode(@response.body)
- assert !hostgroups.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => hostgroups(:common).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create hostgroup" do
- assert_difference('Hostgroup.unscoped.count') do
- post :create, { :hostgroup => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update hostgroup" do
- put :update, { :id => hostgroups(:common).to_param, :hostgroup => valid_attrs }
- assert_response :success
- end
-
- test "should destroy hostgroups" do
- hostgroup = FactoryBot.create(:hostgroup)
- assert_difference('Hostgroup.unscoped.count', -1) do
- delete :destroy, :id => hostgroup
- end
- assert_response :success
- end
-
- test "blocks API deletion of hosts with children" do
- assert hostgroups(:parent).has_children?
- assert_no_difference('Hostgroup.unscoped.count') do
- delete :destroy, { :id => hostgroups(:parent).to_param }
- end
- assert_response :conflict
- end
-
- test "should create nested hostgroup with a parent" do
- assert_difference('Hostgroup.unscoped.count') do
- post :create, { :hostgroup => valid_attrs.merge(:parent_id => hostgroups(:common).id) }
- end
- assert_response :success
- assert_equal hostgroups(:common).id.to_s, Hostgroup.unscoped.order(:id).last.ancestry
- end
-
- test "should update a hostgroup to nested by passing parent_id" do
- put :update, { :id => hostgroups(:db).to_param, :hostgroup => {:parent_id => hostgroups(:common).id} }
- assert_response :success
- assert_equal hostgroups(:common).id.to_s, Hostgroup.unscoped.find_by_name("db").ancestry
- end
-
- private
-
- def last_record
- Hostgroup.unscoped.order(:id).last
- end
-end
diff --git a/test/controllers/api/v1/hosts_controller_test.rb b/test/controllers/api/v1/hosts_controller_test.rb
deleted file mode 100644
index 11905d944742..000000000000
--- a/test/controllers/api/v1/hosts_controller_test.rb
+++ /dev/null
@@ -1,207 +0,0 @@
-require 'test_helper'
-require 'controllers/shared/pxe_loader_test'
-
-class Api::V1::HostsControllerTest < ActionController::TestCase
- include ::PxeLoaderTest
-
- def setup
- @host = FactoryBot.create(:host)
- @ptable = FactoryBot.create(:ptable)
- @ptable.operatingsystems = [ Operatingsystem.find_by_name('Redhat') ]
- end
-
- def basic_attrs
- { :name => 'testhost11',
- :environment_id => environments(:production).id,
- :domain_id => domains(:mydomain).id,
- :ptable_id => @ptable.id,
- :medium_id => media(:one).id,
- :architecture_id => Architecture.find_by_name('x86_64').id,
- :operatingsystem_id => Operatingsystem.find_by_name('Redhat').id,
- :puppet_proxy_id => smart_proxies(:puppetmaster).id,
- :compute_resource_id => compute_resources(:one).id,
- :root_pass => "xybxa6JUkz63w",
- :location_id => taxonomies(:location1).id,
- :organization_id => taxonomies(:organization1).id
- }
- end
-
- def valid_attrs
- net_attrs = {
- :ip => '10.0.0.20',
- :mac => '52:53:00:1e:85:93'
- }
- basic_attrs.merge(net_attrs)
- end
-
- def valid_attrs_with_root(extra_attrs = {})
- { :host => valid_attrs.merge(extra_attrs) }
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:hosts)
- hosts = ActiveSupport::JSON.decode(@response.body)
- assert_not_empty hosts
- end
-
- test "should show individual record" do
- get :show, { :id => @host.to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert_not_empty show_response
- end
-
- test "should create host" do
- disable_orchestration
- assert_difference('Host.count') do
- post :create, { :host => valid_attrs }
- end
- assert_response :success
- end
-
- test "should create host with host_parameters_attributes" do
- disable_orchestration
- Foreman::Deprecation.expects(:api_deprecation_warning).with('Field host_parameters_attributes.nested ignored')
- assert_difference('Host.count') do
- attrs = [{"name" => "compute_resource_id", "value" => "1", "nested" => "true"}]
- post :create, { :host => valid_attrs.merge(:host_parameters_attributes => attrs) }
- end
- assert_response :created
- end
-
- test "should create host with host_parameters_attributes sent in a hash" do
- disable_orchestration
- Foreman::Deprecation.expects(:api_deprecation_warning).with('Field host_parameters_attributes.nested ignored')
- assert_difference('Host.count') do
- attrs = {"0" => {"name" => "compute_resource_id", "value" => "1", "nested" => "true"}}
- post :create, { :host => valid_attrs.merge(:host_parameters_attributes => attrs) }
- end
- assert_response :created
- end
-
- test "should create host with managed is false if parameter is passed" do
- disable_orchestration
- post :create, { :host => valid_attrs.merge!(:managed => false) }
- assert_response :success
- last_host = Host.order('id desc').last
- assert_equal false, last_host.managed?
- end
-
- test "should update host" do
- put :update, { :id => @host.to_param, :host => { :name => 'testhost1435' } }
- assert_response :success
- end
-
- test "should destroy hosts" do
- assert_difference('Host.count', -1) do
- delete :destroy, { :id => @host.to_param }
- end
- assert_response :success
- end
-
- test "should show status hosts" do
- Foreman::Deprecation.expects(:api_deprecation_warning).with(regexp_matches(%r{/status route is deprecated}))
- get :status, { :id => @host.to_param }
- assert_response :success
- end
-
- test "should be able to create hosts even when restricted" do
- disable_orchestration
- assert_difference('Host.count') do
- post :create, { :host => valid_attrs }
- end
- assert_response :success
- end
-
- test "should allow access to restricted user who owns the host" do
- host = FactoryBot.create(:host, :owner => users(:scoped), :organization => taxonomies(:organization1), :location => taxonomies(:location1))
- setup_user 'view', 'hosts', "owner_type = User and owner_id = #{users(:scoped).id}", :scoped
- get :show, { :id => host.to_param }
- assert_response :success
- end
-
- test "should allow to update for restricted user who owns the host" do
- disable_orchestration
- host = FactoryBot.create(:host, :owner => users(:scoped), :organization => taxonomies(:organization1), :location => taxonomies(:location1))
- setup_user 'edit', 'hosts', "owner_type = User and owner_id = #{users(:scoped).id}", :scoped
- put :update, { :id => host.to_param, :host => {:name => 'testhost1435'} }
- assert_response :success
- end
-
- test "should allow destroy for restricted user who owns the hosts" do
- host = FactoryBot.create(:host, :owner => users(:scoped), :organization => taxonomies(:organization1), :location => taxonomies(:location1))
- assert_difference('Host.count', -1) do
- setup_user 'destroy', 'hosts', "owner_type = User and owner_id = #{users(:scoped).id}", :scoped
- delete :destroy, { :id => host.to_param }
- end
- assert_response :success
- end
-
- test "should allow show status for restricted user who owns the hosts" do
- host = FactoryBot.create(:host, :owner => users(:scoped), :organization => taxonomies(:organization1), :location => taxonomies(:location1))
- setup_user 'view', 'hosts', "owner_type = User and owner_id = #{users(:scoped).id}", :scoped
- Foreman::Deprecation.expects(:api_deprecation_warning).with(regexp_matches(%r{/status route is deprecated}))
- get :status, { :id => host.to_param }
- assert_response :success
- end
-
- test "should not allow access to a host out of users hosts scope" do
- setup_user 'view', 'hosts', "owner_type = User and owner_id = #{users(:restricted).id}", :restricted
- get :show, { :id => @host.to_param }
- assert_response :not_found
- end
-
- test "should not list a host out of users hosts scope" do
- host = FactoryBot.create(:host, :owner => users(:scoped), :organization => taxonomies(:organization1), :location => taxonomies(:location1))
- setup_user 'view', 'hosts', "owner_type = User and owner_id = #{users(:scoped).id}", :scoped
- get :index, {}
- assert_response :success
- hosts = ActiveSupport::JSON.decode(@response.body)
- ids = hosts.map { |hash| hash['host']['id'] }
- refute_includes ids, @host.id
- assert_includes ids, host.id
- end
-
- test "should not update host out of users hosts scope" do
- setup_user 'edit', 'hosts', "owner_type = User and owner_id = #{users(:restricted).id}", :restricted
- put :update, { :id => @host.to_param }
- assert_response :not_found
- end
-
- test "should not delete hosts out of users hosts scope" do
- setup_user 'destroy', 'hosts', "owner_type = User and owner_id = #{users(:restricted).id}", :restricted
- delete :destroy, { :id => @host.to_param }
- assert_response :not_found
- end
-
- test "should not show status of hosts out of users hosts scope" do
- setup_user 'view', 'hosts', "owner_type = User and owner_id = #{users(:restricted).id}", :restricted
- get :status, { :id => @host.to_param }
- assert_response :not_found
- end
-
- def set_remote_user_to(user)
- @request.env['REMOTE_USER'] = user.login
- end
-
- test "when REMOTE_USER is provided and both authorize_login_delegation{,_api}
- are set, authentication should succeed w/o valid session cookies" do
- Setting[:authorize_login_delegation] = true
- Setting[:authorize_login_delegation_api] = true
- set_remote_user_to users(:admin)
- User.current = nil # User.current is admin at this point (from initialize_host)
- host = Host.first
- get :show, {:id => host.to_param, :format => 'json'}
- assert_response :success
- get :show, {:id => host.to_param}
- assert_response :success
- end
-
- private
-
- def last_record
- Host.unscoped.order(:id).last
- end
-end
diff --git a/test/controllers/api/v1/images_controller_test.rb b/test/controllers/api/v1/images_controller_test.rb
deleted file mode 100644
index 8fbfff0eed29..000000000000
--- a/test/controllers/api/v1/images_controller_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'test_helper'
-
-class Api::V1::ImagesControllerTest < ActionController::TestCase
- def valid_attrs
- { :name => 'TestImage', :username => 'ec2-user', :uuid => 'abcdef',
- :operatingsystem_id => Operatingsystem.first.id,
- :compute_resource_id => ComputeResource.first.id,
- :architecture_id => Architecture.first.id
- }
- end
-
- test "should get index" do
- get :index, { :compute_resource_id => images(:two).compute_resource_id }
- assert_response :success
- assert_not_nil assigns(:images)
- images = ActiveSupport::JSON.decode(@response.body)
- assert !images.empty?
- end
-
- test "should show individual record" do
- get :show, { :compute_resource_id => images(:two).compute_resource_id, :id => images(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create image" do
- assert_difference('Image.count') do
- post :create, { :compute_resource_id => images(:two).compute_resource_id, :image => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update image" do
- put :update, { :compute_resource_id => images(:two).compute_resource_id, :id => images(:one).to_param, :image => { :name => "testimagegergt"} }
- assert_response :success
- end
-
- test "should destroy images" do
- assert_difference('Image.count', -1) do
- delete :destroy, { :compute_resource_id => images(:two).compute_resource_id, :id => images(:one).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/lookup_keys_controller_test.rb b/test/controllers/api/v1/lookup_keys_controller_test.rb
deleted file mode 100644
index 9d6e0b16eab1..000000000000
--- a/test/controllers/api/v1/lookup_keys_controller_test.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'test_helper'
-
-class Api::V1::LookupKeysControllerTest < ActionController::TestCase
- valid_attrs = { :key => 'testkey' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:lookup_keys)
- lookup_keys = ActiveSupport::JSON.decode(@response.body)
- assert !lookup_keys.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => lookup_keys(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create lookup_key" do
- assert_difference('LookupKey.count') do
- post :create, { :lookup_key => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update lookup_key" do
- put :update, { :id => lookup_keys(:one).to_param, :lookup_key => { :default_value => 8080, :lookup_values => [], :override => true } }
- assert_response :success
- end
-
- test "should not destroy PuppetclassLookupKey" do
- assert_difference('LookupKey.count', 0) do
- delete :destroy, { :id => lookup_keys(:one).to_param }
- end
- assert_response :unprocessable_entity
- assert_match 'Smart class parameters cannot be destroyed', @response.body
- end
-
- test "should destroy VariableLookupKey" do
- assert_difference('LookupKey.count', -1) do
- delete :destroy, { :id => lookup_keys(:two).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/media_controller_test.rb b/test/controllers/api/v1/media_controller_test.rb
deleted file mode 100644
index 175a36f7fa22..000000000000
--- a/test/controllers/api/v1/media_controller_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'test_helper'
-
-class Api::V1::MediaControllerTest < ActionController::TestCase
- new_medium = {
- :name => "new medium",
- :path => "http://www.newmedium.com/"
- }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:media)
- medium = ActiveSupport::JSON.decode(@response.body)
- assert !medium.empty?
- end
-
- test "should show medium" do
- get :show, { :id => media(:one).to_param }
- assert_not_nil assigns(:medium)
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create medium" do
- assert_difference('Medium.unscoped.count', +1) do
- post :create, { :medium => new_medium }
- end
- assert_response :created
- assert_not_nil assigns(:medium)
- end
-
- test "should update medium" do
- name = Medium.first.name
- put :update, { :id => Medium.first.id.to_param, :name => name.to_s.to_param }
- assert_response :success
- end
-
- test "should destroy medium" do
- assert_difference('Medium.unscoped.count', -1) do
- delete :destroy, { :id => media(:unused).id.to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/models_controller_test.rb b/test/controllers/api/v1/models_controller_test.rb
deleted file mode 100644
index 4f6d3082baff..000000000000
--- a/test/controllers/api/v1/models_controller_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'test_helper'
-
-class Api::V1::ModelsControllerTest < ActionController::TestCase
- valid_attrs = { :name => "new model" }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:models)
- end
-
- test "should show model" do
- get :show, { :id => models(:one).to_param }
- assert_not_nil assigns(:model)
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create model" do
- assert_difference('Model.count', +1) do
- post :create, { :model => valid_attrs }
- end
- assert_response :created
- assert_not_nil assigns(:model)
- end
-
- test "should update model" do
- name = Model.first.name
- put :update, { :id => Model.first.to_param, :name => name.to_s.to_param }
- assert_response :success
- end
-
- test "should destroy model" do
- assert_difference('Model.count', -1) do
- delete :destroy, { :id => models(:one).to_param }
- end
- assert_response :success
- end
-
- test "invalid searches are handled gracefully" do
- get :index, { :search => 'notarightterm = wrong' }
- assert_response :bad_request
- end
-end
diff --git a/test/controllers/api/v1/operatingsystems_controller_test.rb b/test/controllers/api/v1/operatingsystems_controller_test.rb
deleted file mode 100644
index c7b825c0f587..000000000000
--- a/test/controllers/api/v1/operatingsystems_controller_test.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'test_helper'
-
-class Api::V1::OperatingsystemsControllerTest < ActionController::TestCase
- os = {
- :name => "awsome_os",
- :major => "1",
- :minor => "2"
- }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:operatingsystems)
- end
-
- test "should show os" do
- get :show, { :id => operatingsystems(:redhat).to_param }
- assert_response :success
- assert_not_nil assigns(:operatingsystem)
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create os" do
- assert_difference('Operatingsystem.count') do
- post :create, { :operatingsystem => os }
- end
- assert_response :success
- assert_not_nil assigns(:operatingsystem)
- end
-
- test "should not create os without version" do
- assert_difference('Operatingsystem.count', 0) do
- post :create, { :operatingsystem => os.except(:major) }
- end
- assert_response :unprocessable_entity
- end
-
- test "should update os" do
- put :update, { :id => operatingsystems(:redhat).to_param, :operatingsystem => { :name => "new_name" } }
- assert_response :success
- end
-
- test "should destroy os" do
- assert_difference('Operatingsystem.count', -1) do
- delete :destroy, { :id => operatingsystems(:no_hosts_os).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/ptables_controller_test.rb b/test/controllers/api/v1/ptables_controller_test.rb
deleted file mode 100644
index 4412172ae97b..000000000000
--- a/test/controllers/api/v1/ptables_controller_test.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'test_helper'
-
-class Api::V1::PtablesControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'ptable_test', :layout => 'd-i partman-auto/disk' }
-
- def setup
- @ptable = FactoryBot.create(:ptable)
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:ptables)
- ptables = ActiveSupport::JSON.decode(@response.body)
- assert !ptables.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => @ptable.to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create ptable" do
- assert_difference('Ptable.unscoped.count') do
- post :create, { :ptable => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update ptable" do
- put :update, { :id => @ptable.to_param, :ptable => valid_attrs }
- assert_response :success
- end
-
- test "should NOT destroy ptable in use" do
- FactoryBot.create(:host, :ptable_id => @ptable.id)
-
- assert_difference('Ptable.unscoped.count', -0) do
- delete :destroy, { :id => @ptable.to_param }
- end
- assert_response :unprocessable_entity
- end
-
- test "should destroy ptable that is NOT in use" do
- assert_difference('Ptable.unscoped.count', -1) do
- delete :destroy, { :id => @ptable.to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/puppetclasses_controller_test.rb b/test/controllers/api/v1/puppetclasses_controller_test.rb
deleted file mode 100644
index f59a9e3a371c..000000000000
--- a/test/controllers/api/v1/puppetclasses_controller_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'test_helper'
-
-class Api::V1::PuppetclassesControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'test_puppetclass' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- puppetclasses = ActiveSupport::JSON.decode(@response.body)
- assert !puppetclasses.empty?
- end
-
- test "should create puppetclass" do
- assert_difference('Puppetclass.count') do
- post :create, { :puppetclass => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update puppetclass" do
- put :update, { :id => puppetclasses(:one).to_param, :puppetclass => valid_attrs }
- assert_response :success
- end
-
- test "should destroy puppetclasss" do
- HostClass.delete_all
- HostgroupClass.delete_all
- assert_difference('Puppetclass.count', -1) do
- delete :destroy, { :id => puppetclasses(:one).to_param }
- end
- assert_response :success
- end
-
- test "should get puppetclasses for given host only" do
- host1 = FactoryBot.create(:host, :with_puppetclass)
- FactoryBot.create(:host, :with_puppetclass)
- get :index, {:host_id => host1.to_param }
- assert_response :success
- puppetclasses = ActiveSupport::JSON.decode(@response.body)
- assert_equal host1.puppetclasses.map(&:name).sort, puppetclasses.keys.sort
- end
-
- test "should not get puppetclasses for nonexistent host" do
- get :index, {"search" => "host = imaginaryhost.nodomain.what" }
- assert_response :success
- fact_values = ActiveSupport::JSON.decode(@response.body)
- assert fact_values.empty?
- end
-end
diff --git a/test/controllers/api/v1/reports_controller_test.rb b/test/controllers/api/v1/reports_controller_test.rb
deleted file mode 100644
index c37cab90927b..000000000000
--- a/test/controllers/api/v1/reports_controller_test.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-require 'test_helper'
-require 'controllers/shared/report_host_permissions_test'
-
-class Api::V1::ReportsControllerTest < ActionController::TestCase
- include ::ReportHostPermissionsTest
-
- setup do
- Foreman::Deprecation.expects(:api_deprecation_warning).with('Reports were renamed to ConfigReports')
- end
-
- test "should get index" do
- FactoryBot.create(:report)
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:reports)
- reports = ActiveSupport::JSON.decode(@response.body)
- assert !reports.empty?
- end
-
- test "should show individual record" do
- report = FactoryBot.create(:report)
- get :show, { :id => report.to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should destroy report" do
- report = FactoryBot.create(:report)
- assert_difference('Report.count', -1) do
- delete :destroy, { :id => report.to_param }
- end
- assert_response :success
- refute Report.find_by_id(report.id)
- end
-
- test "should get reports for given host only" do
- report = FactoryBot.create(:report)
- get :index, {:host_id => report.host.to_param }
- assert_response :success
- assert_not_nil assigns(:reports)
- reports = ActiveSupport::JSON.decode(@response.body)
- assert !reports.empty?
- assert_equal 1, reports.count
- end
-
- test "should return empty result for host with no reports" do
- host = FactoryBot.create(:host)
- get :index, {:host_id => host.to_param }
- assert_response :success
- assert_not_nil assigns(:reports)
- reports = ActiveSupport::JSON.decode(@response.body)
- assert reports.empty?
- assert_equal 0, reports.count
- end
-
- test "should get last report" do
- reports = FactoryBot.create_list(:config_report, 5)
- get :last
- assert_response :success
- assert_not_nil assigns(:report)
- report = ActiveSupport::JSON.decode(@response.body)
- assert !report.empty?
- assert_equal reports.last, Report.find(report['report']['id'])
- end
-
- test "should get last report for given host only" do
- main_report = FactoryBot.create(:config_report)
- FactoryBot.create_list(:report, 5)
- get :last, {:host_id => main_report.host.to_param }
- assert_response :success
- assert_not_nil assigns(:report)
- report = ActiveSupport::JSON.decode(@response.body)
- assert !report.empty?
- assert_equal main_report, Report.find(report['report']['id'])
- end
-
- test "should give error if no last report for given host" do
- host = FactoryBot.create(:host)
- get :last, {:host_id => host.to_param }
- assert_response :not_found
- end
-
- test 'cannot view the last report without hosts view permission' do
- report = FactoryBot.create(:report)
- setup_user('view', 'config_reports')
- get :last, { :host_id => report.host.id }, set_session_user.merge(:user => User.current.id)
- assert_response :not_found
- end
-end
diff --git a/test/controllers/api/v1/roles_controller_test.rb b/test/controllers/api/v1/roles_controller_test.rb
deleted file mode 100644
index 041d7d356be3..000000000000
--- a/test/controllers/api/v1/roles_controller_test.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'test_helper'
-
-class Api::V1::RolesControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'staff' }
-
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:roles)
- roles = ActiveSupport::JSON.decode(@response.body)
- assert !roles.empty?
- assert_equal Role.order(:name).pluck(:name), roles.map { |r| r['role']['name'] }
- end
-
- test "should show individual record" do
- get :show, { :id => roles(:manager).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create role" do
- assert_difference('Role.count') do
- post :create, { :role => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update role" do
- put :update, { :id => roles(:destroy_hosts).to_param, :role => valid_attrs }
- assert_response :success
- end
-
- test "should destroy roles" do
- assert_difference('Role.count', -1) do
- delete :destroy, { :id => roles(:destroy_hosts).to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/settings_controller_test.rb b/test/controllers/api/v1/settings_controller_test.rb
deleted file mode 100644
index d709d2221256..000000000000
--- a/test/controllers/api/v1/settings_controller_test.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'test_helper'
-
-class Api::V1::SettingsControllerTest < ActionController::TestCase
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:settings)
- settings = ActiveSupport::JSON.decode(@response.body)
- assert !settings.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => settings(:attributes1).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should update setting" do
- put :update, { :id => settings(:attributes10).to_param, :setting => { } }
- assert_response :success
- end
-
- test "should parse string values" do
- setting_id = Setting.where(:settings_type => 'integer').first.id
- put :update, { :id => setting_id, :setting => { :value => "100" } }
- assert_response :success
- assert_equal 100, Setting.find(setting_id).value
- end
-
- test "settings shouldnt include ones about organizations when organizations are disabled" do
- SETTINGS[:organizations_enabled] = false
- get :index, { }
- assert_response :success
- assert_no_match /default_organization/, @response.body
- assert_no_match /organization_fact/, @response.body
- SETTINGS[:organizations_enabled] = true
- end
-
- test "settings shouldnt include ones about locations when locations are disabled" do
- SETTINGS[:locations_enabled] = false
- get :index, { }
- assert_response :success
- assert_no_match /default_location/, @response.body
- assert_no_match /location_fact/, @response.body
- SETTINGS[:locations_enabled] = true
- end
-end
diff --git a/test/controllers/api/v1/smart_proxies_controller_test.rb b/test/controllers/api/v1/smart_proxies_controller_test.rb
deleted file mode 100644
index f0c07c9c687a..000000000000
--- a/test/controllers/api/v1/smart_proxies_controller_test.rb
+++ /dev/null
@@ -1,199 +0,0 @@
-require 'test_helper'
-require 'controllers/shared/smart_proxies_controller_shared_test'
-
-class Api::V1::SmartProxiesControllerTest < ActionController::TestCase
- valid_attrs = { :name => 'master02', :url => 'http://server:8443' }
- include SmartProxiesControllerSharedTest
-
- setup do
- ProxyAPI::Features.any_instance.stubs(:features => Feature.name_map.keys)
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:smart_proxies)
- smart_proxies = ActiveSupport::JSON.decode(@response.body)
- assert_not smart_proxies.empty?
- end
-
- test "should get index filtered by type" do
- as_user :admin do
- get :index, { :type => 'TFTP' }
- end
- assert_response :success
- assert_not_nil assigns(:smart_proxies)
- smart_proxies = ActiveSupport::JSON.decode(@response.body)
- assert_not smart_proxies.empty?
-
- returned_proxy_ids = smart_proxies.map { |p| p["smart_proxy"]["id"] }
- expected_proxy_ids = SmartProxy.with_features("TFTP").map { |p| p.id }
- assert returned_proxy_ids == expected_proxy_ids
- end
-
- test "index should fail with invalid type filter" do
- as_user :admin do
- get :index, { :type => 'unknown_type' }
- end
- assert_response :error
- end
-
- test "should show individual record" do
- get :show, { :id => smart_proxies(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert_not show_response.empty?
- end
-
- test "should create smart_proxy" do
- assert_difference('SmartProxy.unscoped.count') do
- post :create, { :smart_proxy => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update smart_proxy" do
- put :update, { :id => smart_proxies(:one).to_param, :smart_proxy => valid_attrs }
- assert_response :success
- end
-
- test "should destroy smart_proxy" do
- assert_difference('SmartProxy.unscoped.count', -1) do
- delete :destroy, { :id => smart_proxies(:four).to_param }
- end
- assert_response :success
- end
-
- # Pending - failure on .permission_failed?
- # test "should not destroy smart_proxy that is in use" do
- # as_user :admin do
- # assert_difference('SmartProxy.count', 0) do
- # delete :destroy, {:id => smart_proxies(:one).to_param}
- # end
- # end
- # assert_response :unprocessable_entity
- # end
-
- test "should refresh smart proxy features" do
- proxy = smart_proxies(:one)
- SmartProxy.any_instance.stubs(:associate_features).returns(true)
- post :refresh, {:id => proxy}
- assert_response :success
- end
-
- test "should return errors during smart proxy refresh" do
- proxy = smart_proxies(:one)
- errors = ActiveModel::Errors.new(Host::Managed.new)
- errors.add :base, "Unable to communicate with the proxy: it's down"
- SmartProxy.any_instance.stubs(:errors).returns(errors)
- SmartProxy.any_instance.stubs(:associate_features).returns(true)
- post :refresh, {:id => proxy}, set_session_user
- assert_response :unprocessable_entity
- end
-
- # puppetmaster proxy - import_puppetclasses tests
-
- test "should import new environments" do
- setup_import_classes
- as_admin do
- Host::Managed.update_all(:environment_id => nil)
- Hostgroup.update_all(:environment_id => nil)
- Puppetclass.destroy_all
- Environment.destroy_all
- end
- assert_difference('Environment.unscoped.count', 2) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id}, set_session_user
- end
- assert_response :success
- response = ActiveSupport::JSON.decode(@response.body)
- assert_equal 2, response['environments_with_new_puppetclasses']
- end
-
- [{}, { :dryrun => false }, { :dryrun => 'false' }].each do |dryrun_param|
- test "should import new puppetclasses" do
- setup_import_classes
- as_admin do
- Host::Managed.update_all(:environment_id => nil)
- Hostgroup.update_all(:environment_id => nil)
- Puppetclass.destroy_all
- Environment.destroy_all
- assert_difference('Puppetclass.unscoped.count', 1) do
- post :import_puppetclasses,
- { :id => smart_proxies(:puppetmaster).id }.merge(dryrun_param),
- set_session_user
- end
- end
- assert_response :success
- end
- end
-
- test "should not import new puppetclasses when dryrun" do
- setup_import_classes
- as_admin do
- Host::Managed.update_all(:environment_id => nil)
- Hostgroup.update_all(:environment_id => nil)
- Puppetclass.destroy_all
- Environment.destroy_all
- assert_difference('Puppetclass.unscoped.count', 0) do
- post :import_puppetclasses, { :id => smart_proxies(:puppetmaster).id, :dryrun => true }, set_session_user
- end
- end
- assert_response :success
- end
-
- test "should obsolete environment" do
- setup_import_classes
- as_admin do
- Environment.create!(:name => 'xyz')
- end
- assert_difference('Environment.unscoped.count', -1) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id}, set_session_user
- end
- assert_response :success
- end
-
- test "should obsolete puppetclasses" do
- setup_import_classes
- as_admin do
- assert_difference('Environment.unscoped.find_by_name("env1").puppetclasses.count', -2) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id}, set_session_user
- end
- end
- assert_response :success
- end
-
- test "should update puppetclass smart class parameters" do
- setup_import_classes
- LookupKey.destroy_all
- assert_difference('LookupKey.unscoped.count', 1) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id}, set_session_user
- end
- assert_response :success
- end
-
- test "no changes on import_puppetclasses" do
- setup_import_classes
- Puppetclass.find_by_name('b').destroy
- Puppetclass.find_by_name('c').destroy
- assert_difference('Environment.unscoped.count', 0) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id}, set_session_user
- end
- assert_response :success
- response = ActiveSupport::JSON.decode(@response.body)
- assert_equal 'Successfully updated environment and puppetclasses from the on-disk puppet installation', response['message']
- end
-
- test "should import new environment that does not exist in db" do
- setup_import_classes
- as_admin do
- env_name = 'env1'
- assert Environment.find_by_name(env_name).destroy
- assert_difference('Environment.unscoped.count', 1) do
- post :import_puppetclasses, {:id => smart_proxies(:puppetmaster).id, :environment_id => env_name}, set_session_user
- end
- assert_response :success
- response = ActiveSupport::JSON.decode(@response.body)
- assert_equal env_name, response['results']['name']
- end
- end
-end
diff --git a/test/controllers/api/v1/statistics_controller_test.rb b/test/controllers/api/v1/statistics_controller_test.rb
deleted file mode 100644
index 94d78b8187c4..000000000000
--- a/test/controllers/api/v1/statistics_controller_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'test_helper'
-
-class Api::V1::StatisticsControllerTest < ActionController::TestCase
- test "should get statistics" do
- get :index, { }
- assert_response :success
- response = ActiveSupport::JSON.decode(@response.body)
- assert_not response.empty?
- expected_keys = ["arch_count", "cpu_count", "env_count", "klass_count",
- "mem_free", "mem_size", "mem_totfree", "mem_totsize",
- "model_count", "os_count", "swap_free", "swap_size"]
-
- assert_equal expected_keys, response.keys.sort
- end
-end
diff --git a/test/controllers/api/v1/subnets_controller_test.rb b/test/controllers/api/v1/subnets_controller_test.rb
deleted file mode 100644
index fa61574a1a8c..000000000000
--- a/test/controllers/api/v1/subnets_controller_test.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require 'test_helper'
-
-class Api::V1::SubnetsControllerTest < ActionController::TestCase
- valid_v4_attrs = { :name => 'QA2', :network_type => 'IPv4', :network => '10.35.2.27', :mask => '255.255.255.0' }
- valid_v6_attrs = { :name => 'QA2', :network_type => 'IPv6', :network => '2001:db8::', :mask => 'ffff:ffff:ffff:ffff::', :ipam => 'None' }
-
- def test_index
- get :index
- subnets = ActiveSupport::JSON.decode(@response.body)
- assert subnets.is_a?(Array)
- assert_response :success
- assert !subnets.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => subnets(:one).to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create IPv4 subnet" do
- assert_difference('Subnet::Ipv4.unscoped.count') do
- post :create, { :subnet => valid_v4_attrs }
- end
- assert_response :success
- assert_equal 'Subnet::Ipv4', Subnet.unscoped.find_by_name('QA2').type
- end
-
- test "should create IPv6 subnet" do
- assert_difference('Subnet::Ipv6.unscoped.count') do
- post :create, { :subnet => valid_v6_attrs }
- end
- assert_response :success
- assert_equal 'Subnet::Ipv6', Subnet.unscoped.find_by_name('QA2').type
- end
-
- test "does not create subnet with non-existent domain" do
- post :create, { :subnet => valid_v4_attrs.merge(:domain_ids => [1, 2]) }
- assert_response :not_found
- end
-
- test "should update subnet" do
- put :update, { :id => subnets(:one).to_param, :subnet => valid_v4_attrs }
- assert_response :success
- end
-
- test "should destroy subnets" do
- assert_difference('Subnet.unscoped.count', -1) do
- delete :destroy, { :id => subnets(:four).to_param }
- end
- assert_response :success
- end
-
- test "should NOT destroy subnet that is in use" do
- assert_difference('Subnet.unscoped.count', 0) do
- delete :destroy, { :id => subnets(:one).to_param }
- end
- assert_response :unprocessable_entity
- end
-
- def test_destroy_json
- subnet = Subnet.first
- subnet.hosts.clear
- subnet.interfaces.clear
- subnet.domains.clear
- as_admin { delete :destroy, {:id => subnet.id} }
- ActiveSupport::JSON.decode(@response.body)
- assert_response :ok
- assert !Subnet.exists?(:id => subnet.id)
- end
-end
diff --git a/test/controllers/api/v1/template_kinds_controller_test.rb b/test/controllers/api/v1/template_kinds_controller_test.rb
deleted file mode 100644
index 928dfb148104..000000000000
--- a/test/controllers/api/v1/template_kinds_controller_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test_helper'
-
-class Api::V1::TemplateKindsControllerTest < ActionController::TestCase
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:template_kinds)
- template_kinds = ActiveSupport::JSON.decode(@response.body)
- assert !template_kinds.empty?
- end
-end
diff --git a/test/controllers/api/v1/usergroups_controller_test.rb b/test/controllers/api/v1/usergroups_controller_test.rb
deleted file mode 100644
index 1943f1238c6a..000000000000
--- a/test/controllers/api/v1/usergroups_controller_test.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'test_helper'
-
-class Api::V1::UsergroupsControllerTest < ActionController::TestCase
- def setup
- as_admin { @usergroup = FactoryBot.create(:usergroup) }
- end
-
- valid_attrs = { :name => 'test_usergroup' }
-
- test "should get index" do
- get :index, { }
- assert_response :success
- assert_not_nil assigns(:usergroups)
- usergroups = ActiveSupport::JSON.decode(@response.body)
- assert !usergroups.empty?
- end
-
- test "should show individual record" do
- get :show, { :id => @usergroup.to_param }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert !show_response.empty?
- end
-
- test "should create usergroup" do
- assert_difference('Usergroup.count') do
- post :create, { :usergroup => valid_attrs }
- end
- assert_response :success
- end
-
- test "should update usergroup" do
- put :update, { :id => @usergroup.to_param, :usergroup => valid_attrs }
- assert_response :success
- end
-
- test "should destroy usergroups" do
- assert_difference('Usergroup.count', -1) do
- delete :destroy, { :id => @usergroup.to_param }
- end
- assert_response :success
- end
-end
diff --git a/test/controllers/api/v1/users_controller_test.rb b/test/controllers/api/v1/users_controller_test.rb
deleted file mode 100644
index 72cbeca4a6ae..000000000000
--- a/test/controllers/api/v1/users_controller_test.rb
+++ /dev/null
@@ -1,195 +0,0 @@
-require 'test_helper'
-
-class Api::V1::UsersControllerTest < ActionController::TestCase
- valid_attrs = { :firstname => "johnsmith" }
-
- def setup
- setup_users
- end
-
- test "should get index" do
- get :index, { }
- assert_response :success
- end
-
- test "should show individual record by ID" do
- get :show, { :id => users(:one).id }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert_not show_response.empty?
- end
-
- test "should show individual record by login name" do
- get :show, { :id => users(:one).login }
- assert_response :success
- show_response = ActiveSupport::JSON.decode(@response.body)
- assert_not show_response.empty?
- end
-
- test "should update user" do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
- put :update, { :id => user.id, :user => valid_attrs }
- assert_response :success
-
- mod_user = User.unscoped.find_by_id(user.id)
- assert mod_user.firstname == "johnsmith"
- end
-
- test "should update admin flag" do
- user = users(:one)
- put :update, { :id => user.id, :user => { :admin => true } }
-
- assert_response :success
- assert User.unscoped.find_by_id(user.id).admin?
- end
-
- test "should not remove the default role" do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
-
- assert user.roles =([roles(:default_role)])
-
- put :update, { :id => user.id, :user => valid_attrs }
- assert_response :success
-
- mod_user = User.unscoped.find_by_id(user.id)
-
- assert mod_user.roles =([roles(:default_role)])
- end
-
- test "should set password" do
- user = User.new :login => "foo", :mail => "foo@bar.com", :firstname => "john", :lastname => "smith", :auth_source => auth_sources(:internal)
- user.password = "changeme"
- assert user.save
-
- put :update, { :id => user.id, :user => { :login => "johnsmith", :password => "dummy", :password_confirmation => "dummy" } }
- assert_response :success
-
- mod_user = User.unscoped.find_by_id(user.id)
- assert mod_user.matching_password?("dummy")
- end
-
- test "should detect password validation mismatches" do
- user = User.new :login => "foo", :mail => "foo@bar.com", :firstname => "john", :lastname => "smith", :auth_source => auth_sources(:internal)
- user.password = "changeme"
- assert user.save
-
- put :update, { :id => user.id, :user => { :login => "johnsmith", :password => "dummy", :password_confirmation => "DUMMY" } }
- assert_response :unprocessable_entity
-
- mod_user = User.unscoped.find_by_id(user.id)
- assert mod_user.matching_password?("changeme")
- end
-
- test "should delete different user" do
- user = users(:one)
-
- delete :destroy, { :id => user.id }
- assert_response :success
-
- refute User.unscoped.exists?(user.id)
- end
-
- test "should not delete same user" do
- user = users(:one)
- user.update_attribute :admin, true
-
- as_user :one do
- delete :destroy, { :id => user.id }
- assert_response :forbidden
-
- response = ActiveSupport::JSON.decode(@response.body)
- assert response['details'] == "You are trying to delete your own account"
- assert response['message'] == "Access denied"
- assert User.unscoped.exists?(user.id)
- end
- end
-
- def user_one_as_anonymous_viewer
- users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
- end
-
- test 'user with viewer rights should fail to edit a user' do
- user_one_as_anonymous_viewer
- user = nil
- as_user :admin do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
- user.save
- end
- as_user :one do
- put :update, { :id => user.id, :user => { :login => "johnsmith" } }
- assert_response :forbidden
- end
- end
-
- test 'user with viewer rights should succeed in viewing users' do
- user_one_as_anonymous_viewer
- as_user :one do
- get :index
- assert_response :success
- end
- end
-
- test 'admin user can be created' do
- user = users(:one)
- user.update_attribute :admin, true
-
- as_user :one do
- post :create, { :user => {
- :admin => true, :login => 'new_admin', :auth_source_id => auth_sources(:one).id }
- }
- assert_response :success
- assert User.unscoped.find_by_login('new_admin').admin?
- end
- end
-
- test "#index should not show hidden users" do
- get :index, { :search => "login == #{users(:anonymous).login}" }
- results = ActiveSupport::JSON.decode(@response.body)
- assert results.empty?, results.inspect
- end
-
- test "#find_resource should not return hidden users" do
- get :show, { :id => users(:anonymous).id }
- assert_response :not_found
- end
-
- test "#show should not allow displaying other users without proper permission" do
- as_user :two do
- get :show, { :id => users(:one).id }
- end
- assert_response :forbidden
- end
-
- test "#show should allow displaying myself without any special permissions" do
- as_user :two do
- get :show, { :id => users(:two).id }
- end
- assert_response :success
- end
-
- test "#update should not update other users without proper permission" do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
- as_user :two do
- put :update, { :id => user.id, :user => valid_attrs }
- end
- assert_response :forbidden
- end
-
- test "#update should allow updating myself without any special permissions" do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
- as_user user do
- put :update, { :id => user.id, :user => valid_attrs }
- end
- assert_response :success
- end
-
- test '#update should not be editing User.current' do
- user = User.create :login => "foo", :mail => "foo@bar.com", :auth_source => auth_sources(:one)
- as_user user do
- put :update, { :id => user.id, :user => valid_attrs }
- end
- assert_equal user, assigns(:user)
- refute_equal user.object_id, assigns(:user).object_id
- assert_response :success
- end
-end
diff --git a/test/integration/api_routing_test.rb b/test/integration/api_routing_test.rb
index 65db778938f8..6152ae1f26ef 100644
--- a/test/integration/api_routing_test.rb
+++ b/test/integration/api_routing_test.rb
@@ -1,10 +1,6 @@
require 'integration_test_helper'
class RoutingIntegrationTest < ActionDispatch::IntegrationTest
- test "should go to v1 controller for /v1/ passed in URL" do
- assert_recognizes({:controller => "api/v1/domains", :action => "index", :apiv => "v1", :format => "json"}, "/api/v1/domains")
- end
-
test "should go to v2 controller for /v2 passed in URL" do
assert_recognizes({:controller => "api/v2/domains", :action => "index", :apiv => "v2", :format => "json"}, "/api/v2/domains")
end