foreman_puppet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +31 -0
- data/app/assets/stylesheets/foreman_puppet.scss +117 -0
- data/app/controllers/concerns/foreman_puppet/api/import_puppetclasses_common_controller.rb +139 -0
- data/app/controllers/concerns/foreman_puppet/environments_import.rb +61 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb +40 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +48 -0
- data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +58 -0
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +228 -0
- data/app/controllers/concerns/foreman_puppet/extensions/operatingsystems_controller.rb +11 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +75 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +70 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_template_combination.rb +21 -0
- data/app/controllers/concerns/foreman_puppet/parameters/config_group.rb +17 -0
- data/app/controllers/concerns/foreman_puppet/parameters/environment.rb +21 -0
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass.rb +24 -0
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +24 -0
- data/app/controllers/foreman_puppet/api/v2/base_controller.rb +26 -0
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +57 -0
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +91 -0
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +59 -0
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +46 -0
- data/app/controllers/foreman_puppet/api/v2/lookups_common_controller.rb +114 -0
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +99 -0
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +99 -0
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +76 -0
- data/app/controllers/foreman_puppet/config_groups_controller.rb +46 -0
- data/app/controllers/foreman_puppet/environments_controller.rb +51 -0
- data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +39 -0
- data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +33 -0
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +113 -0
- data/app/controllers/foreman_puppet/react_controller.rb +19 -0
- data/app/helpers/concerns/foreman_puppet/template_renderer_scope.rb +14 -0
- data/app/helpers/foreman_puppet/environments_helper.rb +17 -0
- data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +96 -0
- data/app/helpers/foreman_puppet/hosts_helper.rb +32 -0
- data/app/helpers/foreman_puppet/puppet_smart_proxies_helper.rb +8 -0
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +135 -0
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +55 -0
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +59 -0
- data/app/helpers/foreman_puppet/template_combinations_helper.rb +33 -0
- data/app/models/concerns/foreman_puppet/extensions/host.rb +88 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +40 -0
- data/app/models/concerns/foreman_puppet/extensions/nic_managed.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +64 -0
- data/app/models/concerns/foreman_puppet/extensions/report.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +19 -0
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +23 -0
- data/app/models/concerns/foreman_puppet/extensions/user.rb +22 -0
- data/app/models/concerns/foreman_puppet/host_common.rb +90 -0
- data/app/models/concerns/foreman_puppet/puppet_lookup_value_extensions.rb +13 -0
- data/app/models/foreman_puppet/config_group.rb +45 -0
- data/app/models/foreman_puppet/config_group_class.rb +19 -0
- data/app/models/foreman_puppet/environment.rb +63 -0
- data/app/models/foreman_puppet/environment_class.rb +40 -0
- data/app/models/foreman_puppet/host_class.rb +23 -0
- data/app/models/foreman_puppet/host_config_group.rb +15 -0
- data/app/models/foreman_puppet/host_puppet_facet.rb +130 -0
- data/app/models/foreman_puppet/hostgroup_class.rb +23 -0
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +98 -0
- data/app/models/foreman_puppet/puppetclass.rb +132 -0
- data/app/models/foreman_puppet/puppetclass_lookup_key.rb +58 -0
- data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +10 -0
- data/app/services/foreman_puppet/host_info_providers/puppet_info.rb +92 -0
- data/app/services/foreman_puppet/input_type/puppet_parameter_input.rb +35 -0
- data/app/services/foreman_puppet/proxy_status/puppet.rb +17 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +355 -0
- data/app/views/api/v2/template_combinations/base.json.erb +9 -0
- data/app/views/foreman_puppet/api/v2/config_groups/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/main.json.rabl +8 -0
- data/app/views/foreman_puppet/api/v2/config_groups/show.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/main.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/environments/show.json.rabl +15 -0
- data/app/views/foreman_puppet/api/v2/environments/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/base.json.rabl +1 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_single.json.rabl +17 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/show.json.rabl +11 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single.json.rabl +16 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/show.json.rabl +11 -0
- data/app/views/foreman_puppet/api/v2/import_puppetclasses/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/import_puppetclasses/show.json.rabl +36 -0
- data/app/views/foreman_puppet/api/v2/override_values/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/show.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/index.json.rabl +4 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/list.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/main.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/show.json.rabl +15 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/base.json.rabl +4 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/destroy.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/main.json.rabl +23 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/show.json.rabl +19 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/update.json.rabl +3 -0
- data/app/views/foreman_puppet/config_groups/_config_group.html.erb +34 -0
- data/app/views/foreman_puppet/config_groups/_config_groups_selection.html.erb +36 -0
- data/app/views/foreman_puppet/config_groups/_form.html.erb +9 -0
- data/app/views/foreman_puppet/config_groups/edit.html.erb +3 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +31 -0
- data/app/views/foreman_puppet/config_groups/new.html.erb +3 -0
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -0
- data/app/views/foreman_puppet/environments/_form.html.erb +20 -0
- data/app/views/foreman_puppet/environments/edit.html.erb +8 -0
- data/app/views/foreman_puppet/environments/index.html.erb +32 -0
- data/app/views/foreman_puppet/environments/new.html.erb +7 -0
- data/app/views/foreman_puppet/environments/welcome.html.erb +16 -0
- data/app/views/foreman_puppet/layouts/application_react.html.erb +15 -0
- data/app/views/foreman_puppet/puppet_smart_proxies/_dashboard.html.erb +9 -0
- data/app/views/foreman_puppet/puppet_smart_proxies/_environments.html.erb +30 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/edit.html.erb +3 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/index.html.erb +22 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +9 -0
- data/app/views/foreman_puppet/puppetclasses/_class_parameters.html.erb +37 -0
- data/app/views/foreman_puppet/puppetclasses/_class_selection.html.erb +70 -0
- data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +22 -0
- data/app/views/foreman_puppet/puppetclasses/_classes_in_groups.html.erb +5 -0
- data/app/views/foreman_puppet/puppetclasses/_classes_parameters.html.erb +16 -0
- data/app/views/foreman_puppet/puppetclasses/_form.html.erb +62 -0
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +4 -0
- data/app/views/foreman_puppet/puppetclasses/edit.html.erb +4 -0
- data/app/views/foreman_puppet/puppetclasses/index.html.erb +47 -0
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +24 -0
- data/app/views/hosts/foreman_puppet/_form_main_tab_fields.html.erb +1 -0
- data/app/views/hosts/select_multiple_environment.html.erb +8 -0
- data/app/views/provisioning_templates/_combination.html.erb +5 -0
- data/app/views/provisioning_templates/_combinations.html.erb +6 -0
- data/app/views/smart_proxies/plugins/_puppet.html.erb +24 -0
- data/config/api_routes.rb +81 -0
- data/config/routes.rb +89 -0
- data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +9 -0
- data/db/migrate/20200720123005_migrate_puppet_core_types.foreman_puppet.rb +19 -0
- data/db/migrate/20200722171017_create_host_puppet_facet.foreman_puppet.rb +10 -0
- data/db/migrate/20200803113531_create_hostgroup_puppet_facet.foreman_puppet.rb +10 -0
- data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +22 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +29 -0
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +47 -0
- data/db/migrate_foreman/20090722141107_create_environments.rb +17 -0
- data/db/migrate_foreman/20120905095532_create_environment_classes.rb +15 -0
- data/db/migrate_foreman/20140407161817_create_config_groups.rb +9 -0
- data/db/migrate_foreman/20140407162007_create_config_group_classes.rb +10 -0
- data/db/migrate_foreman/20140407162059_create_host_config_groups.rb +11 -0
- data/db/migrate_foreman/20161205142618_delete_orphaned_smart_class_parameters.rb +10 -0
- data/db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb +15 -0
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +35 -0
- data/db/migrate_foreman/20181023112532_add_environment_puppetclass_id.rb +7 -0
- data/db/migrate_foreman/20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.rb +6 -0
- data/db/seeds.d/111_puppet_proxy_feature.rb +8 -0
- data/lib/foreman_puppet.rb +10 -0
- data/lib/foreman_puppet/engine.rb +82 -0
- data/lib/foreman_puppet/register.rb +218 -0
- data/lib/foreman_puppet/version.rb +3 -0
- data/lib/tasks/foreman_puppet_tasks.rake +31 -0
- data/locale/Makefile +60 -0
- data/locale/action_names.rb +5 -0
- data/locale/en/foreman_puppet.edit.po +911 -0
- data/locale/en/foreman_puppet.po +690 -0
- data/locale/en/foreman_puppet.po.time_stamp +0 -0
- data/locale/foreman_puppet.pot +1076 -0
- data/locale/gemspec.rb +2 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +28 -0
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +346 -0
- data/test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb +48 -0
- data/test/controllers/foreman_puppet/api/v2/hostgroup_classes_controller_test.rb +41 -0
- data/test/controllers/foreman_puppet/api/v2/hostgroups_controller_test.rb +79 -0
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +101 -0
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +29 -0
- data/test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb +169 -0
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +144 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +557 -0
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +81 -0
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +47 -0
- data/test/controllers/foreman_puppet/environments_controller_test.rb +230 -0
- data/test/controllers/foreman_puppet/hostgroups_controller_test.rb +72 -0
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +346 -0
- data/test/controllers/foreman_puppet/puppet_smart_proxies_controller_test.rb +29 -0
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +59 -0
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +235 -0
- data/test/controllers/provisioning_templates_controller_test.rb +70 -0
- data/test/factories/foreman_puppet_factories.rb +134 -0
- data/test/factories/host_puppet_enhancements.rb +61 -0
- data/test/factories/proxy_puppet_enhancements.rb +33 -0
- data/test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb +65 -0
- data/test/helpers/foreman_puppet/puppetclasses_helper_test.rb +33 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +27 -0
- data/test/integration/foreman_puppet/host_js_test.rb +371 -0
- data/test/integration/foreman_puppet/hostgroup_js_test.rb +100 -0
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +37 -0
- data/test/integration/foreman_puppet/smartclass_parameter_js_test.rb +84 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +9 -0
- data/test/models/foreman_puppet/config_group_test.rb +8 -0
- data/test/models/foreman_puppet/environment_test.rb +92 -0
- data/test/models/foreman_puppet/host_config_group_test.rb +39 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +116 -0
- data/test/models/foreman_puppet/host_test.rb +288 -0
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +200 -0
- data/test/models/foreman_puppet/hostgroup_test.rb +14 -0
- data/test/models/foreman_puppet/lookup_value_test.rb +69 -0
- data/test/models/foreman_puppet/provisioning_template_test.rb +124 -0
- data/test/models/foreman_puppet/puppetclass_lookup_key_test.rb +81 -0
- data/test/models/foreman_puppet/puppetclass_test.rb +144 -0
- data/test/models/foreman_puppet/smart_proxy_test.rb +28 -0
- data/test/qraphql/queries/host_puppet_query_test.rb +36 -0
- data/test/qraphql/queries/hostgroup_puppet_query_test.rb +36 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +791 -0
- data/test/services/foreman_puppet/input_type/puppet_parameter_input_test.rb +14 -0
- data/test/test_puppet_helper.rb +30 -0
- data/test/unit/foreman_puppet/access_permissions_test.rb +16 -0
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +247 -0
- data/test/unit/foreman_puppet/template_rendering_test.rb +20 -0
- data/test/unit/foreman_puppet_test.rb +11 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +7 -0
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +2 -0
- data/webpack/__mocks__/foremanReact/readme.md +11 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
- data/webpack/__mocks__/foremanReact/redux/index.js +1 -0
- data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
- data/webpack/fills_index.js +30 -0
- data/webpack/index.js +18 -0
- data/webpack/src/ForemanPuppet.js +11 -0
- data/webpack/src/Router/__snapshots__/routes.test.js.snap +3 -0
- data/webpack/src/Router/index.js +14 -0
- data/webpack/src/Router/routes.js +3 -0
- data/webpack/src/Router/routes.test.js +16 -0
- data/webpack/src/foreman_class_edit.js +224 -0
- data/webpack/src/foreman_puppet_host_form.js +140 -0
- data/webpack/src/foreman_puppet_host_form.test.js +65 -0
- data/webpack/src/index.js +1 -0
- data/webpack/src/reducers.js +7 -0
- metadata +340 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
require 'integration_test_helper'
|
3
|
+
|
4
|
+
module ForemanPuppet
|
5
|
+
class HostgroupJSTest < IntegrationTestWithJavascript
|
6
|
+
let(:hostgroup) { FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass) }
|
7
|
+
let(:environment) { FactoryBot.create(:environment) }
|
8
|
+
|
9
|
+
describe 'create new page' do
|
10
|
+
test 'create new page' do
|
11
|
+
environment
|
12
|
+
assert_new_button(hostgroups_path, 'Create Host Group', new_hostgroup_path)
|
13
|
+
fill_in 'hostgroup_name', with: 'staging'
|
14
|
+
select2 environment.name, from: 'hostgroup_puppet_attributes_environment_id'
|
15
|
+
assert_submit_button(hostgroups_path)
|
16
|
+
assert_equal environment.id,
|
17
|
+
Hostgroup.find_by(name: 'staging').environment_id,
|
18
|
+
'Hostgroup not created or environment not set'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'edit page' do
|
23
|
+
setup do
|
24
|
+
@another_puppetclass = FactoryBot.create(:puppetclass)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'changing the environment' do
|
28
|
+
setup do
|
29
|
+
environment
|
30
|
+
@hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc)
|
31
|
+
visit hostgroups_path
|
32
|
+
click_link @hostgroup.name
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'preserves the puppetclasses' do
|
36
|
+
puppetclasses = @hostgroup.puppet.puppetclasses.all
|
37
|
+
|
38
|
+
select2 environment.name, from: 'hostgroup_puppet_attributes_environment_id'
|
39
|
+
assert_submit_button(hostgroups_path)
|
40
|
+
|
41
|
+
assert_equal puppetclasses, @hostgroup.puppet.puppetclasses.all
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'has inherited Puppetclasses' do
|
46
|
+
test 'has the parent group inherited parameters visible' do
|
47
|
+
child_hostgroup = FactoryBot.create(:hostgroup, parent: hostgroup)
|
48
|
+
|
49
|
+
visit edit_hostgroup_path(child_hostgroup)
|
50
|
+
switch_form_tab('Puppet ENC')
|
51
|
+
|
52
|
+
header_element = page.find('#puppet_enc_tab .panel h3 a')
|
53
|
+
assert header_element.text =~ /#{hostgroup.name}$/
|
54
|
+
header_element.click
|
55
|
+
|
56
|
+
class_element = page.find('#inherited_ids > li')
|
57
|
+
assert_equal hostgroup.puppet.puppetclasses.first.name, class_element.text
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'shows errors on invalid lookup values' do
|
62
|
+
lookup_key = FactoryBot.create(:puppetclass_lookup_key, :integer,
|
63
|
+
path: 'hostgroup', puppetclass: hostgroup.puppet.puppetclasses.first,
|
64
|
+
overrides: { hostgroup.lookup_value_matcher => 2 })
|
65
|
+
|
66
|
+
visit edit_hostgroup_path(hostgroup)
|
67
|
+
switch_form_tab('Puppet ENC')
|
68
|
+
assert page.has_no_selector?('#puppet_klasses_parameters .input-group.has-error')
|
69
|
+
fill_in "hostgroup_lookup_values_attributes_#{lookup_key.id}_value", with: 'invalid'
|
70
|
+
click_button('Submit')
|
71
|
+
assert page.has_selector?('#puppet_klasses_parameters td.has-error')
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'puppet classes are not available in the environment' do
|
75
|
+
test 'it shows a warning and marks as unavailable' do
|
76
|
+
hostgroup.puppet.puppetclasses << @another_puppetclass
|
77
|
+
visit edit_hostgroup_path(hostgroup)
|
78
|
+
|
79
|
+
switch_form_tab('Puppet ENC')
|
80
|
+
|
81
|
+
assert page.has_selector?('#puppetclasses_unavailable_warning')
|
82
|
+
assert page.has_selector?('.selected_puppetclass.unavailable')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'clone page' do
|
88
|
+
test 'clones lookup values' do
|
89
|
+
lookup_key = FactoryBot.create(:puppetclass_lookup_key, path: "hostgroup\ncomment",
|
90
|
+
puppetclass: hostgroup.puppet.puppetclasses.first,
|
91
|
+
overrides: { hostgroup.lookup_value_matcher => 'abc' })
|
92
|
+
|
93
|
+
visit clone_hostgroup_path(hostgroup)
|
94
|
+
switch_form_tab('Puppet ENC')
|
95
|
+
a = page.find("#hostgroup_lookup_values_attributes_#{lookup_key.id}_value")
|
96
|
+
assert_equal 'abc', a.value
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
require 'integration_test_helper'
|
3
|
+
|
4
|
+
module ForemanPuppet
|
5
|
+
class PuppetclassJsTest < IntegrationTestWithJavascript
|
6
|
+
include ForemanPuppet::Engine.routes.url_helpers
|
7
|
+
# intermittent failures:
|
8
|
+
# PuppetclassIntegrationTest.test_0001_edit page
|
9
|
+
|
10
|
+
let(:environment) { FactoryBot.create(:environment) }
|
11
|
+
let(:puppetclass) { FactoryBot.create(:puppetclass, environments: [environment]) }
|
12
|
+
|
13
|
+
test 'edit page' do
|
14
|
+
visit puppetclasses_path
|
15
|
+
click_link 'vim'
|
16
|
+
assert page.has_no_link? 'Common'
|
17
|
+
find(:xpath, "//a[@data-original-title='Select All']").click
|
18
|
+
assert_submit_button(puppetclasses_path)
|
19
|
+
assert page.has_link? 'vim'
|
20
|
+
assert page.has_link? 'Common'
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'verify key label exists in case key is too long' do
|
24
|
+
smart_class_parameter_long = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 50)
|
25
|
+
visit edit_puppetclass_path(puppetclass)
|
26
|
+
click_link 'Smart Class Parameter'
|
27
|
+
assert_equal smart_class_parameter_long.key, page.find("#pill_#{smart_class_parameter_long.id}-#{smart_class_parameter_long.key}")['data-original-title']
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'verify key label is empty in case key is short' do
|
31
|
+
smart_class_parameter_short = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 40)
|
32
|
+
visit edit_puppetclass_path(puppetclass)
|
33
|
+
click_link 'Smart Class Parameter'
|
34
|
+
assert_empty page.find("#pill_#{smart_class_parameter_short.id}-#{smart_class_parameter_short.key}")['data-original-title']
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require_relative '../../test_puppet_helper'
|
2
|
+
require 'integration_test_helper'
|
3
|
+
|
4
|
+
module ForemanPuppet
|
5
|
+
class SmartclassParameterJSTest < IntegrationTestWithJavascript
|
6
|
+
include ForemanPuppet::Engine.routes.url_helpers
|
7
|
+
|
8
|
+
# intermittent failures:
|
9
|
+
# PuppetclassLookupKeyJSTest.test_0001_can hide value when overriden
|
10
|
+
# PuppetclassLookupKeyJSTest.test_0002_uncheck override
|
11
|
+
|
12
|
+
test 'index page' do
|
13
|
+
FactoryBot.create(:puppetclass_lookup_key, key: 'ssl')
|
14
|
+
assert_index_page(puppetclass_lookup_keys_path, 'Smart Class Parameters', false)
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'can hide value when overriden' do
|
18
|
+
FactoryBot.create(:puppetclass_lookup_key, key: 'port', override: false)
|
19
|
+
visit puppetclass_lookup_keys_path
|
20
|
+
within(:xpath, '//table') do
|
21
|
+
click_link 'port'
|
22
|
+
end
|
23
|
+
page.find('#puppetclass_lookup_key_override').click
|
24
|
+
assert page.find('#puppetclass_lookup_key_hidden_value:enabled')
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'does not turn empty boolean value to false' do
|
28
|
+
FactoryBot.create(:puppetclass_lookup_key, key: 'ssl')
|
29
|
+
visit puppetclass_lookup_keys_path
|
30
|
+
within(:xpath, '//table') do
|
31
|
+
click_link 'ssl'
|
32
|
+
end
|
33
|
+
|
34
|
+
page.find('.add_nested_fields').click
|
35
|
+
row = page.first('.lookup_values table tbody tr')
|
36
|
+
row.find('.matcher_key').select('os')
|
37
|
+
row.find('.matcher_value').set('fake')
|
38
|
+
wait_for_ajax
|
39
|
+
|
40
|
+
click_button('Submit')
|
41
|
+
assert page.has_selector?('.has-error')
|
42
|
+
end
|
43
|
+
|
44
|
+
test 'uncheck override' do
|
45
|
+
FactoryBot.create(:puppetclass_lookup_key, key: 'ssl')
|
46
|
+
visit puppetclass_lookup_keys_path
|
47
|
+
within(:xpath, '//table') do
|
48
|
+
click_link 'ssl'
|
49
|
+
end
|
50
|
+
|
51
|
+
page.find('#puppetclass_lookup_key_hidden_value').click
|
52
|
+
|
53
|
+
assert_submit_button(puppetclass_lookup_keys_path)
|
54
|
+
wait_for_ajax
|
55
|
+
|
56
|
+
within(:xpath, '//table') do
|
57
|
+
click_link 'ssl'
|
58
|
+
end
|
59
|
+
|
60
|
+
page.find('#puppetclass_lookup_key_override').click
|
61
|
+
|
62
|
+
assert_submit_button(puppetclass_lookup_keys_path)
|
63
|
+
wait_for_ajax
|
64
|
+
|
65
|
+
within(:xpath, '//table') do
|
66
|
+
click_link 'ssl'
|
67
|
+
end
|
68
|
+
|
69
|
+
assert page.find('#puppetclass_lookup_key_hidden_value').checked?
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'edit page' do
|
73
|
+
FactoryBot.create(:puppetclass_lookup_key, key: 'ssl')
|
74
|
+
visit puppetclass_lookup_keys_path
|
75
|
+
within(:xpath, '//table') do
|
76
|
+
click_link 'ssl'
|
77
|
+
end
|
78
|
+
fill_in 'puppetclass_lookup_key_description', with: 'test'
|
79
|
+
fill_in 'puppetclass_lookup_key_default_value', with: 'false'
|
80
|
+
assert_submit_button(puppetclass_lookup_keys_path)
|
81
|
+
assert page.has_link? 'ssl'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
class ConfigGroupClassTest < ActiveSupport::TestCase
|
5
|
+
should validate_presence_of(:config_group)
|
6
|
+
should validate_presence_of(:puppetclass)
|
7
|
+
should validate_uniqueness_of(:config_group).scoped_to(:puppetclass_id)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
class EnvironmentTest < ActiveSupport::TestCase
|
5
|
+
should validate_presence_of(:name)
|
6
|
+
should validate_uniqueness_of(:name)
|
7
|
+
should have_many(:provisioning_templates).through(:template_combinations)
|
8
|
+
should have_many(:puppetclasses).through(:environment_classes)
|
9
|
+
|
10
|
+
test 'to_label should print name' do
|
11
|
+
env = Environment.new name: 'foo'
|
12
|
+
assert_equal env.to_label, env.name
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'to_s should print name' do
|
16
|
+
env = Environment.new name: 'foo'
|
17
|
+
assert_equal env.to_s, env.name
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should create environment with the name "new"' do
|
21
|
+
assert FactoryBot.build_stubbed(:environment, name: 'new').valid?
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'should create with multiple valid names' do
|
25
|
+
valid_env_name_list.each do |name|
|
26
|
+
env = FactoryBot.build(:environment, name: name)
|
27
|
+
assert env.valid?, "Can't create environment with valid name #{name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'should not create with multiple invalid names' do
|
32
|
+
invalid_env_name_list.each do |name|
|
33
|
+
env = FactoryBot.build(:environment, name: name)
|
34
|
+
assert_not env.valid?, "Can create environment with invalid name #{name}"
|
35
|
+
assert_includes env.errors.keys, :name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'should update with multiple valid names' do
|
40
|
+
env = FactoryBot.create(:environment)
|
41
|
+
valid_env_name_list.each do |name|
|
42
|
+
env.name = name
|
43
|
+
assert env.valid?, "Can't update environment with valid name #{name}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'should not update with multiple invalid names' do
|
48
|
+
env = FactoryBot.create(:environment)
|
49
|
+
invalid_env_name_list.each do |name|
|
50
|
+
env.name = name
|
51
|
+
assert_not env.valid?, "Can update environment with invalid name #{name}"
|
52
|
+
assert_includes env.errors.keys, :name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'audited' do
|
57
|
+
test 'on creation on of a new environment' do
|
58
|
+
environment = FactoryBot.build(:environment, :with_auditing)
|
59
|
+
|
60
|
+
assert_difference 'environment.audits.count' do
|
61
|
+
environment.save!
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# List of valid environment names.
|
69
|
+
def valid_env_name_list
|
70
|
+
[
|
71
|
+
RFauxFactory.gen_alphanumeric(1),
|
72
|
+
RFauxFactory.gen_alphanumeric(255),
|
73
|
+
RFauxFactory.gen_alphanumeric(rand(1..254)),
|
74
|
+
RFauxFactory.gen_alpha(rand(1..254)),
|
75
|
+
RFauxFactory.gen_numeric_string(rand(1..254)),
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
# List of invalid environment names.
|
80
|
+
def invalid_env_name_list
|
81
|
+
[
|
82
|
+
RFauxFactory.gen_cjk,
|
83
|
+
RFauxFactory.gen_latin1,
|
84
|
+
RFauxFactory.gen_utf8,
|
85
|
+
RFauxFactory.gen_alpha(256),
|
86
|
+
RFauxFactory.gen_numeric_string(256),
|
87
|
+
RFauxFactory.gen_alphanumeric(256),
|
88
|
+
RFauxFactory.gen_html(249),
|
89
|
+
]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
class HostConfigGroupTest < ActiveSupport::TestCase
|
5
|
+
should belong_to(:host)
|
6
|
+
should belong_to(:config_group)
|
7
|
+
should validate_uniqueness_of(:host_id).scoped_to(:config_group_id, :host_type)
|
8
|
+
|
9
|
+
let(:environment) { FactoryBot.create(:environment) }
|
10
|
+
let(:puppetclasses) { FactoryBot.create_list(:puppetclass, 4, environments: [environment]) }
|
11
|
+
let(:config_group_with_classes) { FactoryBot.create(:config_group, puppetclasses: puppetclasses) }
|
12
|
+
|
13
|
+
test 'relationship host.group_puppetclasses' do
|
14
|
+
host = FactoryBot.create(:host, :with_puppet_enc, config_groups: [config_group_with_classes])
|
15
|
+
assert_equal 4, host.puppet.group_puppetclasses.count
|
16
|
+
assert_equal puppetclasses.map(&:id).sort, host.puppet.group_puppetclasses.pluck(:id).sort
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'relationship host.config_groups ' do
|
20
|
+
cgs = FactoryBot.create_list(:config_group, 2)
|
21
|
+
host = FactoryBot.create(:host, :with_puppet_enc, config_groups: cgs)
|
22
|
+
assert_equal 2, host.puppet.config_groups.count
|
23
|
+
assert_equal cgs.map(&:name).sort, host.puppet.config_groups.pluck(:name).sort
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'relationship hostgroup.group_puppetclasses' do
|
27
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, config_groups: [config_group_with_classes])
|
28
|
+
assert_equal 4, hostgroup.puppet.group_puppetclasses.count
|
29
|
+
assert_equal puppetclasses.map(&:id).sort, hostgroup.puppet.group_puppetclasses.pluck(:id).sort
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'relationship hostgroup.config_groups' do
|
33
|
+
cgs = FactoryBot.create_list(:config_group, 2)
|
34
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, config_groups: cgs)
|
35
|
+
assert_equal 2, hostgroup.puppet.config_groups.count
|
36
|
+
assert_equal cgs.map(&:name).sort, hostgroup.puppet.config_groups.pluck(:name).sort
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'test_puppet_helper'
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
class HostgroupPuppetFacetTest < ActiveSupport::TestCase
|
5
|
+
let(:environment) { FactoryBot.create(:environment) }
|
6
|
+
let(:diff_environment) { FactoryBot.create(:environment) }
|
7
|
+
let(:puppetclass_both) { FactoryBot.create(:puppetclass, environments: [environment, diff_environment]) }
|
8
|
+
let(:config_group) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [environment]) }
|
9
|
+
let(:config_group_diff_env) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [diff_environment]) }
|
10
|
+
|
11
|
+
describe '#classes_in_groups' do
|
12
|
+
test 'classes_in_groups should return the puppetclasses of a config group only if it is in host environment' do
|
13
|
+
host = FactoryBot.create(:host, :with_puppet_enc,
|
14
|
+
location: taxonomies(:location1),
|
15
|
+
organization: taxonomies(:organization1),
|
16
|
+
environment: environment,
|
17
|
+
config_groups: [config_group, config_group_diff_env])
|
18
|
+
group_classes = host.puppet.classes_in_groups
|
19
|
+
assert_equal config_group.puppetclasses.pluck(:id).sort, group_classes.map(&:id).sort
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#all_puppetclasses' do
|
24
|
+
test 'should return all classes for environment only' do
|
25
|
+
host = FactoryBot.create(:host, :with_puppet_enc,
|
26
|
+
location: taxonomies(:location1),
|
27
|
+
organization: taxonomies(:organization1),
|
28
|
+
environment: environment,
|
29
|
+
config_groups: [config_group, config_group_diff_env],
|
30
|
+
puppetclasses: [puppetclass_both])
|
31
|
+
all_classes = host.puppet.classes
|
32
|
+
# four classes in config groups plus one manually added
|
33
|
+
assert_equal 2, all_classes.count
|
34
|
+
assert_equal [puppetclass_both.id, config_group.puppetclass_ids.first].sort, all_classes.map(&:id).sort
|
35
|
+
assert_equal all_classes, host.puppet.all_puppetclasses
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#parent_classes' do
|
40
|
+
test 'should return parent_classes if host has hostgroup and environment are the same' do
|
41
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
42
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
43
|
+
assert host.hostgroup
|
44
|
+
assert_not_empty host.puppet.parent_classes
|
45
|
+
assert_equal host.puppet.parent_classes, host.hostgroup.puppet.classes
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'should not return parent classes that do not match environment' do
|
49
|
+
# one class in the right env, one in a different env
|
50
|
+
pclass2 = FactoryBot.create(:puppetclass, environments: [diff_environment])
|
51
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, puppetclasses: [puppetclass_both, pclass2], environment: environment)
|
52
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: diff_environment)
|
53
|
+
assert host.hostgroup
|
54
|
+
assert_not_empty host.puppet.parent_classes
|
55
|
+
assert_not_equal host.puppet.environment, host.hostgroup.puppet.environment
|
56
|
+
assert_not_equal host.puppet.parent_classes, host.hostgroup.puppet.classes
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'should return empty array if host does not have hostgroup' do
|
60
|
+
host = FactoryBot.create(:host, :with_puppet_enc)
|
61
|
+
assert_nil host.hostgroup
|
62
|
+
assert_empty host.puppet.parent_classes
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#parent_config_groups' do
|
67
|
+
test 'should return parent config_groups if host has hostgroup' do
|
68
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_config_group)
|
69
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
70
|
+
assert host.hostgroup
|
71
|
+
assert_equal host.puppet.parent_config_groups, host.hostgroup.puppet.config_groups
|
72
|
+
end
|
73
|
+
|
74
|
+
test 'should return empty array if host has no hostgroup' do
|
75
|
+
host = FactoryBot.create(:host, :with_puppet_enc)
|
76
|
+
assert_not host.hostgroup
|
77
|
+
assert_empty host.puppet.parent_config_groups
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#individual_puppetclasses' do
|
82
|
+
test 'individual puppetclasses added to host (that can be removed) does not include classes that are included by config group' do
|
83
|
+
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group)
|
84
|
+
pclass = FactoryBot.create(:puppetclass, environments: [host.puppet.environment])
|
85
|
+
host.puppet.puppetclasses << pclass
|
86
|
+
# not sure why, but .classes and .puppetclasses don't return the same thing here...
|
87
|
+
assert_equal (host.puppet.config_groups.first.classes + [pclass]).map(&:name).sort, host.puppet.classes.map(&:name).sort
|
88
|
+
assert_equal [pclass.name], host.puppet.individual_puppetclasses.map(&:name)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#available_puppetclasses' do
|
93
|
+
test 'available_puppetclasses should return all if no environment' do
|
94
|
+
host = FactoryBot.create(:host, :with_puppet_enc)
|
95
|
+
host.puppet.update(environment_id: nil)
|
96
|
+
assert_equal ForemanPuppet::Puppetclass.where(nil), host.puppet.available_puppetclasses
|
97
|
+
end
|
98
|
+
|
99
|
+
test 'available_puppetclasses should return environment-specific classes' do
|
100
|
+
puppetclass_both
|
101
|
+
host = FactoryBot.create(:host, :with_puppet_enc)
|
102
|
+
assert_not_equal ForemanPuppet::Puppetclass.where(nil), host.puppet.available_puppetclasses
|
103
|
+
assert_equal host.puppet.environment.puppetclasses.sort, host.puppet.available_puppetclasses.sort
|
104
|
+
end
|
105
|
+
|
106
|
+
test 'available_puppetclasses should return environment-specific classes (and that are NOT already inherited by parent)' do
|
107
|
+
puppetclass_both
|
108
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass, environment: environment)
|
109
|
+
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup, environment: environment)
|
110
|
+
assert_not_equal ForemanPuppet::Puppetclass.where(nil), host.puppet.available_puppetclasses
|
111
|
+
assert_not_equal host.puppet.environment.puppetclasses.sort, host.puppet.available_puppetclasses.sort
|
112
|
+
assert_equal (host.puppet.environment.puppetclasses - host.puppet.parent_classes).sort, host.puppet.available_puppetclasses.sort
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|