puppet 6.19.1-universal-darwin → 7.0.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +19 -20
- data/README.md +1 -1
- data/conf/fileserver.conf +5 -10
- data/ext/build_defaults.yaml +1 -1
- data/ext/osx/file_mapping.yaml +0 -5
- data/ext/project_data.yaml +1 -14
- data/ext/redhat/puppet.spec.erb +0 -1
- data/ext/windows/service/daemon.rb +6 -5
- data/install.rb +21 -17
- data/lib/puppet.rb +11 -20
- data/lib/puppet/application.rb +172 -98
- data/lib/puppet/application/device.rb +100 -104
- data/lib/puppet/application/filebucket.rb +15 -11
- data/lib/puppet/application/ssl.rb +1 -1
- data/lib/puppet/configurer.rb +28 -33
- data/lib/puppet/configurer/plugin_handler.rb +21 -19
- data/lib/puppet/defaults.rb +95 -159
- data/lib/puppet/environments.rb +10 -25
- data/lib/puppet/face/config.rb +10 -0
- data/lib/puppet/face/epp.rb +12 -2
- data/lib/puppet/face/facts.rb +66 -6
- data/lib/puppet/face/help.rb +1 -1
- data/lib/puppet/face/plugin.rb +5 -8
- data/lib/puppet/ffi/windows.rb +12 -0
- data/lib/puppet/ffi/windows/api_types.rb +311 -0
- data/lib/puppet/ffi/windows/constants.rb +404 -0
- data/lib/puppet/ffi/windows/functions.rb +628 -0
- data/lib/puppet/ffi/windows/structs.rb +338 -0
- data/lib/puppet/file_serving/configuration.rb +0 -5
- data/lib/puppet/file_serving/configuration/parser.rb +3 -32
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_serving/mount.rb +1 -2
- data/lib/puppet/forge/repository.rb +0 -1
- data/lib/puppet/functions/epp.rb +1 -0
- data/lib/puppet/functions/inline_epp.rb +1 -0
- data/lib/puppet/generate/models/type/type.rb +4 -1
- data/lib/puppet/http.rb +22 -13
- data/lib/puppet/http/client.rb +164 -114
- data/lib/puppet/{network/resolver.rb → http/dns.rb} +2 -2
- data/lib/puppet/http/errors.rb +16 -0
- data/lib/puppet/http/external_client.rb +5 -7
- data/lib/puppet/{network/http → http}/factory.rb +8 -11
- data/lib/puppet/{network/http → http}/pool.rb +61 -26
- data/lib/puppet/{network/http/session.rb → http/pool_entry.rb} +2 -3
- data/lib/puppet/http/proxy.rb +137 -0
- data/lib/puppet/http/redirector.rb +4 -12
- data/lib/puppet/http/resolver.rb +5 -15
- data/lib/puppet/http/resolver/server_list.rb +6 -10
- data/lib/puppet/http/resolver/settings.rb +4 -7
- data/lib/puppet/http/resolver/srv.rb +7 -11
- data/lib/puppet/http/response.rb +36 -54
- data/lib/puppet/http/response_converter.rb +24 -0
- data/lib/puppet/http/response_net_http.rb +42 -0
- data/lib/puppet/http/retry_after_handler.rb +4 -13
- data/lib/puppet/http/service.rb +12 -26
- data/lib/puppet/http/service/ca.rb +11 -22
- data/lib/puppet/http/service/compiler.rb +22 -69
- data/lib/puppet/http/service/file_server.rb +18 -27
- data/lib/puppet/http/service/puppetserver.rb +26 -12
- data/lib/puppet/http/service/report.rb +8 -10
- data/lib/puppet/http/session.rb +11 -20
- data/lib/puppet/{network/http → http}/site.rb +1 -2
- data/lib/puppet/indirector/catalog/rest.rb +2 -4
- data/lib/puppet/indirector/fact_search.rb +60 -0
- data/lib/puppet/indirector/facts/facter.rb +24 -3
- data/lib/puppet/indirector/facts/json.rb +27 -0
- data/lib/puppet/indirector/facts/rest.rb +3 -22
- data/lib/puppet/indirector/facts/yaml.rb +3 -58
- data/lib/puppet/indirector/file_bucket_file/rest.rb +3 -9
- data/lib/puppet/indirector/file_content/rest.rb +2 -6
- data/lib/puppet/indirector/file_metadata/rest.rb +3 -9
- data/lib/puppet/indirector/file_server.rb +1 -8
- data/lib/puppet/indirector/generic_http.rb +0 -11
- data/lib/puppet/indirector/json.rb +5 -1
- data/lib/puppet/indirector/node/json.rb +8 -0
- data/lib/puppet/indirector/node/rest.rb +2 -4
- data/lib/puppet/indirector/report/json.rb +34 -0
- data/lib/puppet/indirector/report/rest.rb +3 -8
- data/lib/puppet/indirector/request.rb +0 -101
- data/lib/puppet/indirector/rest.rb +12 -263
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/network/authconfig.rb +2 -96
- data/lib/puppet/network/authorization.rb +13 -35
- data/lib/puppet/network/formats.rb +2 -1
- data/lib/puppet/network/http.rb +3 -3
- data/lib/puppet/network/http/api/indirected_routes.rb +2 -20
- data/lib/puppet/network/http/api/master/v3.rb +11 -13
- data/lib/puppet/network/http/connection.rb +247 -316
- data/lib/puppet/network/http/handler.rb +0 -1
- data/lib/puppet/network/http_pool.rb +16 -34
- data/lib/puppet/node.rb +1 -30
- data/lib/puppet/pal/json_catalog_encoder.rb +4 -0
- data/lib/puppet/pal/pal_impl.rb +73 -18
- data/lib/puppet/parser/ast/pops_bridge.rb +0 -38
- data/lib/puppet/parser/compiler.rb +0 -198
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +14 -39
- data/lib/puppet/parser/resource.rb +0 -69
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -8
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +3 -3
- data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -1
- data/lib/puppet/pops/issues.rb +0 -5
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -8
- data/lib/puppet/pops/model/ast.pp +0 -42
- data/lib/puppet/pops/model/ast.rb +0 -290
- data/lib/puppet/pops/model/factory.rb +0 -45
- data/lib/puppet/pops/model/model_label_provider.rb +0 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +0 -22
- data/lib/puppet/pops/model/pn_transformer.rb +0 -16
- data/lib/puppet/pops/parser/egrammar.ra +0 -56
- data/lib/puppet/pops/parser/eparser.rb +1520 -1712
- data/lib/puppet/pops/parser/lexer2.rb +4 -4
- data/lib/puppet/pops/parser/parser_support.rb +0 -5
- data/lib/puppet/pops/resource/resource_type_impl.rb +2 -24
- data/lib/puppet/pops/types/type_calculator.rb +0 -7
- data/lib/puppet/pops/types/type_parser.rb +0 -4
- data/lib/puppet/pops/types/types.rb +0 -1
- data/lib/puppet/pops/validation/checker4_0.rb +9 -37
- data/lib/puppet/pops/validation/tasks_checker.rb +0 -12
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -2
- data/lib/puppet/provider.rb +0 -13
- data/lib/puppet/provider/nameservice.rb +0 -18
- data/lib/puppet/provider/package/dpkg.rb +0 -10
- data/lib/puppet/provider/package/gem.rb +23 -3
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +0 -4
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +1 -4
- data/lib/puppet/provider/service/smf.rb +191 -73
- data/lib/puppet/provider/user/directoryservice.rb +0 -10
- data/lib/puppet/reference/configuration.rb +2 -0
- data/lib/puppet/reference/indirection.rb +1 -1
- data/lib/puppet/resource.rb +1 -89
- data/lib/puppet/resource/catalog.rb +1 -14
- data/lib/puppet/resource/type.rb +3 -119
- data/lib/puppet/resource/type_collection.rb +3 -48
- data/lib/puppet/runtime.rb +1 -2
- data/lib/puppet/settings.rb +45 -33
- data/lib/puppet/settings/base_setting.rb +26 -2
- data/lib/puppet/settings/integer_setting.rb +17 -0
- data/lib/puppet/settings/port_setting.rb +15 -0
- data/lib/puppet/settings/priority_setting.rb +5 -4
- data/lib/puppet/ssl.rb +10 -6
- data/lib/puppet/ssl/base.rb +3 -5
- data/lib/puppet/ssl/certificate.rb +0 -6
- data/lib/puppet/ssl/certificate_request.rb +1 -12
- data/lib/puppet/ssl/certificate_signer.rb +6 -0
- data/lib/puppet/ssl/oids.rb +3 -1
- data/lib/puppet/ssl/ssl_provider.rb +17 -0
- data/lib/puppet/ssl/state_machine.rb +3 -1
- data/lib/puppet/ssl/verifier.rb +2 -0
- data/lib/puppet/test/test_helper.rb +1 -3
- data/lib/puppet/transaction.rb +1 -7
- data/lib/puppet/transaction/report.rb +2 -4
- data/lib/puppet/type.rb +0 -76
- data/lib/puppet/type/file.rb +5 -7
- data/lib/puppet/type/file/checksum.rb +1 -1
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/filebucket.rb +3 -3
- data/lib/puppet/type/package.rb +5 -13
- data/lib/puppet/util/execution.rb +0 -11
- data/lib/puppet/util/http_proxy.rb +2 -215
- data/lib/puppet/util/monkey_patches.rb +0 -46
- data/lib/puppet/util/rdoc.rb +0 -7
- data/lib/puppet/util/retry_action.rb +1 -1
- data/lib/puppet/util/rubygems.rb +5 -1
- data/lib/puppet/util/run_mode.rb +9 -1
- data/lib/puppet/util/windows.rb +3 -8
- data/lib/puppet/util/windows/daemon.rb +360 -0
- data/lib/puppet/util/windows/error.rb +1 -0
- data/lib/puppet/util/windows/eventlog.rb +4 -9
- data/lib/puppet/util/windows/file.rb +8 -242
- data/lib/puppet/util/windows/monkey_patches/process.rb +414 -0
- data/lib/puppet/util/windows/process.rb +4 -226
- data/lib/puppet/util/windows/service.rb +9 -460
- data/lib/puppet/util/windows/string.rb +12 -13
- data/lib/puppet/util/yaml.rb +0 -22
- data/lib/puppet/vendor/require_vendored.rb +0 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet/x509.rb +5 -1
- data/lib/puppet/x509/cert_provider.rb +29 -1
- data/locales/puppet.pot +531 -1232
- data/man/man5/puppet.conf.5 +37 -97
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +55 -9
- data/man/man8/puppet-filebucket.8 +6 -6
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-module.8 +1 -58
- data/man/man8/puppet-node.8 +4 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +4 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/service/smf/{svcs.out → svcs_instances.out} +0 -0
- data/spec/integration/application/agent_spec.rb +24 -11
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/application/filebucket_spec.rb +16 -16
- data/spec/integration/application/help_spec.rb +2 -0
- data/spec/integration/application/plugin_spec.rb +23 -1
- data/spec/integration/defaults_spec.rb +7 -3
- data/spec/integration/environments/setting_hooks_spec.rb +1 -1
- data/spec/integration/network/http_pool_spec.rb +3 -21
- data/spec/integration/parser/catalog_spec.rb +0 -38
- data/spec/integration/parser/node_spec.rb +0 -9
- data/spec/integration/parser/pcore_resource_spec.rb +0 -37
- data/spec/integration/type/file_spec.rb +5 -4
- data/spec/integration/util/windows/monkey_patches/process_spec.rb +231 -0
- data/spec/integration/util/windows/security_spec.rb +1 -1
- data/spec/lib/puppet_spec/puppetserver.rb +1 -1
- data/spec/lib/puppet_spec/settings.rb +7 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/agent_spec.rb +0 -2
- data/spec/unit/application/config_spec.rb +224 -4
- data/spec/unit/application/facts_spec.rb +35 -0
- data/spec/unit/application/filebucket_spec.rb +41 -39
- data/spec/unit/application/ssl_spec.rb +2 -2
- data/spec/unit/certificate_factory_spec.rb +1 -1
- data/spec/unit/configurer/downloader_spec.rb +6 -2
- data/spec/unit/configurer/plugin_handler_spec.rb +56 -18
- data/spec/unit/configurer_spec.rb +12 -9
- data/spec/unit/context/trusted_information_spec.rb +2 -6
- data/spec/unit/defaults_spec.rb +77 -28
- data/spec/unit/environments_spec.rb +0 -3
- data/spec/unit/face/config_spec.rb +27 -32
- data/spec/unit/face/facts_spec.rb +4 -0
- data/spec/unit/face/plugin_spec.rb +73 -33
- data/spec/unit/file_bucket/file_spec.rb +1 -1
- data/spec/unit/file_serving/configuration/parser_spec.rb +14 -18
- data/spec/unit/file_serving/configuration_spec.rb +6 -12
- data/spec/unit/functions/camelcase_spec.rb +1 -1
- data/spec/unit/functions/capitalize_spec.rb +1 -1
- data/spec/unit/functions/downcase_spec.rb +1 -1
- data/spec/unit/functions/inline_epp_spec.rb +26 -1
- data/spec/unit/functions/upcase_spec.rb +1 -1
- data/spec/unit/http/client_spec.rb +7 -8
- data/spec/unit/{network/resolver_spec.rb → http/dns_spec.rb} +3 -3
- data/spec/unit/http/external_client_spec.rb +4 -4
- data/spec/unit/{network/http → http}/factory_spec.rb +5 -11
- data/spec/unit/{network/http/session_spec.rb → http/pool_entry_spec.rb} +3 -3
- data/spec/unit/{network/http → http}/pool_spec.rb +12 -17
- data/spec/unit/{util/http_proxy_spec.rb → http/proxy_spec.rb} +2 -69
- data/spec/unit/http/resolver_spec.rb +13 -13
- data/spec/unit/http/service/compiler_spec.rb +49 -62
- data/spec/unit/http/service/file_server_spec.rb +3 -3
- data/spec/unit/http/service/puppetserver_spec.rb +34 -4
- data/spec/unit/http/service_spec.rb +1 -2
- data/spec/unit/http/session_spec.rb +16 -14
- data/spec/unit/{network/http → http}/site_spec.rb +3 -3
- data/spec/unit/indirector/facts/facter_spec.rb +97 -0
- data/spec/unit/indirector/facts/json_spec.rb +255 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +5 -3
- data/spec/unit/indirector/file_content/rest_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/rest_spec.rb +0 -4
- data/spec/unit/indirector/file_server_spec.rb +1 -15
- data/spec/unit/indirector/node/json_spec.rb +33 -0
- data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
- data/spec/unit/indirector/report/rest_spec.rb +2 -17
- data/spec/unit/indirector/report/yaml_spec.rb +72 -8
- data/spec/unit/indirector/request_spec.rb +0 -264
- data/spec/unit/indirector/rest_spec.rb +98 -752
- data/spec/unit/network/authconfig_spec.rb +2 -132
- data/spec/unit/network/authorization_spec.rb +2 -55
- data/spec/unit/network/formats_spec.rb +4 -4
- data/spec/unit/network/http/api/indirected_routes_spec.rb +1 -97
- data/spec/unit/network/http/api/master/v3_spec.rb +28 -7
- data/spec/unit/network/http/api_spec.rb +10 -0
- data/spec/unit/network/http/connection_spec.rb +19 -41
- data/spec/unit/network/http/handler_spec.rb +0 -6
- data/spec/unit/network/http_pool_spec.rb +0 -4
- data/spec/unit/node/environment_spec.rb +33 -21
- data/spec/unit/node_spec.rb +2 -54
- data/spec/unit/parser/functions/create_resources_spec.rb +2 -20
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +4 -7
- data/spec/unit/pops/loaders/loaders_spec.rb +6 -21
- data/spec/unit/pops/parser/parse_application_spec.rb +4 -22
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +0 -1
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +8 -21
- data/spec/unit/pops/parser/parse_site_spec.rb +20 -24
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +0 -71
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +6 -6
- data/spec/unit/pops/types/type_factory_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +61 -46
- data/spec/unit/pops/visitor_spec.rb +1 -1
- data/spec/unit/provider/nameservice_spec.rb +0 -57
- data/spec/unit/provider/package/dpkg_spec.rb +0 -48
- data/spec/unit/provider/package/gem_spec.rb +32 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +3 -2
- data/spec/unit/provider/service/smf_spec.rb +401 -165
- data/spec/unit/provider/service/windows_spec.rb +0 -1
- data/spec/unit/provider_spec.rb +0 -12
- data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
- data/spec/unit/resource/type_collection_spec.rb +2 -22
- data/spec/unit/resource_spec.rb +0 -56
- data/spec/unit/settings/http_extra_headers_spec.rb +2 -4
- data/spec/unit/settings/integer_setting_spec.rb +42 -0
- data/spec/unit/settings/port_setting_spec.rb +31 -0
- data/spec/unit/settings/priority_setting_spec.rb +4 -4
- data/spec/unit/settings_spec.rb +423 -236
- data/spec/unit/ssl/base_spec.rb +36 -3
- data/spec/unit/ssl/certificate_request_spec.rb +15 -45
- data/spec/unit/ssl/certificate_spec.rb +2 -11
- data/spec/unit/ssl/ssl_provider_spec.rb +11 -8
- data/spec/unit/ssl/state_machine_spec.rb +0 -1
- data/spec/unit/ssl/verifier_spec.rb +0 -21
- data/spec/unit/transaction/report_spec.rb +0 -2
- data/spec/unit/transaction/resource_harness_spec.rb +2 -2
- data/spec/unit/transaction_spec.rb +45 -79
- data/spec/unit/type/file/checksum_spec.rb +6 -6
- data/spec/unit/type/file/content_spec.rb +1 -1
- data/spec/unit/type/file/ensure_spec.rb +1 -1
- data/spec/unit/type/file/mode_spec.rb +1 -1
- data/spec/unit/type/file/source_spec.rb +0 -1
- data/spec/unit/type/file_spec.rb +12 -6
- data/spec/unit/type/package_spec.rb +1 -1
- data/spec/unit/type_spec.rb +20 -0
- data/spec/unit/util/backups_spec.rb +0 -2
- data/spec/unit/util/execution_spec.rb +0 -29
- data/spec/unit/util/monkey_patches_spec.rb +0 -6
- data/spec/unit/util/rubygems_spec.rb +2 -2
- data/spec/unit/util/run_mode_spec.rb +21 -121
- data/spec/unit/util/windows/string_spec.rb +1 -3
- data/spec/unit/util/yaml_spec.rb +0 -54
- data/spec/unit/util_spec.rb +0 -18
- metadata +50 -176
- data/conf/auth.conf +0 -150
- data/lib/puppet/application/cert.rb +0 -76
- data/lib/puppet/application/key.rb +0 -4
- data/lib/puppet/application/man.rb +0 -4
- data/lib/puppet/application/status.rb +0 -4
- data/lib/puppet/face/key.rb +0 -16
- data/lib/puppet/face/man.rb +0 -145
- data/lib/puppet/face/module/build.rb +0 -14
- data/lib/puppet/face/module/generate.rb +0 -14
- data/lib/puppet/face/module/search.rb +0 -103
- data/lib/puppet/face/status.rb +0 -51
- data/lib/puppet/indirector/certificate/file.rb +0 -9
- data/lib/puppet/indirector/certificate/rest.rb +0 -18
- data/lib/puppet/indirector/certificate_request/file.rb +0 -9
- data/lib/puppet/indirector/certificate_request/memory.rb +0 -7
- data/lib/puppet/indirector/certificate_request/rest.rb +0 -11
- data/lib/puppet/indirector/file_content/http.rb +0 -22
- data/lib/puppet/indirector/key/file.rb +0 -46
- data/lib/puppet/indirector/key/memory.rb +0 -7
- data/lib/puppet/indirector/ssl_file.rb +0 -162
- data/lib/puppet/indirector/status.rb +0 -3
- data/lib/puppet/indirector/status/local.rb +0 -12
- data/lib/puppet/indirector/status/rest.rb +0 -27
- data/lib/puppet/module_tool/applications/searcher.rb +0 -29
- data/lib/puppet/network/auth_config_parser.rb +0 -90
- data/lib/puppet/network/authstore.rb +0 -283
- data/lib/puppet/network/http/api/master/v3/authorization.rb +0 -18
- data/lib/puppet/network/http/api/master/v3/environment.rb +0 -88
- data/lib/puppet/network/http/base_pool.rb +0 -36
- data/lib/puppet/network/http/compression.rb +0 -127
- data/lib/puppet/network/http/connection_adapter.rb +0 -184
- data/lib/puppet/network/http/nocache_pool.rb +0 -28
- data/lib/puppet/network/rest_controller.rb +0 -2
- data/lib/puppet/network/rights.rb +0 -210
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +0 -66
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +0 -22
- data/lib/puppet/parser/environment_compiler.rb +0 -202
- data/lib/puppet/pops/types/enumeration.rb +0 -16
- data/lib/puppet/resource/capability_finder.rb +0 -154
- data/lib/puppet/rest/errors.rb +0 -15
- data/lib/puppet/rest/response.rb +0 -35
- data/lib/puppet/rest/route.rb +0 -85
- data/lib/puppet/rest/routes.rb +0 -135
- data/lib/puppet/ssl/host.rb +0 -505
- data/lib/puppet/ssl/key.rb +0 -61
- data/lib/puppet/ssl/validator.rb +0 -61
- data/lib/puppet/ssl/validator/default_validator.rb +0 -209
- data/lib/puppet/ssl/validator/no_validator.rb +0 -22
- data/lib/puppet/ssl/verifier_adapter.rb +0 -58
- data/lib/puppet/status.rb +0 -40
- data/lib/puppet/util/connection.rb +0 -88
- data/lib/puppet/util/ssl.rb +0 -83
- data/lib/puppet/util/windows/api_types.rb +0 -309
- data/lib/puppet/util/windows/monkey_patches/dir.rb +0 -40
- data/lib/puppet/vendor/load_pathspec.rb +0 -1
- data/lib/puppet/vendor/pathspec/CHANGELOG.md +0 -2
- data/lib/puppet/vendor/pathspec/LICENSE +0 -201
- data/lib/puppet/vendor/pathspec/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/pathspec/README.md +0 -53
- data/lib/puppet/vendor/pathspec/lib/pathspec.rb +0 -122
- data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +0 -275
- data/lib/puppet/vendor/pathspec/lib/pathspec/regexspec.rb +0 -17
- data/lib/puppet/vendor/pathspec/lib/pathspec/spec.rb +0 -14
- data/man/man8/puppet-key.8 +0 -126
- data/man/man8/puppet-man.8 +0 -76
- data/man/man8/puppet-status.8 +0 -108
- data/spec/integration/application/config_spec.rb +0 -74
- data/spec/integration/network/authconfig_spec.rb +0 -256
- data/spec/integration/util/windows/monkey_patches/dir_spec.rb +0 -11
- data/spec/unit/application/man_spec.rb +0 -52
- data/spec/unit/capability_spec.rb +0 -414
- data/spec/unit/face/catalog_spec.rb +0 -6
- data/spec/unit/face/key_spec.rb +0 -9
- data/spec/unit/face/module/search_spec.rb +0 -231
- data/spec/unit/face/module_spec.rb +0 -3
- data/spec/unit/face/status_spec.rb +0 -9
- data/spec/unit/indirector/certificate/file_spec.rb +0 -14
- data/spec/unit/indirector/certificate/rest_spec.rb +0 -61
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -14
- data/spec/unit/indirector/certificate_request/rest_spec.rb +0 -25
- data/spec/unit/indirector/key/file_spec.rb +0 -79
- data/spec/unit/indirector/ssl_file_spec.rb +0 -305
- data/spec/unit/indirector/status/local_spec.rb +0 -10
- data/spec/unit/indirector/status/rest_spec.rb +0 -50
- data/spec/unit/module_tool/applications/searcher_spec.rb +0 -38
- data/spec/unit/network/auth_config_parser_spec.rb +0 -115
- data/spec/unit/network/authstore_spec.rb +0 -422
- data/spec/unit/network/http/api/master/v3/authorization_spec.rb +0 -57
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +0 -185
- data/spec/unit/network/http/compression_spec.rb +0 -240
- data/spec/unit/network/http/nocache_pool_spec.rb +0 -64
- data/spec/unit/network/http_spec.rb +0 -9
- data/spec/unit/network/rights_spec.rb +0 -439
- data/spec/unit/parser/environment_compiler_spec.rb +0 -730
- data/spec/unit/pops/types/enumeration_spec.rb +0 -51
- data/spec/unit/resource/capability_finder_spec.rb +0 -143
- data/spec/unit/rest/route_spec.rb +0 -132
- data/spec/unit/ssl/host_spec.rb +0 -650
- data/spec/unit/ssl/key_spec.rb +0 -173
- data/spec/unit/ssl/validator_spec.rb +0 -278
- data/spec/unit/status_spec.rb +0 -45
- data/spec/unit/util/ssl_spec.rb +0 -91
data/spec/unit/provider_spec.rb
CHANGED
@@ -670,18 +670,6 @@ describe Puppet::Provider do
|
|
670
670
|
|
671
671
|
provider.send(:execpipe, "a_command", true, block)
|
672
672
|
end
|
673
|
-
|
674
|
-
it "delegates instance execfail to Puppet::Util::Execution" do
|
675
|
-
expect(Puppet::Util::Execution).to receive(:execfail).with("a_command", "an exception to raise")
|
676
|
-
|
677
|
-
provider.new.send(:execfail, "a_command", "an exception to raise")
|
678
|
-
end
|
679
|
-
|
680
|
-
it "delegates class execfail to Puppet::Util::Execution" do
|
681
|
-
expect(Puppet::Util::Execution).to receive(:execfail).with("a_command", "an exception to raise")
|
682
|
-
|
683
|
-
provider.send(:execfail, "a_command", "an exception to raise")
|
684
|
-
end
|
685
673
|
end
|
686
674
|
|
687
675
|
context "mk_resource_methods" do
|
@@ -69,6 +69,51 @@ describe 'Puppet Pal' do
|
|
69
69
|
}.to raise_error(/manifest_file or code_string cannot be given when configured_by_env is true/)
|
70
70
|
end
|
71
71
|
|
72
|
+
it 'shadows target variables that collide with plan variables' do
|
73
|
+
facts = { 'var' => 'fact' }
|
74
|
+
target_vars = { 'var' => 'target' }
|
75
|
+
|
76
|
+
expect(Puppet).to receive(:warning).with(/Target variable \$var will be overridden by fact of the same name/)
|
77
|
+
|
78
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', facts: {}) do |ctx|
|
79
|
+
ctx.with_catalog_compiler(facts: facts, target_variables: target_vars ) do |c|
|
80
|
+
c.evaluate_string('$var')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
expect(result).to eq('fact')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'shadows target variables that collide with facts' do
|
88
|
+
plan_vars = { 'var' => 'plan' }
|
89
|
+
target_vars = { 'var' => 'target' }
|
90
|
+
|
91
|
+
expect(Puppet).to receive(:warning).with(/Target variable \$var will be overridden by plan variable of the same name/)
|
92
|
+
|
93
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', facts: {}) do |ctx|
|
94
|
+
ctx.with_catalog_compiler(variables: plan_vars, target_variables: target_vars ) do |c|
|
95
|
+
c.evaluate_string('$var')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
expect(result).to eq('plan')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'shadows plan variables that collide with facts' do
|
103
|
+
facts = { 'var' => 'fact' }
|
104
|
+
plan_vars = { 'var' => 'plan' }
|
105
|
+
|
106
|
+
expect(Puppet).to receive(:warning).with(/Plan variable \$var will be overridden by fact of the same name/)
|
107
|
+
|
108
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', facts: {}) do |ctx|
|
109
|
+
ctx.with_catalog_compiler(facts: facts, variables: plan_vars ) do |c|
|
110
|
+
c.evaluate_string('$var')
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
expect(result).to eq('fact')
|
115
|
+
end
|
116
|
+
|
72
117
|
context "evaluate_string method" do
|
73
118
|
it 'evaluates code string in a given tmp environment' do
|
74
119
|
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do |ctx|
|
@@ -75,18 +75,16 @@ describe Puppet::Resource::TypeCollection do
|
|
75
75
|
end.to raise_error(Puppet::ParseError, /cannot be redefined/)
|
76
76
|
end
|
77
77
|
|
78
|
-
it "should remove all nodes, classes
|
78
|
+
it "should remove all nodes, classes and definitions when cleared" do
|
79
79
|
loader = Puppet::Resource::TypeCollection.new(environment)
|
80
80
|
loader.add Puppet::Resource::Type.new(:hostclass, "class")
|
81
81
|
loader.add Puppet::Resource::Type.new(:definition, "define")
|
82
82
|
loader.add Puppet::Resource::Type.new(:node, "node")
|
83
|
-
loader.add Puppet::Resource::Type.new(:application, "application")
|
84
83
|
|
85
84
|
loader.clear
|
86
85
|
expect(loader.hostclass("class")).to be_nil
|
87
86
|
expect(loader.definition("define")).to be_nil
|
88
87
|
expect(loader.node("node")).to be_nil
|
89
|
-
expect(loader.node("application")).to be_nil
|
90
88
|
end
|
91
89
|
|
92
90
|
describe "when looking up names" do
|
@@ -155,7 +153,7 @@ describe Puppet::Resource::TypeCollection do
|
|
155
153
|
end
|
156
154
|
end
|
157
155
|
|
158
|
-
KINDS = %w{hostclass node definition
|
156
|
+
KINDS = %w{hostclass node definition}
|
159
157
|
KINDS.each do |data|
|
160
158
|
describe "behavior of add for #{data}" do
|
161
159
|
|
@@ -178,24 +176,6 @@ describe Puppet::Resource::TypeCollection do
|
|
178
176
|
it "should return nil when asked for a #{data} that has not been added" do
|
179
177
|
expect(Puppet::Resource::TypeCollection.new(environment).send(data, "foo")).to be_nil
|
180
178
|
end
|
181
|
-
|
182
|
-
if data != "node"
|
183
|
-
it "should fail if an application with the same name is added" do
|
184
|
-
loader = Puppet::Resource::TypeCollection.new(environment)
|
185
|
-
instance = Puppet::Resource::Type.new(data, "foo")
|
186
|
-
application = Puppet::Resource::Type.new(:application, "foo")
|
187
|
-
loader.add(instance)
|
188
|
-
expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should fail if there is an application with the same name" do
|
192
|
-
loader = Puppet::Resource::TypeCollection.new(environment)
|
193
|
-
application = Puppet::Resource::Type.new(:application, "foo")
|
194
|
-
instance = Puppet::Resource::Type.new(data, "foo")
|
195
|
-
loader.add(instance)
|
196
|
-
expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
|
197
|
-
end
|
198
|
-
end
|
199
179
|
end
|
200
180
|
end
|
201
181
|
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -286,39 +286,6 @@ describe Puppet::Resource do
|
|
286
286
|
Puppet::Parser::AST::Leaf.new(value: value)
|
287
287
|
end
|
288
288
|
|
289
|
-
it "should fail when asked to set default values and it is not a parser resource" do
|
290
|
-
environment.known_resource_types.add(
|
291
|
-
Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("default")})
|
292
|
-
)
|
293
|
-
resource = Puppet::Resource.new("default_param", "name", :environment => environment)
|
294
|
-
expect { resource.set_default_parameters(scope) }.to raise_error(Puppet::DevError)
|
295
|
-
end
|
296
|
-
|
297
|
-
it "should evaluate and set any default values when no value is provided" do
|
298
|
-
environment.known_resource_types.add(
|
299
|
-
Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("a_default_value")})
|
300
|
-
)
|
301
|
-
resource = Puppet::Parser::Resource.new("default_param", "name", :scope => scope)
|
302
|
-
resource.set_default_parameters(scope)
|
303
|
-
expect(resource["a"]).to eq("a_default_value")
|
304
|
-
end
|
305
|
-
|
306
|
-
it "should skip attributes with no default value" do
|
307
|
-
environment.known_resource_types.add(
|
308
|
-
Puppet::Resource::Type.new(:definition, "no_default_param", :arguments => {"a" => ast_leaf("a_default_value")})
|
309
|
-
)
|
310
|
-
resource = Puppet::Parser::Resource.new("no_default_param", "name", :scope => scope)
|
311
|
-
expect { resource.set_default_parameters(scope) }.not_to raise_error
|
312
|
-
end
|
313
|
-
|
314
|
-
it "should return the list of default parameters set" do
|
315
|
-
environment.known_resource_types.add(
|
316
|
-
Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => ast_leaf("a_default_value")})
|
317
|
-
)
|
318
|
-
resource = Puppet::Parser::Resource.new("default_param", "name", :scope => scope)
|
319
|
-
expect(resource.set_default_parameters(scope)).to eq(["a"])
|
320
|
-
end
|
321
|
-
|
322
289
|
describe "when the resource type is :hostclass" do
|
323
290
|
let(:environment_name) { "testing env" }
|
324
291
|
let(:fact_values) { { :a => 1 } }
|
@@ -405,7 +372,6 @@ describe Puppet::Resource do
|
|
405
372
|
|
406
373
|
it "should use the value provided" do
|
407
374
|
expect(Puppet::DataBinding.indirection).not_to receive(:find)
|
408
|
-
expect(resource.set_default_parameters(scope)).to eq([])
|
409
375
|
expect(resource[:port]).to eq('8080')
|
410
376
|
end
|
411
377
|
|
@@ -447,28 +413,6 @@ describe Puppet::Resource do
|
|
447
413
|
end
|
448
414
|
end
|
449
415
|
|
450
|
-
describe "when validating all required parameters are present" do
|
451
|
-
it "should be able to validate that all required parameters are present" do
|
452
|
-
environment.known_resource_types.add(
|
453
|
-
Puppet::Resource::Type.new(:definition, "required_param", :arguments => {"a" => nil})
|
454
|
-
)
|
455
|
-
expect { Puppet::Resource.new("required_param", "name", :environment => environment).validate_complete }.to raise_error(Puppet::ParseError)
|
456
|
-
end
|
457
|
-
|
458
|
-
it "should not fail when all required parameters are present" do
|
459
|
-
environment.known_resource_types.add(
|
460
|
-
Puppet::Resource::Type.new(:definition, "no_required_param")
|
461
|
-
)
|
462
|
-
resource = Puppet::Resource.new("no_required_param", "name", :environment => environment)
|
463
|
-
resource["a"] = "meh"
|
464
|
-
expect { resource.validate_complete }.not_to raise_error
|
465
|
-
end
|
466
|
-
|
467
|
-
it "should not validate against builtin types" do
|
468
|
-
expect { Puppet::Resource.new("file", "/bar").validate_complete }.not_to raise_error
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
416
|
describe "when referring to a resource with name canonicalization" do
|
473
417
|
it "should canonicalize its own name" do
|
474
418
|
res = Puppet::Resource.new("file", "/path/")
|
@@ -46,18 +46,16 @@ describe Puppet::Settings::HttpExtraHeadersSetting do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe 'raises an error when' do
|
49
|
-
|
50
|
-
# Ruby 2.3 reports the class of these objects as Fixnum, whereas later ruby versions report them as Integer
|
51
49
|
it 'is given an unexpected object type' do
|
52
50
|
expect {
|
53
51
|
subject.munge(65)
|
54
|
-
}.to raise_error(ArgumentError, /^Expected an Array, String, or Hash, got a
|
52
|
+
}.to raise_error(ArgumentError, /^Expected an Array, String, or Hash, got a Integer/)
|
55
53
|
end
|
56
54
|
|
57
55
|
it 'is given an array of unexpected object types' do
|
58
56
|
expect {
|
59
57
|
subject.munge([65, 82])
|
60
|
-
}.to raise_error(ArgumentError, /^Expected an Array or String, got a
|
58
|
+
}.to raise_error(ArgumentError, /^Expected an Array or String, got a Integer/)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'puppet/settings'
|
4
|
+
require 'puppet/settings/integer_setting'
|
5
|
+
|
6
|
+
describe Puppet::Settings::IntegerSetting do
|
7
|
+
let(:setting) { described_class.new(:settings => double('settings'), :desc => "test") }
|
8
|
+
|
9
|
+
it "is of type :integer" do
|
10
|
+
expect(setting.type).to eq(:integer)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "when munging the setting" do
|
14
|
+
it "returns the same value if given a positive integer" do
|
15
|
+
expect(setting.munge(5)).to eq(5)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns the same value if given a negative integer" do
|
19
|
+
expect(setting.munge(-25)).to eq(-25)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns an integer if given a valid integer as string" do
|
23
|
+
expect(setting.munge('12')).to eq(12)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns an integer if given a valid negative integer as string" do
|
27
|
+
expect(setting.munge('-12')).to eq(-12)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns an integer if given a valid positive integer as string" do
|
31
|
+
expect(setting.munge('+12')).to eq(12)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises if given an invalid value" do
|
35
|
+
expect { setting.munge('a5') }.to raise_error(Puppet::Settings::ValidationError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "raises if given nil" do
|
39
|
+
expect { setting.munge(nil) }.to raise_error(Puppet::Settings::ValidationError)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'puppet/settings'
|
4
|
+
require 'puppet/settings/port_setting'
|
5
|
+
|
6
|
+
describe Puppet::Settings::PortSetting do
|
7
|
+
let(:setting) { described_class.new(:settings => double('settings'), :desc => "test") }
|
8
|
+
|
9
|
+
it "is of type :port" do
|
10
|
+
expect(setting.type).to eq(:port)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "when munging the setting" do
|
14
|
+
it "returns the same value if given a valid port as integer" do
|
15
|
+
expect(setting.munge(5)).to eq(5)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns an integer if given valid port as string" do
|
19
|
+
expect(setting.munge('12')).to eq(12)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "raises if given a negative port number" do
|
23
|
+
expect { setting.munge('-5') }.to raise_error(Puppet::Settings::ValidationError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises if the port number is too high" do
|
27
|
+
expect { setting.munge(65536) }.to raise_error(Puppet::Settings::ValidationError)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -52,10 +52,10 @@ describe Puppet::Settings::PrioritySetting do
|
|
52
52
|
describe "on a Windows-like platform it", :if => Puppet::Util::Platform.windows? do
|
53
53
|
it "parses high, normal, low, and idle priorities" do
|
54
54
|
{
|
55
|
-
'high' => Puppet::
|
56
|
-
'normal' => Puppet::
|
57
|
-
'low' => Puppet::
|
58
|
-
'idle' => Puppet::
|
55
|
+
'high' => Puppet::FFI::Windows::Constants::HIGH_PRIORITY_CLASS,
|
56
|
+
'normal' => Puppet::FFI::Windows::Constants::NORMAL_PRIORITY_CLASS,
|
57
|
+
'low' => Puppet::FFI::Windows::Constants::BELOW_NORMAL_PRIORITY_CLASS,
|
58
|
+
'idle' => Puppet::FFI::Windows::Constants::IDLE_PRIORITY_CLASS
|
59
59
|
}.each do |value, converted_value|
|
60
60
|
expect(setting.munge(value)).to eq(converted_value)
|
61
61
|
end
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -87,16 +87,7 @@ describe Puppet::Settings do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
90
|
describe "when initializing application defaults do" do
|
92
|
-
let(:default_values) do
|
93
|
-
values = {}
|
94
|
-
PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
|
95
|
-
values[key] = 'default value'
|
96
|
-
end
|
97
|
-
values
|
98
|
-
end
|
99
|
-
|
100
91
|
before do
|
101
92
|
@settings = Puppet::Settings.new
|
102
93
|
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
@@ -104,7 +95,7 @@ describe Puppet::Settings do
|
|
104
95
|
|
105
96
|
it "should fail if the app defaults hash is missing any required values" do
|
106
97
|
expect {
|
107
|
-
@settings.initialize_app_defaults(
|
98
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.reject { |key, _| key == :confdir })
|
108
99
|
}.to raise_error(Puppet::Settings::SettingsError)
|
109
100
|
end
|
110
101
|
|
@@ -112,7 +103,7 @@ describe Puppet::Settings do
|
|
112
103
|
# case behaviors / uses. However, until that time... we need to make sure that our private run_mode=
|
113
104
|
# setter method gets properly called during app initialization.
|
114
105
|
it "sets the preferred run mode when initializing the app defaults" do
|
115
|
-
@settings.initialize_app_defaults(
|
106
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
|
116
107
|
|
117
108
|
expect(@settings.preferred_run_mode).to eq(:server)
|
118
109
|
end
|
@@ -121,7 +112,7 @@ describe Puppet::Settings do
|
|
121
112
|
# initialize_app_defaults is called in spec_helper, before we even
|
122
113
|
# get here, but call it here to make it explicit what we're trying
|
123
114
|
# to do.
|
124
|
-
@settings.initialize_app_defaults(
|
115
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
125
116
|
|
126
117
|
Puppet::Settings::REQUIRED_APP_SETTINGS.each do |key|
|
127
118
|
expect(File).to exist(File.dirname(Puppet[key]))
|
@@ -148,6 +139,7 @@ describe Puppet::Settings do
|
|
148
139
|
end.to_not raise_error
|
149
140
|
end
|
150
141
|
end
|
142
|
+
|
151
143
|
describe "if no interpolation error" do
|
152
144
|
it "should not raise an error" do
|
153
145
|
hook_values = []
|
@@ -177,6 +169,7 @@ describe Puppet::Settings do
|
|
177
169
|
@settings.send(:call_hooks_deferred_to_application_initialization, options)
|
178
170
|
end.to raise_error(Puppet::Settings::InterpolationError)
|
179
171
|
end
|
172
|
+
|
180
173
|
it "should contain the setting name in error message" do
|
181
174
|
hook_values = []
|
182
175
|
@settings.define_settings(
|
@@ -193,6 +186,7 @@ describe Puppet::Settings do
|
|
193
186
|
end.to raise_error(Puppet::Settings::InterpolationError, /badhook/)
|
194
187
|
end
|
195
188
|
end
|
189
|
+
|
196
190
|
describe "if no interpolation error" do
|
197
191
|
it "should not raise an error" do
|
198
192
|
hook_values = []
|
@@ -397,122 +391,320 @@ describe Puppet::Settings do
|
|
397
391
|
end
|
398
392
|
|
399
393
|
describe "call_hook" do
|
394
|
+
let(:config_file) { tmpfile('config') }
|
395
|
+
|
396
|
+
before :each do
|
397
|
+
# We can't specify the config file to read from using `Puppet[:config] =`
|
398
|
+
# or pass it as an arg to Puppet.initialize_global_settings, because
|
399
|
+
# both of those will set the value on the `Puppet.settings` instance
|
400
|
+
# which is different from the `@settings` instance created in the test.
|
401
|
+
# Instead, we define a `:config` setting and set its default value to
|
402
|
+
# the `config_file` temp file, and then access the `config_file` within
|
403
|
+
# each test.
|
404
|
+
@settings.define_settings(:main, :config => { :type => :file, :desc => "config file", :default => config_file })
|
405
|
+
end
|
406
|
+
|
400
407
|
Puppet::Settings::StringSetting.available_call_hook_values.each do |val|
|
401
408
|
describe "when :#{val}" do
|
402
409
|
describe "and definition invalid" do
|
403
410
|
it "should raise error if no hook defined" do
|
404
411
|
expect do
|
405
|
-
@settings.define_settings(:section, :
|
412
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val})
|
406
413
|
end.to raise_error(ArgumentError, /no :hook/)
|
407
414
|
end
|
415
|
+
|
408
416
|
it "should include the setting name in the error message" do
|
409
417
|
expect do
|
410
|
-
@settings.define_settings(:section, :
|
411
|
-
end.to raise_error(ArgumentError, /for :
|
418
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val})
|
419
|
+
end.to raise_error(ArgumentError, /for :setting/)
|
412
420
|
end
|
413
421
|
end
|
422
|
+
|
414
423
|
describe "and definition valid" do
|
415
424
|
before(:each) do
|
416
425
|
hook_values = []
|
417
|
-
@settings.define_settings(:section, :
|
426
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => val, :hook => lambda { |v| hook_values << v }})
|
418
427
|
end
|
419
428
|
|
420
429
|
it "should call the hook when value written" do
|
421
|
-
expect(@settings.setting(:
|
422
|
-
@settings[:
|
430
|
+
expect(@settings.setting(:setting)).to receive(:handle).with("something").once
|
431
|
+
@settings[:setting] = "something"
|
423
432
|
end
|
424
433
|
end
|
425
434
|
end
|
426
435
|
end
|
427
436
|
|
428
437
|
it "should have a default value of :on_write_only" do
|
429
|
-
@settings.define_settings(:section, :
|
430
|
-
expect(@settings.setting(:
|
438
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
|
439
|
+
expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
|
431
440
|
end
|
432
441
|
|
433
442
|
describe "when nil" do
|
434
443
|
it "should generate a warning" do
|
435
444
|
expect(Puppet).to receive(:warning)
|
436
|
-
@settings.define_settings(:section, :
|
445
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
|
437
446
|
end
|
447
|
+
|
438
448
|
it "should use default" do
|
439
|
-
@settings.define_settings(:section, :
|
440
|
-
expect(@settings.setting(:
|
449
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => nil, :hook => lambda { |v| hook_values << v }})
|
450
|
+
expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
|
441
451
|
end
|
442
452
|
end
|
443
453
|
|
444
454
|
describe "when invalid" do
|
445
455
|
it "should raise an error" do
|
446
456
|
expect do
|
447
|
-
@settings.define_settings(:section, :
|
457
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => :foo, :hook => lambda { |v| hook_values << v }})
|
448
458
|
end.to raise_error(ArgumentError, /invalid.*call_hook/i)
|
449
459
|
end
|
450
460
|
end
|
451
461
|
|
462
|
+
describe "when :on_write_only" do
|
463
|
+
it "returns its hook type" do
|
464
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |_| }})
|
465
|
+
|
466
|
+
expect(@settings.setting(:setting).call_hook).to eq(:on_write_only)
|
467
|
+
end
|
468
|
+
|
469
|
+
it "should not call the hook at definition" do
|
470
|
+
hook_values = []
|
471
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
|
472
|
+
|
473
|
+
expect(hook_values).to eq(%w[])
|
474
|
+
end
|
475
|
+
|
476
|
+
it "calls the hook when initializing global defaults with the value from the `main` section" do
|
477
|
+
hook_values = []
|
478
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
|
479
|
+
|
480
|
+
File.write(config_file, <<~END)
|
481
|
+
[main]
|
482
|
+
setting=in_main
|
483
|
+
END
|
484
|
+
@settings.initialize_global_settings
|
485
|
+
|
486
|
+
expect(@settings[:setting]).to eq('in_main')
|
487
|
+
expect(hook_values).to eq(%w[in_main])
|
488
|
+
end
|
489
|
+
|
490
|
+
it "doesn't call the hook when initializing app defaults" do
|
491
|
+
hook_values = []
|
492
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
493
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
|
494
|
+
|
495
|
+
File.write(config_file, <<~END)
|
496
|
+
[main]
|
497
|
+
setting=in_main
|
498
|
+
[agent]
|
499
|
+
setting=in_agent
|
500
|
+
END
|
501
|
+
@settings.initialize_global_settings
|
502
|
+
|
503
|
+
hook_values.clear
|
504
|
+
|
505
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
506
|
+
|
507
|
+
expect(@settings[:setting]).to eq('in_main')
|
508
|
+
expect(hook_values).to eq(%w[])
|
509
|
+
end
|
510
|
+
|
511
|
+
it "doesn't call the hook with value from a section that matches the run_mode" do
|
512
|
+
hook_values = []
|
513
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
514
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| hook_values << v }})
|
515
|
+
|
516
|
+
File.write(config_file, <<~END)
|
517
|
+
[main]
|
518
|
+
setting=in_main
|
519
|
+
[agent]
|
520
|
+
setting=in_agent
|
521
|
+
END
|
522
|
+
@settings.initialize_global_settings
|
523
|
+
|
524
|
+
hook_values.clear
|
525
|
+
|
526
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
|
527
|
+
|
528
|
+
expect(@settings[:setting]).to eq('in_agent')
|
529
|
+
expect(hook_values).to eq(%w[])
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
452
533
|
describe "when :on_define_and_write" do
|
453
|
-
it "
|
534
|
+
it "returns its hook type" do
|
535
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |_| }})
|
536
|
+
|
537
|
+
expect(@settings.setting(:setting).call_hook).to eq(:on_define_and_write)
|
538
|
+
end
|
539
|
+
|
540
|
+
it "should call the hook at definition with the default value" do
|
454
541
|
hook_values = []
|
455
|
-
@settings.define_settings(:
|
456
|
-
|
457
|
-
expect(hook_values).to eq(%w
|
542
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
|
543
|
+
|
544
|
+
expect(hook_values).to eq(%w[yay])
|
545
|
+
end
|
546
|
+
|
547
|
+
it "calls the hook when initializing global defaults with the value from the `main` section" do
|
548
|
+
hook_values = []
|
549
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
|
550
|
+
|
551
|
+
File.write(config_file, <<~END)
|
552
|
+
[main]
|
553
|
+
setting=in_main
|
554
|
+
END
|
555
|
+
@settings.initialize_global_settings
|
556
|
+
|
557
|
+
expect(@settings[:setting]).to eq('in_main')
|
558
|
+
expect(hook_values).to eq(%w[yay in_main])
|
559
|
+
end
|
560
|
+
|
561
|
+
it "doesn't call the hook when initializing app defaults" do
|
562
|
+
hook_values = []
|
563
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
564
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
|
565
|
+
|
566
|
+
File.write(config_file, <<~END)
|
567
|
+
[main]
|
568
|
+
setting=in_main
|
569
|
+
[agent]
|
570
|
+
setting=in_agent
|
571
|
+
END
|
572
|
+
@settings.initialize_global_settings
|
573
|
+
|
574
|
+
hook_values.clear
|
575
|
+
|
576
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
577
|
+
|
578
|
+
expect(@settings[:setting]).to eq('in_main')
|
579
|
+
expect(hook_values).to eq([])
|
580
|
+
end
|
581
|
+
|
582
|
+
it "doesn't call the hook with value from a section that matches the run_mode" do
|
583
|
+
hook_values = []
|
584
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
585
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| hook_values << v }})
|
586
|
+
|
587
|
+
File.write(config_file, <<~END)
|
588
|
+
[main]
|
589
|
+
setting=in_main
|
590
|
+
[agent]
|
591
|
+
setting=in_agent
|
592
|
+
END
|
593
|
+
|
594
|
+
@settings.initialize_global_settings
|
595
|
+
|
596
|
+
hook_values.clear
|
597
|
+
|
598
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
|
599
|
+
|
600
|
+
# The correct value is returned
|
601
|
+
expect(@settings[:setting]).to eq('in_agent')
|
602
|
+
|
603
|
+
# but the hook is never called, seems like a bug!
|
604
|
+
expect(hook_values).to eq([])
|
458
605
|
end
|
459
606
|
end
|
460
607
|
|
461
608
|
describe "when :on_initialize_and_write" do
|
462
|
-
|
463
|
-
@
|
464
|
-
|
609
|
+
it "returns its hook type" do
|
610
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |_| }})
|
611
|
+
|
612
|
+
expect(@settings.setting(:setting).call_hook).to eq(:on_initialize_and_write)
|
465
613
|
end
|
466
614
|
|
467
615
|
it "should not call the hook at definition" do
|
468
|
-
|
469
|
-
|
616
|
+
hook_values = []
|
617
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
|
618
|
+
expect(hook_values).to eq([])
|
470
619
|
end
|
471
620
|
|
472
|
-
it "
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
621
|
+
it "calls the hook when initializing global defaults with the value from the `main` section" do
|
622
|
+
hook_values = []
|
623
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
|
624
|
+
|
625
|
+
File.write(config_file, <<~END)
|
626
|
+
[main]
|
627
|
+
setting=in_main
|
628
|
+
END
|
629
|
+
@settings.initialize_global_settings
|
630
|
+
|
631
|
+
expect(@settings[:setting]).to eq('in_main')
|
632
|
+
expect(hook_values).to eq(%w[in_main])
|
633
|
+
end
|
634
|
+
|
635
|
+
it "calls the hook when initializing app defaults" do
|
636
|
+
hook_values = []
|
637
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
638
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
|
639
|
+
|
640
|
+
File.write(config_file, <<~END)
|
641
|
+
[main]
|
642
|
+
setting=in_main
|
643
|
+
[agent]
|
644
|
+
setting=in_agent
|
645
|
+
END
|
646
|
+
@settings.initialize_global_settings
|
647
|
+
|
648
|
+
hook_values.clear
|
649
|
+
|
650
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
651
|
+
|
652
|
+
expect(@settings[:setting]).to eq('in_main')
|
653
|
+
expect(hook_values).to eq(%w[in_main])
|
654
|
+
end
|
655
|
+
|
656
|
+
it "calls the hook with the overridden value from a section that matches the run_mode" do
|
657
|
+
hook_values = []
|
478
658
|
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
659
|
+
@settings.define_settings(:main, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_initialize_and_write, :hook => lambda { |v| hook_values << v }})
|
660
|
+
|
661
|
+
File.write(config_file, <<~END)
|
662
|
+
[main]
|
663
|
+
setting=in_main
|
664
|
+
[agent]
|
665
|
+
setting=in_agent
|
666
|
+
END
|
667
|
+
@settings.initialize_global_settings
|
668
|
+
|
669
|
+
hook_values.clear
|
479
670
|
|
480
|
-
|
671
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
|
481
672
|
|
482
|
-
@settings.
|
673
|
+
expect(@settings[:setting]).to eq('in_agent')
|
674
|
+
expect(hook_values).to eq(%w[in_agent])
|
483
675
|
end
|
484
676
|
end
|
485
677
|
end
|
486
678
|
|
487
679
|
it "should call passed blocks when values are set" do
|
488
680
|
values = []
|
489
|
-
@settings.define_settings(:section, :
|
681
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
|
490
682
|
expect(values).to eq([])
|
491
683
|
|
492
|
-
@settings[:
|
684
|
+
@settings[:setting] = "something"
|
493
685
|
expect(values).to eq(%w{something})
|
494
686
|
end
|
495
687
|
|
496
688
|
it "should call passed blocks when values are set via the command line" do
|
497
689
|
values = []
|
498
|
-
@settings.define_settings(:section, :
|
690
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
|
499
691
|
expect(values).to eq([])
|
500
692
|
|
501
|
-
@settings.handlearg("--
|
693
|
+
@settings.handlearg("--setting", "yay")
|
502
694
|
|
503
695
|
expect(values).to eq(%w{yay})
|
504
696
|
end
|
505
697
|
|
506
698
|
it "should provide an option to call passed blocks during definition" do
|
507
699
|
values = []
|
508
|
-
@settings.define_settings(:section, :
|
700
|
+
@settings.define_settings(:section, :setting => {:default => "yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
|
509
701
|
expect(values).to eq(%w{yay})
|
510
702
|
end
|
511
703
|
|
512
704
|
it "should pass the fully interpolated value to the hook when called on definition" do
|
513
705
|
values = []
|
514
706
|
@settings.define_settings(:section, :one => { :default => "test", :desc => "a" })
|
515
|
-
@settings.define_settings(:section, :
|
707
|
+
@settings.define_settings(:section, :setting => {:default => "$one/yay", :desc => "boo", :call_hook => :on_define_and_write, :hook => lambda { |v| values << v }})
|
516
708
|
expect(values).to eq(%w{test/yay})
|
517
709
|
end
|
518
710
|
|
@@ -561,12 +753,8 @@ describe Puppet::Settings do
|
|
561
753
|
end
|
562
754
|
|
563
755
|
it "setting a value to nil causes it to return to its default" do
|
564
|
-
default_values = { :one => "skipped value" }
|
565
|
-
[:logdir, :confdir, :codedir, :vardir].each do |key|
|
566
|
-
default_values[key] = 'default value'
|
567
|
-
end
|
568
756
|
@settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
|
569
|
-
@settings.initialize_app_defaults(
|
757
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:one => "skipped value"))
|
570
758
|
@settings[:one] = "value will disappear"
|
571
759
|
|
572
760
|
@settings[:one] = nil
|
@@ -627,13 +815,14 @@ describe Puppet::Settings do
|
|
627
815
|
end
|
628
816
|
|
629
817
|
describe "when choosing which value to return" do
|
818
|
+
let(:config_file) { tmpfile('settings') }
|
819
|
+
|
630
820
|
before do
|
631
821
|
@settings = Puppet::Settings.new
|
632
822
|
@settings.define_settings :section,
|
633
|
-
:config => { :type => :file, :default =>
|
823
|
+
:config => { :type => :file, :default => config_file, :desc => "a" },
|
634
824
|
:one => { :default => "ONE", :desc => "a" },
|
635
825
|
:two => { :default => "TWO", :desc => "b" }
|
636
|
-
allow(Puppet::FileSystem).to receive(:exist?).and_return(true)
|
637
826
|
@settings.preferred_run_mode = :agent
|
638
827
|
end
|
639
828
|
|
@@ -642,18 +831,16 @@ describe Puppet::Settings do
|
|
642
831
|
end
|
643
832
|
|
644
833
|
it "should return values set on the cli before values set in the configuration file" do
|
645
|
-
|
646
|
-
allow(@settings).to receive(:read_file).and_return(text)
|
834
|
+
File.write(config_file, "[main]\none = fileval\n")
|
647
835
|
@settings.handlearg("--one", "clival")
|
648
|
-
@settings.
|
836
|
+
@settings.initialize_global_settings
|
649
837
|
|
650
838
|
expect(@settings[:one]).to eq("clival")
|
651
839
|
end
|
652
840
|
|
653
841
|
it "should return values set in the mode-specific section before values set in the main section" do
|
654
|
-
|
655
|
-
|
656
|
-
@settings.send(:parse_config_files)
|
842
|
+
File.write(config_file, "[main]\none = mainval\n[agent]\none = modeval\n")
|
843
|
+
@settings.initialize_global_settings
|
657
844
|
|
658
845
|
expect(@settings[:one]).to eq("modeval")
|
659
846
|
end
|
@@ -663,17 +850,15 @@ describe Puppet::Settings do
|
|
663
850
|
before(:each) { @settings.preferred_run_mode = run_mode }
|
664
851
|
|
665
852
|
it "returns values set in the 'master' section if the 'server' section does not exist" do
|
666
|
-
|
667
|
-
|
668
|
-
@settings.send(:parse_config_files)
|
853
|
+
File.write(config_file, "[main]\none = mainval\n[master]\none = modeval\n")
|
854
|
+
@settings.initialize_global_settings
|
669
855
|
|
670
856
|
expect(@settings[:one]).to eq("modeval")
|
671
857
|
end
|
672
858
|
|
673
859
|
it "prioritizes values set in the 'server' section if set" do
|
674
|
-
|
675
|
-
|
676
|
-
@settings.send(:parse_config_files)
|
860
|
+
File.write(config_file, "[main]\none = mainval\n[server]\none = serverval\n[master]\none = masterval\n")
|
861
|
+
@settings.initialize_global_settings
|
677
862
|
|
678
863
|
expect(@settings[:one]).to eq("serverval")
|
679
864
|
end
|
@@ -681,9 +866,9 @@ describe Puppet::Settings do
|
|
681
866
|
end
|
682
867
|
|
683
868
|
it "should not return values outside of its search path" do
|
684
|
-
|
685
|
-
|
686
|
-
|
869
|
+
File.write(config_file, "[other]\none = oval\n")
|
870
|
+
@settings.initialize_global_settings
|
871
|
+
|
687
872
|
expect(@settings[:one]).to eq("ONE")
|
688
873
|
end
|
689
874
|
|
@@ -705,7 +890,7 @@ describe Puppet::Settings do
|
|
705
890
|
expect(Puppet::FileSystem).to receive(:exist?).with(main_config_file_default_location).and_return(false)
|
706
891
|
expect(Puppet::FileSystem).not_to receive(:exist?).with(user_config_file_default_location)
|
707
892
|
|
708
|
-
@settings.
|
893
|
+
@settings.initialize_global_settings
|
709
894
|
end
|
710
895
|
end
|
711
896
|
|
@@ -715,7 +900,7 @@ describe Puppet::Settings do
|
|
715
900
|
|
716
901
|
expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
|
717
902
|
|
718
|
-
@settings.
|
903
|
+
@settings.initialize_global_settings
|
719
904
|
end
|
720
905
|
end
|
721
906
|
|
@@ -724,7 +909,7 @@ describe Puppet::Settings do
|
|
724
909
|
expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(true)
|
725
910
|
expect(@settings).to receive(:read_file).and_raise('Permission denied')
|
726
911
|
|
727
|
-
expect{ @settings.
|
912
|
+
expect{ @settings.initialize_global_settings }.to raise_error(RuntimeError, /Could not load #{user_config_file_default_location}: Permission denied/)
|
728
913
|
end
|
729
914
|
|
730
915
|
it "does not fail if the file is not readable and when `require_config` is false" do
|
@@ -734,7 +919,7 @@ describe Puppet::Settings do
|
|
734
919
|
expect(@settings).not_to receive(:parse_config)
|
735
920
|
expect(Puppet).to receive(:log_exception)
|
736
921
|
|
737
|
-
expect{ @settings.
|
922
|
+
expect{ @settings.initialize_global_settings([], false) }.not_to raise_error
|
738
923
|
end
|
739
924
|
|
740
925
|
it "reads the file if it is readable" do
|
@@ -742,7 +927,7 @@ describe Puppet::Settings do
|
|
742
927
|
expect(@settings).to receive(:read_file).and_return('server = host.string')
|
743
928
|
expect(@settings).to receive(:parse_config)
|
744
929
|
|
745
|
-
@settings.
|
930
|
+
@settings.initialize_global_settings
|
746
931
|
end
|
747
932
|
end
|
748
933
|
|
@@ -751,7 +936,7 @@ describe Puppet::Settings do
|
|
751
936
|
expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
|
752
937
|
expect(@settings).not_to receive(:parse_config)
|
753
938
|
|
754
|
-
@settings.
|
939
|
+
@settings.initialize_global_settings
|
755
940
|
end
|
756
941
|
end
|
757
942
|
end
|
@@ -761,43 +946,41 @@ describe Puppet::Settings do
|
|
761
946
|
@settings = Puppet::Settings.new
|
762
947
|
allow(@settings).to receive(:service_user_available?).and_return(true)
|
763
948
|
allow(@settings).to receive(:service_group_available?).and_return(true)
|
764
|
-
@file =
|
765
|
-
@userconfig = make_absolute("/test/userconfigfile")
|
949
|
+
@file = tmpfile("somefile")
|
766
950
|
@settings.define_settings :section, :user => { :default => "suser", :desc => "doc" }, :group => { :default => "sgroup", :desc => "doc" }
|
767
951
|
@settings.define_settings :section,
|
768
952
|
:config => { :type => :file, :default => @file, :desc => "eh" },
|
769
953
|
:one => { :default => "ONE", :desc => "a" },
|
770
954
|
:two => { :default => "$one TWO", :desc => "b" },
|
771
955
|
:three => { :default => "$one $two THREE", :desc => "c" }
|
772
|
-
|
773
|
-
|
774
|
-
allow(
|
956
|
+
|
957
|
+
userconfig = tmpfile("userconfig")
|
958
|
+
allow(@settings).to receive(:user_config_file).and_return(userconfig)
|
775
959
|
end
|
776
960
|
|
777
961
|
it "should not ignore the report setting" do
|
778
962
|
@settings.define_settings :section, :report => { :default => "false", :desc => "a" }
|
779
|
-
|
780
|
-
myfile = File.expand_path(@file)
|
781
|
-
@settings[:config] = myfile
|
782
|
-
text = <<-CONF
|
963
|
+
File.write(@file, <<~CONF)
|
783
964
|
[puppetd]
|
784
|
-
|
965
|
+
report=true
|
785
966
|
CONF
|
786
|
-
|
787
|
-
|
788
|
-
|
967
|
+
|
968
|
+
@settings.initialize_global_settings
|
969
|
+
|
789
970
|
expect(@settings[:report]).to be_truthy
|
790
971
|
end
|
791
972
|
|
792
973
|
it "should use its current ':config' value for the file to parse" do
|
793
|
-
myfile =
|
794
|
-
|
795
|
-
|
796
|
-
|
974
|
+
myfile = tmpfile('myfile')
|
975
|
+
File.write(myfile, <<~CONF)
|
976
|
+
[main]
|
977
|
+
one=myfile
|
978
|
+
CONF
|
797
979
|
|
798
|
-
|
980
|
+
@settings[:config] = myfile
|
981
|
+
@settings.initialize_global_settings
|
799
982
|
|
800
|
-
@settings.
|
983
|
+
expect(@settings[:one]).to eq('myfile')
|
801
984
|
end
|
802
985
|
|
803
986
|
it "should not try to parse non-existent files" do
|
@@ -805,42 +988,50 @@ describe Puppet::Settings do
|
|
805
988
|
|
806
989
|
expect(File).not_to receive(:read).with(@file)
|
807
990
|
|
808
|
-
@settings.
|
991
|
+
@settings.initialize_global_settings
|
809
992
|
end
|
810
993
|
|
811
994
|
it "should return values set in the configuration file" do
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
995
|
+
File.write(@file, <<~CONF)
|
996
|
+
[main]
|
997
|
+
one = fileval
|
998
|
+
CONF
|
999
|
+
|
1000
|
+
@settings.initialize_global_settings
|
817
1001
|
expect(@settings[:one]).to eq("fileval")
|
818
1002
|
end
|
819
1003
|
|
820
1004
|
#484 - this should probably be in the regression area
|
821
1005
|
it "should not throw an exception on unknown parameters" do
|
822
|
-
|
823
|
-
|
824
|
-
|
1006
|
+
File.write(@file, <<~CONF)
|
1007
|
+
[main]
|
1008
|
+
nosuchparam = mval
|
1009
|
+
CONF
|
1010
|
+
|
1011
|
+
expect { @settings.initialize_global_settings }.not_to raise_error
|
825
1012
|
end
|
826
1013
|
|
827
1014
|
it "should convert booleans in the configuration file into Ruby booleans" do
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
1015
|
+
File.write(@file, <<~CONF)
|
1016
|
+
[main]
|
1017
|
+
one = true
|
1018
|
+
two = false
|
1019
|
+
CONF
|
1020
|
+
|
1021
|
+
@settings.initialize_global_settings
|
1022
|
+
|
834
1023
|
expect(@settings[:one]).to eq(true)
|
835
1024
|
expect(@settings[:two]).to eq(false)
|
836
1025
|
end
|
837
1026
|
|
838
1027
|
it "should convert integers in the configuration file into Ruby Integers" do
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
1028
|
+
File.write(@file, <<~CONF)
|
1029
|
+
[main]
|
1030
|
+
one = 65
|
1031
|
+
CONF
|
1032
|
+
|
1033
|
+
@settings.initialize_global_settings
|
1034
|
+
|
844
1035
|
expect(@settings[:one]).to eq(65)
|
845
1036
|
end
|
846
1037
|
|
@@ -871,25 +1062,21 @@ describe Puppet::Settings do
|
|
871
1062
|
end
|
872
1063
|
|
873
1064
|
it "should support loading metadata (owner, group, or mode) from a run_mode section in the configuration file" do
|
874
|
-
default_values = {}
|
875
|
-
PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
|
876
|
-
default_values[key] = 'default value'
|
877
|
-
end
|
878
1065
|
@settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
|
879
1066
|
@settings.define_settings :server, :myfile => { :type => :file, :default => make_absolute("/myfile"), :desc => "a" }
|
880
1067
|
|
881
1068
|
otherfile = make_absolute("/other/file")
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
1069
|
+
File.write(@file, <<~CONF)
|
1070
|
+
[server]
|
1071
|
+
myfile = #{otherfile} {mode = 664}
|
1072
|
+
CONF
|
886
1073
|
|
887
1074
|
# will start initialization as user
|
888
1075
|
expect(@settings.preferred_run_mode).to eq(:user)
|
889
|
-
@settings.
|
1076
|
+
@settings.initialize_global_settings
|
890
1077
|
|
891
1078
|
# change app run_mode to server
|
892
|
-
@settings.initialize_app_defaults(
|
1079
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
|
893
1080
|
expect(@settings.preferred_run_mode).to eq(:server)
|
894
1081
|
|
895
1082
|
# initializing the app should have reloaded the metadata based on run_mode
|
@@ -899,18 +1086,18 @@ describe Puppet::Settings do
|
|
899
1086
|
|
900
1087
|
context "when setting serverport and masterport" do
|
901
1088
|
before(:each) do
|
902
|
-
default_values = {}
|
903
|
-
PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
|
904
|
-
default_values[key] = 'default value'
|
905
|
-
end
|
906
1089
|
@settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
|
907
1090
|
@settings.define_settings :server, :masterport => { :desc => "a", :default => 1000 }
|
908
1091
|
@settings.define_settings :server, :serverport => { :desc => "a", :default => 1000 }
|
909
1092
|
@settings.define_settings :server, :ca_port => { :desc => "a", :default => "$serverport" }
|
910
1093
|
@settings.define_settings :server, :report_port => { :desc => "a", :default => "$serverport" }
|
911
|
-
|
912
|
-
|
913
|
-
@settings
|
1094
|
+
|
1095
|
+
config_file = tmpfile('config')
|
1096
|
+
@settings[:config] = config_file
|
1097
|
+
File.write(config_file, text)
|
1098
|
+
|
1099
|
+
@settings.initialize_global_settings
|
1100
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
|
914
1101
|
expect(@settings.preferred_run_mode).to eq(:agent)
|
915
1102
|
end
|
916
1103
|
|
@@ -1036,29 +1223,24 @@ describe Puppet::Settings do
|
|
1036
1223
|
end
|
1037
1224
|
|
1038
1225
|
it "does not use the metadata from the same setting in a different section" do
|
1039
|
-
default_values = {}
|
1040
|
-
PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
|
1041
|
-
default_values[key] = 'default value'
|
1042
|
-
end
|
1043
|
-
|
1044
1226
|
file = make_absolute("/file")
|
1045
1227
|
default_mode = "0600"
|
1046
1228
|
@settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
|
1047
1229
|
@settings.define_settings :server, :myfile => { :type => :file, :default => file, :desc => "a", :mode => default_mode }
|
1048
1230
|
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1231
|
+
File.write(@file, <<~CONF)
|
1232
|
+
[server]
|
1233
|
+
myfile = #{file}/foo
|
1234
|
+
[agent]
|
1235
|
+
myfile = #{file} {mode = 664}
|
1236
|
+
CONF
|
1055
1237
|
|
1056
1238
|
# will start initialization as user
|
1057
1239
|
expect(@settings.preferred_run_mode).to eq(:user)
|
1058
|
-
@settings.
|
1240
|
+
@settings.initialize_global_settings
|
1059
1241
|
|
1060
1242
|
# change app run_mode to server
|
1061
|
-
@settings.initialize_app_defaults(
|
1243
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
|
1062
1244
|
expect(@settings.preferred_run_mode).to eq(:server)
|
1063
1245
|
|
1064
1246
|
# initializing the app should have reloaded the metadata based on run_mode
|
@@ -1070,11 +1252,12 @@ describe Puppet::Settings do
|
|
1070
1252
|
values = []
|
1071
1253
|
@settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
|
1072
1254
|
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
@settings.
|
1255
|
+
File.write(@file, <<~CONF)
|
1256
|
+
[main]
|
1257
|
+
mysetting = setval
|
1258
|
+
CONF
|
1259
|
+
@settings.initialize_global_settings
|
1260
|
+
|
1078
1261
|
expect(values).to eq(["setval"])
|
1079
1262
|
end
|
1080
1263
|
|
@@ -1082,13 +1265,14 @@ describe Puppet::Settings do
|
|
1082
1265
|
values = []
|
1083
1266
|
@settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
|
1084
1267
|
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
@settings.
|
1268
|
+
File.write(@file, <<~CONF)
|
1269
|
+
[user]
|
1270
|
+
mysetting = setval
|
1271
|
+
[main]
|
1272
|
+
mysetting = other
|
1273
|
+
CONF
|
1274
|
+
@settings.initialize_global_settings
|
1275
|
+
|
1092
1276
|
expect(values).to eq(["setval"])
|
1093
1277
|
end
|
1094
1278
|
|
@@ -1097,11 +1281,12 @@ describe Puppet::Settings do
|
|
1097
1281
|
@settings.define_settings :section, :base => {:default => "yay", :desc => "a", :hook => proc { |v| values << v }}
|
1098
1282
|
@settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
|
1099
1283
|
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
@settings.
|
1284
|
+
File.write(@file, <<~CONF)
|
1285
|
+
[main]
|
1286
|
+
mysetting = $base/setval
|
1287
|
+
CONF
|
1288
|
+
@settings.initialize_global_settings
|
1289
|
+
|
1105
1290
|
expect(values).to eq(["yay/setval"])
|
1106
1291
|
end
|
1107
1292
|
|
@@ -1111,23 +1296,25 @@ describe Puppet::Settings do
|
|
1111
1296
|
:hook => proc { |v| hook_invoked = true },
|
1112
1297
|
:call_hook => :on_initialize_and_write, }
|
1113
1298
|
|
1299
|
+
# This test relies on `confdir` defaulting to nil which causes the default
|
1300
|
+
# value of `deferred=$confdir/goose` to raise an interpolation error during
|
1301
|
+
# global initialization, and the hook to be skipped
|
1114
1302
|
@settings.define_settings(:main,
|
1115
|
-
|
1116
|
-
|
1117
|
-
:codedir => { :type => :directory, :default => nil, :desc => "codedir" },
|
1118
|
-
:vardir => { :type => :directory, :default => nil, :desc => "vardir" })
|
1303
|
+
PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.merge(
|
1304
|
+
:confdir => { :type => :directory, :default => nil, :desc => "confdir" }))
|
1119
1305
|
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1306
|
+
File.write(@file, <<~EOD)
|
1307
|
+
[main]
|
1308
|
+
deferred=$confdir/goose
|
1123
1309
|
EOD
|
1124
1310
|
|
1125
|
-
allow(@settings).to receive(:read_file).and_return(text)
|
1126
1311
|
@settings.initialize_global_settings
|
1127
1312
|
|
1128
1313
|
expect(hook_invoked).to be_falsey
|
1129
1314
|
|
1130
|
-
|
1315
|
+
# And now that we initialize app defaults with `confdir`, then `deferred`
|
1316
|
+
# can be interpolated and its hook called
|
1317
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
|
1131
1318
|
|
1132
1319
|
expect(hook_invoked).to be_truthy
|
1133
1320
|
expect(@settings[:deferred]).to eq(File.expand_path('/path/to/confdir/goose'))
|
@@ -1136,45 +1323,33 @@ describe Puppet::Settings do
|
|
1136
1323
|
it "does not require the value for a setting without a hook to resolve during global setup" do
|
1137
1324
|
@settings.define_settings :section, :can_cause_problems => {:desc => '' }
|
1138
1325
|
|
1139
|
-
@settings.define_settings(:main,
|
1140
|
-
:logdir => { :type => :directory, :default => nil, :desc => "logdir" },
|
1141
|
-
:confdir => { :type => :directory, :default => nil, :desc => "confdir" },
|
1142
|
-
:codedir => { :type => :directory, :default => nil, :desc => "codedir" },
|
1143
|
-
:vardir => { :type => :directory, :default => nil, :desc => "vardir" })
|
1326
|
+
@settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
1144
1327
|
|
1145
|
-
|
1328
|
+
File.write(@file, <<~EOD)
|
1146
1329
|
[main]
|
1147
1330
|
can_cause_problems=$confdir/goose
|
1148
1331
|
EOD
|
1149
1332
|
|
1150
|
-
allow(@settings).to receive(:read_file).and_return(text)
|
1151
1333
|
@settings.initialize_global_settings
|
1152
|
-
@settings.initialize_app_defaults(:
|
1334
|
+
@settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
|
1153
1335
|
|
1154
|
-
expect(@settings[:can_cause_problems]).to eq(
|
1336
|
+
expect(@settings[:can_cause_problems]).to eq('/path/to/confdir/goose')
|
1155
1337
|
end
|
1156
1338
|
|
1157
1339
|
it "should allow empty values" do
|
1158
1340
|
@settings.define_settings :section, :myarg => { :default => "myfile", :desc => "a" }
|
1159
1341
|
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
@settings.
|
1342
|
+
File.write(@file, <<~CONF)
|
1343
|
+
[main]
|
1344
|
+
myarg =
|
1345
|
+
CONF
|
1346
|
+
@settings.initialize_global_settings
|
1347
|
+
|
1165
1348
|
expect(@settings[:myarg]).to eq("")
|
1166
1349
|
end
|
1167
1350
|
|
1168
1351
|
describe "deprecations" do
|
1169
1352
|
let(:settings) { Puppet::Settings.new }
|
1170
|
-
let(:app_defaults) {
|
1171
|
-
{
|
1172
|
-
:logdir => "/dev/null",
|
1173
|
-
:confdir => "/dev/null",
|
1174
|
-
:codedir => "/dev/null",
|
1175
|
-
:vardir => "/dev/null",
|
1176
|
-
}
|
1177
|
-
}
|
1178
1353
|
|
1179
1354
|
def assert_accessing_setting_is_deprecated(settings, setting)
|
1180
1355
|
expect(Puppet).to receive(:deprecation_warning).with("Accessing '#{setting}' as a setting is deprecated.")
|
@@ -1184,12 +1359,7 @@ describe Puppet::Settings do
|
|
1184
1359
|
end
|
1185
1360
|
|
1186
1361
|
before(:each) do
|
1187
|
-
settings.define_settings(:main,
|
1188
|
-
:logdir => { :default => 'a', :desc => 'a' },
|
1189
|
-
:confdir => { :default => 'b', :desc => 'b' },
|
1190
|
-
:vardir => { :default => 'c', :desc => 'c' },
|
1191
|
-
:codedir => { :default => 'd', :desc => 'd' },
|
1192
|
-
})
|
1362
|
+
settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
|
1193
1363
|
end
|
1194
1364
|
|
1195
1365
|
context "complete" do
|
@@ -1210,7 +1380,7 @@ describe Puppet::Settings do
|
|
1210
1380
|
completely_deprecated_settings.parse_config(<<-CONF)
|
1211
1381
|
completely_deprecated_setting='should warn'
|
1212
1382
|
CONF
|
1213
|
-
completely_deprecated_settings.initialize_app_defaults(
|
1383
|
+
completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
1214
1384
|
end
|
1215
1385
|
|
1216
1386
|
it "warns when set on the commandline" do
|
@@ -1218,7 +1388,7 @@ describe Puppet::Settings do
|
|
1218
1388
|
|
1219
1389
|
args = ["--completely_deprecated_setting", "/some/value"]
|
1220
1390
|
completely_deprecated_settings.send(:parse_global_options, args)
|
1221
|
-
completely_deprecated_settings.initialize_app_defaults(
|
1391
|
+
completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
1222
1392
|
end
|
1223
1393
|
|
1224
1394
|
it "warns when set in code" do
|
@@ -1243,7 +1413,7 @@ describe Puppet::Settings do
|
|
1243
1413
|
partially_deprecated_settings.parse_config(<<-CONF)
|
1244
1414
|
partially_deprecated_setting='should warn'
|
1245
1415
|
CONF
|
1246
|
-
partially_deprecated_settings.initialize_app_defaults(
|
1416
|
+
partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
1247
1417
|
end
|
1248
1418
|
|
1249
1419
|
it "does not warn when manifest is set on command line" do
|
@@ -1251,7 +1421,7 @@ describe Puppet::Settings do
|
|
1251
1421
|
|
1252
1422
|
args = ["--partially_deprecated_setting", "/some/value"]
|
1253
1423
|
partially_deprecated_settings.send(:parse_global_options, args)
|
1254
|
-
partially_deprecated_settings.initialize_app_defaults(
|
1424
|
+
partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
|
1255
1425
|
end
|
1256
1426
|
|
1257
1427
|
it "warns when set in code" do
|
@@ -1344,23 +1514,24 @@ describe Puppet::Settings do
|
|
1344
1514
|
|
1345
1515
|
describe "when reparsing its configuration" do
|
1346
1516
|
before do
|
1347
|
-
@file =
|
1348
|
-
@
|
1517
|
+
@file = tmpfile("testfile")
|
1518
|
+
Puppet::FileSystem.touch(@file)
|
1519
|
+
|
1349
1520
|
@settings = Puppet::Settings.new
|
1350
1521
|
@settings.define_settings :section,
|
1351
1522
|
:config => { :type => :file, :default => @file, :desc => "a" },
|
1352
1523
|
:one => { :default => "ONE", :desc => "a" },
|
1353
1524
|
:two => { :default => "$one TWO", :desc => "b" },
|
1354
1525
|
:three => { :default => "$one $two THREE", :desc => "c" }
|
1355
|
-
|
1356
|
-
|
1357
|
-
allow(@settings).to receive(:user_config_file).and_return(
|
1526
|
+
|
1527
|
+
userconfig = tmpfile("userconfig")
|
1528
|
+
allow(@settings).to receive(:user_config_file).and_return(userconfig)
|
1358
1529
|
end
|
1359
1530
|
|
1360
1531
|
it "does not create the WatchedFile instance and should not parse if the file does not exist" do
|
1361
|
-
|
1362
|
-
expect(Puppet::Util::WatchedFile).not_to receive(:new)
|
1532
|
+
Puppet::FileSystem.unlink(@file)
|
1363
1533
|
|
1534
|
+
expect(Puppet::Util::WatchedFile).not_to receive(:new)
|
1364
1535
|
expect(@settings).not_to receive(:parse_config_files)
|
1365
1536
|
|
1366
1537
|
@settings.reparse_config_files
|
@@ -1399,8 +1570,8 @@ describe Puppet::Settings do
|
|
1399
1570
|
@settings[:one] = "init"
|
1400
1571
|
|
1401
1572
|
# Now replace the value
|
1402
|
-
|
1403
|
-
|
1573
|
+
File.write(@file, "[main]\none = disk-replace\n")
|
1574
|
+
|
1404
1575
|
@settings.reparse_config_files
|
1405
1576
|
expect(@settings[:one]).to eq("disk-replace")
|
1406
1577
|
end
|
@@ -1409,23 +1580,20 @@ describe Puppet::Settings do
|
|
1409
1580
|
it "should retain parameters set by cli when configuration files are reparsed" do
|
1410
1581
|
@settings.handlearg("--one", "clival")
|
1411
1582
|
|
1412
|
-
|
1413
|
-
|
1414
|
-
@settings.send(:parse_config_files)
|
1583
|
+
File.write(@file, "[main]\none = on-disk\n")
|
1584
|
+
@settings.initialize_global_settings
|
1415
1585
|
|
1416
1586
|
expect(@settings[:one]).to eq("clival")
|
1417
1587
|
end
|
1418
1588
|
|
1419
1589
|
it "should remove in-memory values that are no longer set in the file" do
|
1420
1590
|
# Init the value
|
1421
|
-
|
1422
|
-
expect(@settings).to receive(:read_file).and_return(text)
|
1591
|
+
File.write(@file, "[main]\none = disk-init\n")
|
1423
1592
|
@settings.send(:parse_config_files)
|
1424
1593
|
expect(@settings[:one]).to eq("disk-init")
|
1425
1594
|
|
1426
1595
|
# Now replace the value
|
1427
|
-
|
1428
|
-
expect(@settings).to receive(:read_file).and_return(text)
|
1596
|
+
File.write(@file, "[main]\ntwo = disk-replace\n")
|
1429
1597
|
@settings.send(:parse_config_files)
|
1430
1598
|
|
1431
1599
|
# The originally-overridden value should be replaced with the default
|
@@ -1437,14 +1605,12 @@ describe Puppet::Settings do
|
|
1437
1605
|
|
1438
1606
|
it "should retain in-memory values if the file has a syntax error" do
|
1439
1607
|
# Init the value
|
1440
|
-
|
1441
|
-
|
1442
|
-
@settings.send(:parse_config_files)
|
1608
|
+
File.write(@file, "[main]\none = initial-value\n")
|
1609
|
+
@settings.initialize_global_settings
|
1443
1610
|
expect(@settings[:one]).to eq("initial-value")
|
1444
1611
|
|
1445
1612
|
# Now replace the value with something bogus
|
1446
|
-
|
1447
|
-
expect(@settings).to receive(:read_file).with(@file).and_return(text)
|
1613
|
+
File.write(@file, "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n")
|
1448
1614
|
@settings.send(:parse_config_files)
|
1449
1615
|
|
1450
1616
|
# The originally-overridden value should not be replaced with the default
|
@@ -1456,46 +1622,49 @@ describe Puppet::Settings do
|
|
1456
1622
|
end
|
1457
1623
|
|
1458
1624
|
it "should provide a method for creating a catalog of resources from its configuration" do
|
1459
|
-
expect(Puppet::Settings.new).to
|
1625
|
+
expect(Puppet::Settings.new.to_catalog).to be_an_instance_of(Puppet::Resource::Catalog)
|
1460
1626
|
end
|
1461
1627
|
|
1462
1628
|
describe "when creating a catalog" do
|
1629
|
+
let(:maindir) { make_absolute('/maindir') }
|
1630
|
+
let(:seconddir) { make_absolute('/seconddir') }
|
1631
|
+
let(:otherdir) { make_absolute('/otherdir') }
|
1632
|
+
|
1463
1633
|
before do
|
1464
1634
|
@settings = Puppet::Settings.new
|
1465
1635
|
allow(@settings).to receive(:service_user_available?).and_return(true)
|
1466
|
-
@prefix = Puppet.features.posix? ? "" : "C:"
|
1467
1636
|
end
|
1468
1637
|
|
1469
1638
|
it "should add all file resources to the catalog if no sections have been specified" do
|
1470
1639
|
@settings.define_settings :main,
|
1471
|
-
:maindir => { :type => :directory, :default =>
|
1472
|
-
:seconddir => { :type => :directory, :default =>
|
1640
|
+
:maindir => { :type => :directory, :default => maindir, :desc => "a"},
|
1641
|
+
:seconddir => { :type => :directory, :default => seconddir, :desc => "a"}
|
1473
1642
|
@settings.define_settings :other,
|
1474
|
-
:otherdir => { :type => :directory, :default =>
|
1643
|
+
:otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
|
1475
1644
|
|
1476
1645
|
catalog = @settings.to_catalog
|
1477
1646
|
|
1478
|
-
[
|
1647
|
+
[maindir, seconddir, otherdir].each do |path|
|
1479
1648
|
expect(catalog.resource(:file, path)).to be_instance_of(Puppet::Resource)
|
1480
1649
|
end
|
1481
1650
|
end
|
1482
1651
|
|
1483
1652
|
it "should add only files in the specified sections if section names are provided" do
|
1484
|
-
@settings.define_settings :main, :maindir => { :type => :directory, :default =>
|
1485
|
-
@settings.define_settings :other, :otherdir => { :type => :directory, :default =>
|
1653
|
+
@settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
|
1654
|
+
@settings.define_settings :other, :otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
|
1486
1655
|
catalog = @settings.to_catalog(:main)
|
1487
|
-
expect(catalog.resource(:file,
|
1488
|
-
expect(catalog.resource(:file,
|
1656
|
+
expect(catalog.resource(:file, otherdir)).to be_nil
|
1657
|
+
expect(catalog.resource(:file, maindir)).to be_instance_of(Puppet::Resource)
|
1489
1658
|
end
|
1490
1659
|
|
1491
1660
|
it "should not try to add the same file twice" do
|
1492
|
-
@settings.define_settings :main, :maindir => { :type => :directory, :default =>
|
1493
|
-
@settings.define_settings :other, :otherdir => { :type => :directory, :default =>
|
1661
|
+
@settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
|
1662
|
+
@settings.define_settings :other, :otherdir => { :type => :directory, :default => maindir, :desc => "a" }
|
1494
1663
|
expect { @settings.to_catalog }.not_to raise_error
|
1495
1664
|
end
|
1496
1665
|
|
1497
1666
|
it "should ignore files whose :to_resource method returns nil" do
|
1498
|
-
@settings.define_settings :main, :maindir => { :type => :directory, :default =>
|
1667
|
+
@settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
|
1499
1668
|
expect(@settings.setting(:maindir)).to receive(:to_resource).and_return(nil)
|
1500
1669
|
|
1501
1670
|
expect_any_instance_of(Puppet::Resource::Catalog).not_to receive(:add_resource)
|
@@ -1525,6 +1694,7 @@ describe Puppet::Settings do
|
|
1525
1694
|
describe "adding default directory environment to the catalog" do
|
1526
1695
|
let(:tmpenv) { tmpdir("envs") }
|
1527
1696
|
let(:default_path) { "#{tmpenv}/environments" }
|
1697
|
+
|
1528
1698
|
before(:each) do
|
1529
1699
|
@settings.define_settings :main,
|
1530
1700
|
:environment => { :default => "production", :desc => "env"},
|
@@ -1814,6 +1984,23 @@ describe Puppet::Settings do
|
|
1814
1984
|
end
|
1815
1985
|
end
|
1816
1986
|
|
1987
|
+
describe 'when settings_catalog is disabled' do
|
1988
|
+
let(:settings) { Puppet::Settings.new }
|
1989
|
+
before do
|
1990
|
+
allow(Puppet).to receive(:[]).with(:settings_catalog).and_return(false)
|
1991
|
+
end
|
1992
|
+
|
1993
|
+
it 'does not compile and apply settings catalog' do
|
1994
|
+
expect(settings).not_to receive(:to_catalog)
|
1995
|
+
settings.use(:main)
|
1996
|
+
end
|
1997
|
+
|
1998
|
+
it 'logs a message that settings catalog is skipped' do
|
1999
|
+
expect(Puppet).to receive(:debug).with('Skipping settings catalog for sections main')
|
2000
|
+
settings.use(:main)
|
2001
|
+
end
|
2002
|
+
end
|
2003
|
+
|
1817
2004
|
describe "when dealing with printing configs" do
|
1818
2005
|
before do
|
1819
2006
|
@settings = Puppet::Settings.new
|