foreman_puppet 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +61 -7
- data/app/controllers/concerns/foreman_puppet/environments_import.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb +28 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +3 -10
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +2 -2
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +5 -2
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/{base_controller.rb → puppet_base_controller.rb} +3 -4
- data/app/controllers/foreman_puppet/api/v2/{lookups_common_controller.rb → puppet_lookups_common_controller.rb} +6 -2
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +1 -2
- data/app/controllers/foreman_puppet/config_groups_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +2 -2
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +12 -4
- data/app/graphgl/concerns/foreman_puppet/mutations/hosts/create_extensions.rb +29 -0
- data/app/graphgl/concerns/foreman_puppet/types/host_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/hostgroup_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/interface_attributes_input_extensions.rb +9 -0
- data/app/graphgl/concerns/foreman_puppet/types/location_extensions.rb +14 -0
- data/app/graphgl/concerns/foreman_puppet/types/organization_extensions.rb +14 -0
- data/app/graphgl/foreman_puppet/types/environment.rb +20 -0
- data/app/graphgl/foreman_puppet/types/puppetclass.rb +20 -0
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_helper.rb +15 -0
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +2 -2
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +2 -2
- data/app/models/concerns/foreman_puppet/extensions/host.rb +24 -9
- data/app/models/concerns/foreman_puppet/extensions/host_common.rb +17 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +13 -7
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +19 -13
- data/app/models/concerns/foreman_puppet/extensions/report.rb +18 -0
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/user.rb +19 -12
- data/app/models/foreman_puppet/environment.rb +2 -0
- data/app/models/foreman_puppet/environment_class.rb +1 -1
- data/app/models/foreman_puppet/host_class.rb +1 -1
- data/app/models/foreman_puppet/host_puppet_facet.rb +6 -5
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +1 -1
- data/app/models/{concerns/foreman_puppet/host_common.rb → foreman_puppet/puppet_facet_common.rb} +1 -1
- data/app/models/foreman_puppet/puppetclass.rb +15 -1
- data/app/{views/api/v2/template_combinations/base.json.erb → prepend_views/api/v2/template_combinations/base.json.rabl} +0 -0
- data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +2 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +17 -18
- data/app/views/foreman_puppet/common/_puppetclasses_or_envs_changed.html.erb +62 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +2 -2
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -11
- data/app/views/foreman_puppet/environments/index.html.erb +1 -1
- data/app/views/foreman_puppet/environments/welcome.html.erb +3 -15
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +10 -8
- data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/index.html.erb +1 -1
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +1 -1
- data/app/views/hosts/select_multiple_environment.html.erb +1 -1
- data/app/views/smart_proxies/plugins/_puppet_ca.html.erb +44 -0
- data/config/initializers/api_reroute.rb +13 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +37 -12
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +13 -1
- data/lib/foreman_puppet/engine.rb +68 -20
- data/lib/foreman_puppet/register.rb +7 -2
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +3 -3
- data/locale/Makefile +1 -1
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.edit.po +19 -3
- data/locale/en/foreman_puppet.po +18 -6
- data/locale/en/foreman_puppet.pox +0 -0
- data/locale/foreman_puppet.pot +19 -3
- data/locale/messages.mo +0 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +18 -16
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +3 -2
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb +32 -0
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +3 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +7 -1
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/environments_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +5 -6
- data/test/factories/foreman_puppet_factories.rb +3 -0
- data/test/factories/host_puppet_enhancements.rb +6 -6
- data/test/graphql/mutations/hosts/create_mutation_test.rb +87 -0
- data/test/graphql/queries/environment_query_test.rb +54 -0
- data/test/graphql/queries/environments_query_test.rb +43 -0
- data/test/{qraphql → graphql}/queries/host_puppet_query_test.rb +3 -8
- data/test/{qraphql → graphql}/queries/hostgroup_puppet_query_test.rb +1 -6
- data/test/graphql/queries/location_query_test.rb +52 -0
- data/test/graphql/queries/organization_query_test.rb +52 -0
- data/test/graphql/queries/puppetclass_query_test.rb +68 -0
- data/test/graphql/queries/puppetclasses_query_test.rb +43 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +4 -1
- data/test/integration/foreman_puppet/host_js_test.rb +1 -1
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +4 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +3 -1
- data/test/models/foreman_puppet/environment_test.rb +2 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +34 -1
- data/test/models/foreman_puppet/host_test.rb +4 -3
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
- data/test/models/foreman_puppet/provisioning_template_test.rb +14 -7
- data/test/models/foreman_puppet/report_test.rb +21 -0
- data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +37 -0
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +35 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +159 -197
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +16 -2
- data/webpack/index.js +3 -4
- data/webpack/src/Components/Environments/Welcome.js +37 -0
- metadata +51 -12
|
@@ -2,6 +2,8 @@ require 'test_puppet_helper'
|
|
|
2
2
|
|
|
3
3
|
module ForemanPuppet
|
|
4
4
|
class EnvironmentTest < ActiveSupport::TestCase
|
|
5
|
+
setup { FactoryBot.create(:environment) }
|
|
6
|
+
|
|
5
7
|
should validate_presence_of(:name)
|
|
6
8
|
should validate_uniqueness_of(:name)
|
|
7
9
|
should have_many(:provisioning_templates).through(:template_combinations)
|
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
require 'test_puppet_helper'
|
|
2
2
|
|
|
3
3
|
module ForemanPuppet
|
|
4
|
-
class
|
|
4
|
+
class HostPuppetFacetTest < ActiveSupport::TestCase
|
|
5
5
|
let(:environment) { FactoryBot.create(:environment) }
|
|
6
6
|
let(:diff_environment) { FactoryBot.create(:environment) }
|
|
7
7
|
let(:puppetclass_both) { FactoryBot.create(:puppetclass, environments: [environment, diff_environment]) }
|
|
8
8
|
let(:config_group) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [environment]) }
|
|
9
9
|
let(:config_group_diff_env) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [diff_environment]) }
|
|
10
10
|
|
|
11
|
+
describe '.populate_fields_from_facts' do
|
|
12
|
+
test 'populate environment without any puppet info' do
|
|
13
|
+
h = FactoryBot.create(:host)
|
|
14
|
+
parser = stub(environment: environment)
|
|
15
|
+
HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
|
|
16
|
+
assert_equal environment, h.puppet.environment
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test 'changes puppet environment when setting says to do so' do
|
|
20
|
+
Setting[:update_environment_from_facts] = true
|
|
21
|
+
h = FactoryBot.create(:host, :with_puppet_enc)
|
|
22
|
+
parser = stub(environment: environment)
|
|
23
|
+
HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
|
|
24
|
+
assert_equal environment, h.puppet.environment
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test 'keep puppet environment when parser has empty environment' do
|
|
28
|
+
Setting[:update_environment_from_facts] = true
|
|
29
|
+
h = FactoryBot.create(:host, :with_puppet_enc)
|
|
30
|
+
parser = stub(environment: nil)
|
|
31
|
+
HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
|
|
32
|
+
assert_not_nil h.puppet.environment
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test 'do not update puppet environment when setting says not to' do
|
|
36
|
+
Setting[:update_environment_from_facts] = false
|
|
37
|
+
h = FactoryBot.create(:host, :with_puppet_enc)
|
|
38
|
+
parser = stub(environment: environment)
|
|
39
|
+
HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
|
|
40
|
+
assert_not_equal environment, h.puppet.environment
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
11
44
|
describe '#classes_in_groups' do
|
|
12
45
|
test 'classes_in_groups should return the puppetclasses of a config group only if it is in host environment' do
|
|
13
46
|
host = FactoryBot.create(:host, :with_puppet_enc,
|
|
@@ -79,7 +79,7 @@ module ForemanPuppet
|
|
|
79
79
|
|
|
80
80
|
test 'can search hosts by puppet class from config group in parent hostgroup' do
|
|
81
81
|
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc)
|
|
82
|
-
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.environment)
|
|
82
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
|
83
83
|
config_group = FactoryBot.create(:config_group, :with_puppetclass)
|
|
84
84
|
hostgroup.puppet.config_groups << config_group
|
|
85
85
|
result = Host.search_for("class = #{config_group.puppetclass_names.first}")
|
|
@@ -138,7 +138,8 @@ module ForemanPuppet
|
|
|
138
138
|
describe '#clone' do
|
|
139
139
|
test '#classes etc. on cloned host return the same' do
|
|
140
140
|
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_config_group, :with_puppetclass)
|
|
141
|
-
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
|
141
|
+
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
|
142
|
+
hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
|
142
143
|
copy = host.clone
|
|
143
144
|
assert_equal host.puppet.individual_puppetclasses.map(&:id), copy.puppet.individual_puppetclasses.map(&:id)
|
|
144
145
|
assert_equal host.puppet.classes_in_groups.map(&:id), copy.puppet.classes_in_groups.map(&:id)
|
|
@@ -241,7 +242,7 @@ module ForemanPuppet
|
|
|
241
242
|
|
|
242
243
|
host.puppet.environment = env_with_other_tax
|
|
243
244
|
assert_not host.valid?
|
|
244
|
-
assert_match(/is not assigned/, host.errors[
|
|
245
|
+
assert_match(/is not assigned/, host.errors['puppet.environment_id'].first)
|
|
245
246
|
end
|
|
246
247
|
|
|
247
248
|
test 'when saving a host, require puppet environment if puppet master is set' do
|
|
@@ -22,15 +22,14 @@ module ForemanPuppet
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
test 'changing environment should preserve puppetclasses' do
|
|
25
|
-
skip 'Something fishy on env update, try once extracted' unless ForemanPuppet.extracted_from_core?
|
|
26
25
|
new_environment = FactoryBot.create(:environment)
|
|
27
|
-
old_puppetclass_ids = hostgroup.puppet.
|
|
26
|
+
old_puppetclass_ids = hostgroup.puppet.puppetclasses.all
|
|
28
27
|
|
|
29
28
|
hostgroup.puppet.update!(environment: new_environment)
|
|
30
29
|
hostgroup.reload
|
|
31
30
|
|
|
32
31
|
assert_equal new_environment, hostgroup.puppet.environment
|
|
33
|
-
assert_equal old_puppetclass_ids.sort, hostgroup.puppet.
|
|
32
|
+
assert_equal old_puppetclass_ids.sort, hostgroup.puppet.puppetclasses.all
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
test 'should return all classes for environment only' do
|
|
@@ -37,7 +37,14 @@ module ForemanPuppet
|
|
|
37
37
|
assert_equal [], tmplt.template_combinations
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
test '#template_includes adds environment include' do
|
|
41
|
+
includes = ProvisioningTemplate.template_includes
|
|
42
|
+
tc_include = includes.detect { |i| i.is_a?(Hash) && i.key?(:template_combinations) }
|
|
43
|
+
assert tc_include
|
|
44
|
+
assert_includes tc_include[:template_combinations], :environment
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '#find_template by template_combinations' do
|
|
41
48
|
setup do
|
|
42
49
|
@arch = FactoryBot.create(:architecture)
|
|
43
50
|
medium = FactoryBot.create(:medium, name: 'combo_medium', path: 'http://www.example.com/m')
|
|
@@ -74,7 +81,7 @@ module ForemanPuppet
|
|
|
74
81
|
@ctd.os_default_templates.create(operatingsystem: @os1, template_kind_id: @ctd.template_kind_id)
|
|
75
82
|
end
|
|
76
83
|
|
|
77
|
-
test '
|
|
84
|
+
test 'finds a matching template with hg and env' do
|
|
78
85
|
assert_equal @ct1.name,
|
|
79
86
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
80
87
|
operatingsystem_id: @os1.id,
|
|
@@ -82,14 +89,14 @@ module ForemanPuppet
|
|
|
82
89
|
environment_id: @ev1.id }).name
|
|
83
90
|
end
|
|
84
91
|
|
|
85
|
-
test '
|
|
92
|
+
test 'finds a matching template with hg only' do
|
|
86
93
|
assert_equal @ct2.name,
|
|
87
94
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
88
95
|
operatingsystem_id: @os1.id,
|
|
89
96
|
hostgroup_id: @hg1.id }).name
|
|
90
97
|
end
|
|
91
98
|
|
|
92
|
-
test '
|
|
99
|
+
test 'finds a matching template with hg and mismatched env' do
|
|
93
100
|
assert_equal @ct2.name,
|
|
94
101
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
95
102
|
operatingsystem_id: @os1.id,
|
|
@@ -97,14 +104,14 @@ module ForemanPuppet
|
|
|
97
104
|
environment_id: @ev3.id }).name
|
|
98
105
|
end
|
|
99
106
|
|
|
100
|
-
test '
|
|
107
|
+
test 'finds a matching template with env only' do
|
|
101
108
|
assert_equal @ct3.name,
|
|
102
109
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
103
110
|
operatingsystem_id: @os1.id,
|
|
104
111
|
environment_id: @ev1.id }).name
|
|
105
112
|
end
|
|
106
113
|
|
|
107
|
-
test '
|
|
114
|
+
test 'finds a matching template with env and mismatched hg' do
|
|
108
115
|
assert_equal @ct3.name,
|
|
109
116
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
110
117
|
operatingsystem_id: @os1.id,
|
|
@@ -112,7 +119,7 @@ module ForemanPuppet
|
|
|
112
119
|
environment_id: @ev1.id }).name
|
|
113
120
|
end
|
|
114
121
|
|
|
115
|
-
test '
|
|
122
|
+
test 'finds the default template when hg and env do not match' do
|
|
116
123
|
assert_equal @ctd.name,
|
|
117
124
|
ProvisioningTemplate.find_template({ kind: @tk.name,
|
|
118
125
|
operatingsystem_id: @os1.id,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'test_puppet_helper'
|
|
2
|
+
|
|
3
|
+
module ForemanPuppet
|
|
4
|
+
class TestReport < ::Report
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class ReportTest < ActiveSupport::TestCase
|
|
8
|
+
test 'Inherited children can search by environment' do
|
|
9
|
+
assert_nothing_raised do
|
|
10
|
+
TestReport.search_for('environment = blah')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# to include the environment search
|
|
15
|
+
test 'Inherited children can search' do
|
|
16
|
+
assert_nothing_raised do
|
|
17
|
+
TestReport.search_for('blah')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -17,7 +17,7 @@ module ForemanPuppet
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
test 'can count connected hosts' do
|
|
20
|
-
FactoryBot.create(:host, :with_puppet_enc,
|
|
20
|
+
FactoryBot.create(:host, :with_puppet_enc, puppet_proxy: proxy)
|
|
21
21
|
|
|
22
22
|
as_admin do
|
|
23
23
|
assert_equal 1, proxy.hosts_count
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'test_puppet_helper'
|
|
2
|
+
|
|
3
|
+
module ForemanPuppet
|
|
4
|
+
class UserTest < ActiveSupport::TestCase
|
|
5
|
+
describe '#visible_environments' do
|
|
6
|
+
let(:environment) { FactoryBot.create(:environment) }
|
|
7
|
+
let(:untaxed_env) { FactoryBot.create(:environment, organizations: [], locations: []) }
|
|
8
|
+
let(:env_names) do
|
|
9
|
+
env_names = [environment.name, untaxed_env.name]
|
|
10
|
+
env_names += %w[production global_puppetmaster testing] unless ForemanPuppet.extracted_from_core?
|
|
11
|
+
env_names
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
setup do
|
|
15
|
+
environment
|
|
16
|
+
untaxed_env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# These will need refactor when the environment fixtures will be gone
|
|
20
|
+
test 'should show the list of environments visible as admin user' do
|
|
21
|
+
# Admin user sees all environments - including the ones without taxonomies\
|
|
22
|
+
assert_equal env_names.sort, ::User.current.visible_environments.sort
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test 'should show the list of environments visible as inherited admin user' do
|
|
26
|
+
::User.current = FactoryBot.create(:user, usergroups: [FactoryBot.create(:usergroup, admin: true)]).reload
|
|
27
|
+
assert_same_elements env_names.sort, ::User.current.visible_environments
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test 'should show the list of environments visible as non-admin user' do
|
|
31
|
+
# Non-admin user only sees environments in a taxonomy at least
|
|
32
|
+
setup_user 'view', 'environments'
|
|
33
|
+
assert_equal [environment.name], ::User.current.visible_environments
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'test_puppet_helper'
|
|
2
|
+
|
|
3
|
+
module ForemanPuppet
|
|
4
|
+
class ConfigGroupInfoTest < ActiveSupport::TestCase
|
|
5
|
+
let(:cg_info) { HostInfoProviders::ConfigGroupsInfo.new(host) }
|
|
6
|
+
|
|
7
|
+
context 'with Puppet Host' do
|
|
8
|
+
let(:config_group) { FactoryBot.create(:config_group) }
|
|
9
|
+
let(:host) do
|
|
10
|
+
FactoryBot.build(:host, :with_puppet_enc,
|
|
11
|
+
location: taxonomies(:location1),
|
|
12
|
+
organization: taxonomies(:organization1),
|
|
13
|
+
operatingsystem: operatingsystems(:redhat),
|
|
14
|
+
config_groups: [config_group])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'adds config_groups to host parameters' do
|
|
18
|
+
assert_equal([config_group.name], cg_info.host_info['parameters']['foreman_config_groups'])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context 'without Puppet' do
|
|
23
|
+
let(:host) do
|
|
24
|
+
FactoryBot.build(:host,
|
|
25
|
+
location: taxonomies(:location1),
|
|
26
|
+
organization: taxonomies(:organization1),
|
|
27
|
+
operatingsystem: operatingsystems(:redhat))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'does not fail without puppet facet' do
|
|
31
|
+
assert_equal({}, cg_info.host_info)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -37,9 +37,9 @@ module ForemanPuppet
|
|
|
37
37
|
|
|
38
38
|
value = as_admin do
|
|
39
39
|
LookupValue.create! lookup_key_id: puppetclass_lookup_key.id,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
|
|
41
|
+
value: 'test',
|
|
42
|
+
omit: false
|
|
43
43
|
end
|
|
44
44
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
45
45
|
|
|
@@ -78,19 +78,17 @@ module ForemanPuppet
|
|
|
78
78
|
host = FactoryBot.build_stubbed(:host, :with_puppet_enc, environment: environment, puppetclasses: [puppetclass])
|
|
79
79
|
Classification::MatchesGenerator.any_instance.expects(:attr_to_value).with('comment').returns('override')
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
lkey.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
managed: false,
|
|
89
|
-
},
|
|
81
|
+
expected = {
|
|
82
|
+
lkey.id => {
|
|
83
|
+
lkey.key => {
|
|
84
|
+
value: 'overridden value',
|
|
85
|
+
element: 'comment',
|
|
86
|
+
element_name: 'override',
|
|
87
|
+
managed: false,
|
|
90
88
|
},
|
|
91
89
|
},
|
|
92
|
-
|
|
93
|
-
)
|
|
90
|
+
}
|
|
91
|
+
assert_equal(expected, Classification::ValuesHashQuery.values_hash(host, LookupKey.where(id: [lkey])).raw)
|
|
94
92
|
|
|
95
93
|
Classification::MatchesGenerator.any_instance.unstub(:attr_to_value)
|
|
96
94
|
end
|
|
@@ -108,9 +106,9 @@ module ForemanPuppet
|
|
|
108
106
|
puppetclass: puppetclass, path: "location\ncomment")
|
|
109
107
|
as_admin do
|
|
110
108
|
LookupValue.create! lookup_key_id: lkey.id,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
match: "location=#{taxonomies(:location1)}",
|
|
110
|
+
value: 'test',
|
|
111
|
+
omit: true
|
|
114
112
|
end
|
|
115
113
|
|
|
116
114
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
@@ -124,9 +122,9 @@ module ForemanPuppet
|
|
|
124
122
|
path: "location\ncomment")
|
|
125
123
|
lvalue = as_admin do
|
|
126
124
|
LookupValue.create! lookup_key_id: lkey.id,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
match: "location=#{taxonomies(:location1)}",
|
|
126
|
+
value: 'test',
|
|
127
|
+
omit: false
|
|
130
128
|
end
|
|
131
129
|
|
|
132
130
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
@@ -142,22 +140,22 @@ module ForemanPuppet
|
|
|
142
140
|
|
|
143
141
|
as_admin do
|
|
144
142
|
LookupValue.create! lookup_key_id: key.id,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
match: "location=#{taxonomies(:location1)}",
|
|
144
|
+
value: { example: { a: 'test' } },
|
|
145
|
+
omit: true
|
|
148
146
|
end
|
|
149
147
|
as_admin do
|
|
150
148
|
LookupValue.create! lookup_key_id: key.id,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
150
|
+
value: { example: { b: 'test2' } },
|
|
151
|
+
omit: true
|
|
154
152
|
end
|
|
155
153
|
|
|
156
154
|
as_admin do
|
|
157
155
|
LookupValue.create! lookup_key_id: key.id,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
match: "os=#{operatingsystems(:redhat)}",
|
|
157
|
+
value: { example: { a: 'test3' } },
|
|
158
|
+
omit: true
|
|
161
159
|
end
|
|
162
160
|
|
|
163
161
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
@@ -166,9 +164,6 @@ module ForemanPuppet
|
|
|
166
164
|
end
|
|
167
165
|
|
|
168
166
|
test '#enc should return correct merged override to host when multiple overrides for inherited hostgroups exist' do
|
|
169
|
-
FactoryBot.create(:setting,
|
|
170
|
-
name: 'matchers_inheritance',
|
|
171
|
-
value: true)
|
|
172
167
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
173
168
|
key_type: 'array', merge_overrides: true,
|
|
174
169
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -184,13 +179,13 @@ module ForemanPuppet
|
|
|
184
179
|
|
|
185
180
|
as_admin do
|
|
186
181
|
LookupValue.create! lookup_key_id: key.id,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
182
|
+
match: "hostgroup=#{parent_hostgroup}",
|
|
183
|
+
value: ['parent'],
|
|
184
|
+
omit: false
|
|
190
185
|
LookupValue.create! lookup_key_id: key.id,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
186
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
187
|
+
value: ['org'],
|
|
188
|
+
omit: false
|
|
194
189
|
end
|
|
195
190
|
|
|
196
191
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -199,9 +194,6 @@ module ForemanPuppet
|
|
|
199
194
|
end
|
|
200
195
|
|
|
201
196
|
test '#enc should return correct merged override to host when multiple overrides for inherited organizations exist' do
|
|
202
|
-
FactoryBot.create(:setting,
|
|
203
|
-
name: 'matchers_inheritance',
|
|
204
|
-
value: true)
|
|
205
197
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
206
198
|
key_type: 'array', merge_overrides: true,
|
|
207
199
|
path: "location\norganization\nhostgroup",
|
|
@@ -218,13 +210,13 @@ module ForemanPuppet
|
|
|
218
210
|
|
|
219
211
|
as_admin do
|
|
220
212
|
LookupValue.create! lookup_key_id: key.id,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
213
|
+
match: "organization=#{parent_org}",
|
|
214
|
+
value: ['parent'],
|
|
215
|
+
omit: false
|
|
224
216
|
LookupValue.create! lookup_key_id: key.id,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
217
|
+
match: "location=#{taxonomies(:location1)}",
|
|
218
|
+
value: ['loc'],
|
|
219
|
+
omit: false
|
|
228
220
|
end
|
|
229
221
|
|
|
230
222
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -233,9 +225,6 @@ module ForemanPuppet
|
|
|
233
225
|
end
|
|
234
226
|
|
|
235
227
|
test '#enc should return correct merged override to host when multiple overrides for inherited locations exist' do
|
|
236
|
-
FactoryBot.create(:setting,
|
|
237
|
-
name: 'matchers_inheritance',
|
|
238
|
-
value: true)
|
|
239
228
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
240
229
|
key_type: 'array', merge_overrides: true,
|
|
241
230
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -252,13 +241,13 @@ module ForemanPuppet
|
|
|
252
241
|
|
|
253
242
|
as_admin do
|
|
254
243
|
LookupValue.create! lookup_key_id: key.id,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
244
|
+
match: "location=#{parent_loc}",
|
|
245
|
+
value: ['parent'],
|
|
246
|
+
omit: false
|
|
258
247
|
LookupValue.create! lookup_key_id: key.id,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
248
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
249
|
+
value: ['org'],
|
|
250
|
+
omit: false
|
|
262
251
|
end
|
|
263
252
|
|
|
264
253
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -267,9 +256,6 @@ module ForemanPuppet
|
|
|
267
256
|
end
|
|
268
257
|
|
|
269
258
|
test '#enc should return correct merged override to host when multiple overrides for inherited hostgroups exist' do
|
|
270
|
-
FactoryBot.create(:setting,
|
|
271
|
-
name: 'matchers_inheritance',
|
|
272
|
-
value: true)
|
|
273
259
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
274
260
|
key_type: 'array', merge_overrides: true,
|
|
275
261
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -285,17 +271,17 @@ module ForemanPuppet
|
|
|
285
271
|
|
|
286
272
|
as_admin do
|
|
287
273
|
LookupValue.create! lookup_key_id: key.id,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
274
|
+
match: "hostgroup=#{parent_hostgroup}",
|
|
275
|
+
value: ['parent'],
|
|
276
|
+
omit: false
|
|
291
277
|
LookupValue.create! lookup_key_id: key.id,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
278
|
+
match: "hostgroup=#{child_hostgroup}",
|
|
279
|
+
value: ['child'],
|
|
280
|
+
omit: false
|
|
295
281
|
LookupValue.create! lookup_key_id: key.id,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
282
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
283
|
+
value: ['org'],
|
|
284
|
+
omit: false
|
|
299
285
|
end
|
|
300
286
|
|
|
301
287
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -304,9 +290,6 @@ module ForemanPuppet
|
|
|
304
290
|
end
|
|
305
291
|
|
|
306
292
|
test '#enc should return correct merged override to host when multiple overrides for inherited organizations exist' do
|
|
307
|
-
FactoryBot.create(:setting,
|
|
308
|
-
name: 'matchers_inheritance',
|
|
309
|
-
value: true)
|
|
310
293
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
311
294
|
key_type: 'array', merge_overrides: true,
|
|
312
295
|
path: "location\norganization\nhostgroup",
|
|
@@ -323,17 +306,17 @@ module ForemanPuppet
|
|
|
323
306
|
|
|
324
307
|
as_admin do
|
|
325
308
|
LookupValue.create! lookup_key_id: key.id,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
309
|
+
match: "organization=#{parent_org}",
|
|
310
|
+
value: ['parent'],
|
|
311
|
+
omit: false
|
|
329
312
|
LookupValue.create! lookup_key_id: key.id,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
313
|
+
match: "organization=#{child_org}",
|
|
314
|
+
value: ['child'],
|
|
315
|
+
omit: false
|
|
333
316
|
LookupValue.create! lookup_key_id: key.id,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
317
|
+
match: "location=#{taxonomies(:location1)}",
|
|
318
|
+
value: ['loc'],
|
|
319
|
+
omit: false
|
|
337
320
|
end
|
|
338
321
|
|
|
339
322
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -342,9 +325,6 @@ module ForemanPuppet
|
|
|
342
325
|
end
|
|
343
326
|
|
|
344
327
|
test '#enc should return correct merged override to host when multiple overrides for inherited locations exist' do
|
|
345
|
-
FactoryBot.create(:setting,
|
|
346
|
-
name: 'matchers_inheritance',
|
|
347
|
-
value: true)
|
|
348
328
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
349
329
|
key_type: 'array', merge_overrides: true,
|
|
350
330
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -361,17 +341,17 @@ module ForemanPuppet
|
|
|
361
341
|
|
|
362
342
|
as_admin do
|
|
363
343
|
LookupValue.create! lookup_key_id: key.id,
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
344
|
+
match: "location=#{parent_loc}",
|
|
345
|
+
value: ['parent'],
|
|
346
|
+
omit: false
|
|
367
347
|
LookupValue.create! lookup_key_id: key.id,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
348
|
+
match: "location=#{child_loc}",
|
|
349
|
+
value: ['child'],
|
|
350
|
+
omit: false
|
|
371
351
|
LookupValue.create! lookup_key_id: key.id,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
352
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
353
|
+
value: ['org'],
|
|
354
|
+
omit: false
|
|
375
355
|
end
|
|
376
356
|
|
|
377
357
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -380,9 +360,6 @@ module ForemanPuppet
|
|
|
380
360
|
end
|
|
381
361
|
|
|
382
362
|
test '#enc should return correct override to host when multiple overrides for inherited hostgroups exist' do
|
|
383
|
-
FactoryBot.create(:setting,
|
|
384
|
-
name: 'matchers_inheritance',
|
|
385
|
-
value: true)
|
|
386
363
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
387
364
|
merge_overrides: false,
|
|
388
365
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -398,17 +375,17 @@ module ForemanPuppet
|
|
|
398
375
|
|
|
399
376
|
value2 = as_admin do
|
|
400
377
|
LookupValue.create! lookup_key_id: key.id,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
378
|
+
match: "hostgroup=#{parent_hostgroup}",
|
|
379
|
+
value: 'parent',
|
|
380
|
+
omit: false
|
|
404
381
|
LookupValue.create! lookup_key_id: key.id,
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
382
|
+
match: "hostgroup=#{child_hostgroup}",
|
|
383
|
+
value: 'child',
|
|
384
|
+
omit: false
|
|
408
385
|
LookupValue.create! lookup_key_id: key.id,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
386
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
387
|
+
value: 'org',
|
|
388
|
+
omit: false
|
|
412
389
|
end
|
|
413
390
|
|
|
414
391
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -417,9 +394,6 @@ module ForemanPuppet
|
|
|
417
394
|
end
|
|
418
395
|
|
|
419
396
|
test '#enc should return correct override to host when multiple overrides for inherited organizations exist' do
|
|
420
|
-
FactoryBot.create(:setting,
|
|
421
|
-
name: 'matchers_inheritance',
|
|
422
|
-
value: true)
|
|
423
397
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
424
398
|
merge_overrides: false,
|
|
425
399
|
path: "location\norganization\nhostgroup",
|
|
@@ -434,17 +408,17 @@ module ForemanPuppet
|
|
|
434
408
|
|
|
435
409
|
value2 = as_admin do
|
|
436
410
|
LookupValue.create! lookup_key_id: key.id,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
411
|
+
match: "organization=#{parent_org}",
|
|
412
|
+
value: 'parent',
|
|
413
|
+
omit: false
|
|
440
414
|
LookupValue.create! lookup_key_id: key.id,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
415
|
+
match: "organization=#{child_org}",
|
|
416
|
+
value: 'child',
|
|
417
|
+
omit: false
|
|
444
418
|
LookupValue.create! lookup_key_id: key.id,
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
419
|
+
match: "location=#{taxonomies(:location1)}",
|
|
420
|
+
value: 'loc',
|
|
421
|
+
omit: false
|
|
448
422
|
end
|
|
449
423
|
|
|
450
424
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -453,9 +427,6 @@ module ForemanPuppet
|
|
|
453
427
|
end
|
|
454
428
|
|
|
455
429
|
test '#enc should return correct override to host when multiple overrides for inherited locations exist' do
|
|
456
|
-
FactoryBot.create(:setting,
|
|
457
|
-
name: 'matchers_inheritance',
|
|
458
|
-
value: true)
|
|
459
430
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
460
431
|
merge_overrides: false,
|
|
461
432
|
path: "organization\nlocation\nhostgroup",
|
|
@@ -470,17 +441,17 @@ module ForemanPuppet
|
|
|
470
441
|
|
|
471
442
|
value2 = as_admin do
|
|
472
443
|
LookupValue.create! lookup_key_id: key.id,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
444
|
+
match: "location=#{parent_loc}",
|
|
445
|
+
value: 'parent',
|
|
446
|
+
omit: false
|
|
476
447
|
LookupValue.create! lookup_key_id: key.id,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
448
|
+
match: "location=#{child_loc}",
|
|
449
|
+
value: 'child',
|
|
450
|
+
omit: false
|
|
480
451
|
LookupValue.create! lookup_key_id: key.id,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
452
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
453
|
+
value: 'org',
|
|
454
|
+
omit: false
|
|
484
455
|
end
|
|
485
456
|
|
|
486
457
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -489,9 +460,6 @@ module ForemanPuppet
|
|
|
489
460
|
end
|
|
490
461
|
|
|
491
462
|
test '#enc should return correct override to host when multiple overrides for inherited hostgroups exist' do
|
|
492
|
-
FactoryBot.create(:setting,
|
|
493
|
-
name: 'matchers_inheritance',
|
|
494
|
-
value: true)
|
|
495
463
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
496
464
|
merge_overrides: false,
|
|
497
465
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -506,17 +474,17 @@ module ForemanPuppet
|
|
|
506
474
|
|
|
507
475
|
value2 = as_admin do
|
|
508
476
|
LookupValue.create! lookup_key_id: key.id,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
477
|
+
match: "hostgroup=#{parent_hostgroup}",
|
|
478
|
+
value: 'parent',
|
|
479
|
+
omit: false
|
|
512
480
|
LookupValue.create! lookup_key_id: key.id,
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
481
|
+
match: "location=#{taxonomies(:location1)}",
|
|
482
|
+
value: 'loc',
|
|
483
|
+
omit: true
|
|
516
484
|
LookupValue.create! lookup_key_id: key.id,
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
485
|
+
match: "hostgroup=#{child_hostgroup}",
|
|
486
|
+
value: 'child',
|
|
487
|
+
omit: false
|
|
520
488
|
end
|
|
521
489
|
|
|
522
490
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -525,9 +493,6 @@ module ForemanPuppet
|
|
|
525
493
|
end
|
|
526
494
|
|
|
527
495
|
test '#enc should return correct override to host when multiple overrides for inherited organizations exist' do
|
|
528
|
-
FactoryBot.create(:setting,
|
|
529
|
-
name: 'matchers_inheritance',
|
|
530
|
-
value: true)
|
|
531
496
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
532
497
|
merge_overrides: false,
|
|
533
498
|
path: "organization\nhostgroup\nlocation",
|
|
@@ -544,17 +509,17 @@ module ForemanPuppet
|
|
|
544
509
|
|
|
545
510
|
value2 = as_admin do
|
|
546
511
|
LookupValue.create! lookup_key_id: key.id,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
512
|
+
match: "organization=#{parent_org}",
|
|
513
|
+
value: 'parent',
|
|
514
|
+
omit: false
|
|
550
515
|
LookupValue.create! lookup_key_id: key.id,
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
516
|
+
match: "location=#{taxonomies(:location1)}",
|
|
517
|
+
value: 'loc',
|
|
518
|
+
omit: true
|
|
554
519
|
LookupValue.create! lookup_key_id: key.id,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
520
|
+
match: "organization=#{child_org}",
|
|
521
|
+
value: 'child',
|
|
522
|
+
omit: false
|
|
558
523
|
end
|
|
559
524
|
|
|
560
525
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -563,9 +528,6 @@ module ForemanPuppet
|
|
|
563
528
|
end
|
|
564
529
|
|
|
565
530
|
test '#enc should return correct override to host when multiple overrides for inherited locations exist' do
|
|
566
|
-
FactoryBot.create(:setting,
|
|
567
|
-
name: 'matchers_inheritance',
|
|
568
|
-
value: true)
|
|
569
531
|
key = FactoryBot.create(:puppetclass_lookup_key, omit: true,
|
|
570
532
|
merge_overrides: false,
|
|
571
533
|
path: "location\norganization\nhostgroup",
|
|
@@ -582,17 +544,17 @@ module ForemanPuppet
|
|
|
582
544
|
|
|
583
545
|
value2 = as_admin do
|
|
584
546
|
LookupValue.create! lookup_key_id: key.id,
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
547
|
+
match: "location=#{parent_loc}",
|
|
548
|
+
value: 'parent',
|
|
549
|
+
omit: false
|
|
588
550
|
LookupValue.create! lookup_key_id: key.id,
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
551
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
552
|
+
value: 'org',
|
|
553
|
+
omit: true
|
|
592
554
|
LookupValue.create! lookup_key_id: key.id,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
555
|
+
match: "location=#{child_loc}",
|
|
556
|
+
value: 'child',
|
|
557
|
+
omit: false
|
|
596
558
|
end
|
|
597
559
|
|
|
598
560
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -608,13 +570,13 @@ module ForemanPuppet
|
|
|
608
570
|
|
|
609
571
|
value2 = as_admin do
|
|
610
572
|
LookupValue.create! lookup_key_id: key.id,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
573
|
+
match: "location=#{taxonomies(:location1)}",
|
|
574
|
+
value: 'test_incorrect',
|
|
575
|
+
omit: false
|
|
614
576
|
LookupValue.create! lookup_key_id: key.id,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
577
|
+
match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
|
|
578
|
+
value: 'test_correct',
|
|
579
|
+
omit: false
|
|
618
580
|
end
|
|
619
581
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
620
582
|
key.reload
|
|
@@ -630,15 +592,15 @@ module ForemanPuppet
|
|
|
630
592
|
|
|
631
593
|
value = as_admin do
|
|
632
594
|
LookupValue.create! lookup_key_id: key.id,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
595
|
+
match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
|
|
596
|
+
value: 'test_correct',
|
|
597
|
+
omit: false
|
|
636
598
|
end
|
|
637
599
|
as_admin do
|
|
638
600
|
LookupValue.create! lookup_key_id: key.id,
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
601
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
602
|
+
value: 'test_incorrect',
|
|
603
|
+
omit: false
|
|
642
604
|
end
|
|
643
605
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
|
644
606
|
|
|
@@ -662,22 +624,22 @@ module ForemanPuppet
|
|
|
662
624
|
|
|
663
625
|
as_admin do
|
|
664
626
|
LookupValue.create! lookup_key_id: key.id,
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
627
|
+
match: "hostgroup=#{parent_hostgroup},organization=#{taxonomies(:organization1)}",
|
|
628
|
+
value: 'parent',
|
|
629
|
+
omit: false
|
|
668
630
|
end
|
|
669
631
|
value2 = as_admin do
|
|
670
632
|
LookupValue.create! lookup_key_id: key.id,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
633
|
+
match: "hostgroup=#{child_hostgroup},organization=#{taxonomies(:organization1)}",
|
|
634
|
+
value: 'child',
|
|
635
|
+
omit: false
|
|
674
636
|
end
|
|
675
637
|
|
|
676
638
|
as_admin do
|
|
677
639
|
LookupValue.create! lookup_key_id: key.id,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
640
|
+
match: "location=#{taxonomies(:location1)}",
|
|
641
|
+
value: 'loc',
|
|
642
|
+
omit: false
|
|
681
643
|
end
|
|
682
644
|
|
|
683
645
|
enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
|
|
@@ -694,21 +656,21 @@ module ForemanPuppet
|
|
|
694
656
|
|
|
695
657
|
as_admin do
|
|
696
658
|
LookupValue.create! lookup_key_id: key.id,
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
659
|
+
match: "location=#{taxonomies(:location1)}",
|
|
660
|
+
value: '<%= [2,3] %>',
|
|
661
|
+
omit: false
|
|
700
662
|
end
|
|
701
663
|
as_admin do
|
|
702
664
|
LookupValue.create! lookup_key_id: key.id,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
665
|
+
match: "organization=#{taxonomies(:organization1)}",
|
|
666
|
+
value: '<%= [3,4] %>',
|
|
667
|
+
omit: false
|
|
706
668
|
end
|
|
707
669
|
as_admin do
|
|
708
670
|
LookupValue.create! lookup_key_id: key.id,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
671
|
+
match: "os=#{operatingsystems(:redhat)}",
|
|
672
|
+
value: '<%= [4,5] %>',
|
|
673
|
+
omit: false
|
|
712
674
|
end
|
|
713
675
|
|
|
714
676
|
key.reload
|
|
@@ -764,9 +726,9 @@ module ForemanPuppet
|
|
|
764
726
|
|
|
765
727
|
as_admin do
|
|
766
728
|
LookupValue.create! lookup_key_id: key.id,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
729
|
+
match: "location=#{taxonomies(:location1)}",
|
|
730
|
+
value: '<%= "c" %>',
|
|
731
|
+
omit: false
|
|
770
732
|
end
|
|
771
733
|
|
|
772
734
|
key.reload
|