puppet 6.16.0-x64-mingw32 → 6.20.0-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CODEOWNERS +2 -16
- data/Gemfile +6 -2
- data/Gemfile.lock +40 -36
- data/README.md +3 -4
- data/Rakefile +4 -12
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/agent/locker.rb +0 -7
- data/lib/puppet/application.rb +10 -6
- data/lib/puppet/application/agent.rb +23 -6
- data/lib/puppet/application/apply.rb +20 -21
- data/lib/puppet/application/device.rb +1 -0
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/filebucket.rb +2 -2
- data/lib/puppet/application/lookup.rb +16 -4
- data/lib/puppet/application/script.rb +1 -0
- data/lib/puppet/application_support.rb +7 -0
- data/lib/puppet/configurer.rb +70 -20
- data/lib/puppet/configurer/downloader.rb +31 -10
- data/lib/puppet/confine.rb +2 -2
- data/lib/puppet/confine/any.rb +1 -1
- data/lib/puppet/defaults.rb +113 -46
- data/lib/puppet/environments.rb +84 -59
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/config.rb +56 -16
- data/lib/puppet/face/epp.rb +12 -2
- data/lib/puppet/face/facts.rb +60 -0
- data/lib/puppet/face/node.rb +3 -3
- data/lib/puppet/face/node/clean.rb +2 -2
- data/lib/puppet/face/status.rb +1 -1
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/ffi/posix.rb +10 -0
- data/lib/puppet/ffi/posix/constants.rb +14 -0
- data/lib/puppet/ffi/posix/functions.rb +24 -0
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/file_serving/http_metadata.rb +13 -1
- data/lib/puppet/file_serving/metadata.rb +4 -1
- data/lib/puppet/file_serving/mount/locales.rb +1 -2
- data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
- data/lib/puppet/file_serving/mount/plugins.rb +1 -2
- data/lib/puppet/file_serving/terminus_selector.rb +7 -8
- data/lib/puppet/file_system/file_impl.rb +4 -4
- data/lib/puppet/file_system/uniquefile.rb +8 -16
- data/lib/puppet/forge.rb +1 -1
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/repository.rb +3 -7
- data/lib/puppet/functions/epp.rb +1 -0
- data/lib/puppet/functions/inline_epp.rb +1 -0
- data/lib/puppet/functions/lstrip.rb +4 -4
- data/lib/puppet/functions/new.rb +8 -3
- data/lib/puppet/functions/reverse_each.rb +1 -1
- data/lib/puppet/functions/rstrip.rb +4 -4
- data/lib/puppet/functions/step.rb +1 -1
- data/lib/puppet/functions/strip.rb +4 -4
- data/lib/puppet/gettext/config.rb +5 -5
- data/lib/puppet/gettext/module_translations.rb +4 -4
- data/lib/puppet/http.rb +1 -0
- data/lib/puppet/http/client.rb +6 -1
- data/lib/puppet/http/redirector.rb +9 -7
- data/lib/puppet/http/resolver.rb +5 -8
- data/lib/puppet/http/resolver/server_list.rb +18 -36
- data/lib/puppet/http/resolver/settings.rb +4 -4
- data/lib/puppet/http/resolver/srv.rb +5 -5
- data/lib/puppet/http/response.rb +19 -0
- data/lib/puppet/http/service.rb +3 -1
- data/lib/puppet/http/service/compiler.rb +1 -1
- data/lib/puppet/http/service/file_server.rb +1 -1
- data/lib/puppet/http/service/puppetserver.rb +39 -0
- data/lib/puppet/http/session.rb +5 -4
- data/lib/puppet/indirector.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +1 -1
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/fact_search.rb +60 -0
- data/lib/puppet/indirector/facts/facter.rb +3 -3
- data/lib/puppet/indirector/facts/json.rb +27 -0
- data/lib/puppet/indirector/facts/yaml.rb +4 -59
- data/lib/puppet/indirector/file_content/rest.rb +1 -1
- data/lib/puppet/indirector/file_metadata/http.rb +25 -5
- data/lib/puppet/indirector/file_metadata/rest.rb +2 -2
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/indirection.rb +1 -1
- data/lib/puppet/indirector/json.rb +5 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/node/json.rb +8 -0
- data/lib/puppet/indirector/report/json.rb +34 -0
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/indirector/request.rb +5 -5
- data/lib/puppet/indirector/yaml.rb +1 -1
- data/lib/puppet/module.rb +1 -2
- data/lib/puppet/module_tool/applications/installer.rb +48 -2
- data/lib/puppet/module_tool/errors/shared.rb +17 -2
- data/lib/puppet/network/format_support.rb +2 -2
- data/lib/puppet/network/formats.rb +2 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +3 -0
- data/lib/puppet/network/http/api/master/v3/environments.rb +0 -1
- data/lib/puppet/network/http/connection_adapter.rb +6 -4
- data/lib/puppet/network/http/route.rb +2 -2
- data/lib/puppet/node/environment.rb +12 -5
- data/lib/puppet/node/facts.rb +17 -0
- data/lib/puppet/pal/pal_impl.rb +90 -13
- data/lib/puppet/parameter.rb +1 -1
- data/lib/puppet/parser/ast/leaf.rb +7 -6
- data/lib/puppet/parser/ast/pops_bridge.rb +0 -4
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +2 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +2 -0
- data/lib/puppet/parser/environment_compiler.rb +4 -1
- data/lib/puppet/parser/functions.rb +21 -17
- data/lib/puppet/parser/functions/create_resources.rb +11 -7
- data/lib/puppet/parser/resource.rb +3 -2
- data/lib/puppet/parser/resource/param.rb +6 -0
- data/lib/puppet/parser/templatewrapper.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +2 -2
- data/lib/puppet/pops/adaptable.rb +7 -13
- data/lib/puppet/pops/adapters.rb +8 -4
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +27 -8
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
- data/lib/puppet/pops/issues.rb +5 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +4 -2
- data/lib/puppet/pops/loaders.rb +18 -11
- data/lib/puppet/pops/lookup/context.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +14 -1
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +2 -0
- data/lib/puppet/pops/types/iterable.rb +34 -8
- data/lib/puppet/pops/types/p_meta_type.rb +1 -1
- data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
- data/lib/puppet/pops/validation/checker4_0.rb +29 -15
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +38 -0
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +4 -2
- data/lib/puppet/provider/package/pip2.rb +17 -0
- data/lib/puppet/provider/package/puppet_gem.rb +5 -0
- data/lib/puppet/provider/package/puppetserver_gem.rb +180 -0
- data/lib/puppet/provider/package/yum.rb +2 -1
- data/lib/puppet/provider/package/zypper.rb +3 -0
- data/lib/puppet/provider/service/windows.rb +23 -7
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +11 -4
- data/lib/puppet/provider/user/windows_adsi.rb +18 -1
- data/lib/puppet/reference/configuration.rb +6 -5
- data/lib/puppet/reports/http.rb +2 -0
- data/lib/puppet/resource.rb +2 -1
- data/lib/puppet/resource/type.rb +10 -1
- data/lib/puppet/rest/route.rb +2 -2
- data/lib/puppet/settings.rb +63 -21
- data/lib/puppet/settings/alias_setting.rb +37 -0
- data/lib/puppet/settings/base_setting.rb +26 -2
- data/lib/puppet/ssl/ssl_context.rb +2 -2
- data/lib/puppet/ssl/ssl_provider.rb +20 -1
- data/lib/puppet/ssl/validator/default_validator.rb +1 -1
- data/lib/puppet/test/test_helper.rb +18 -13
- data/lib/puppet/transaction.rb +2 -2
- data/lib/puppet/transaction/persistence.rb +1 -1
- data/lib/puppet/transaction/report.rb +12 -8
- data/lib/puppet/trusted_external.rb +29 -1
- data/lib/puppet/type.rb +15 -7
- data/lib/puppet/type/file.rb +40 -15
- data/lib/puppet/type/file/checksum.rb +4 -4
- data/lib/puppet/type/file/source.rb +32 -12
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/notify.rb +2 -2
- data/lib/puppet/type/service.rb +53 -0
- data/lib/puppet/type/user.rb +18 -3
- data/lib/puppet/util.rb +41 -3
- data/lib/puppet/util/autoload.rb +10 -15
- data/lib/puppet/util/character_encoding.rb +9 -5
- data/lib/puppet/util/checksums.rb +19 -4
- data/lib/puppet/util/connection.rb +8 -8
- data/lib/puppet/util/execution.rb +2 -2
- data/lib/puppet/util/fact_dif.rb +62 -0
- data/lib/puppet/util/fileparsing.rb +2 -2
- data/lib/puppet/util/posix.rb +54 -5
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/rubygems.rb +5 -1
- data/lib/puppet/util/run_mode.rb +5 -1
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/api_types.rb +60 -33
- data/lib/puppet/util/windows/eventlog.rb +1 -6
- data/lib/puppet/util/windows/monkey_patches/dir.rb +40 -0
- data/lib/puppet/util/windows/principal.rb +8 -6
- data/lib/puppet/util/windows/registry.rb +11 -11
- data/lib/puppet/util/windows/security.rb +4 -4
- data/lib/puppet/util/windows/service.rb +43 -26
- data/lib/puppet/util/windows/user.rb +242 -8
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +501 -443
- data/man/man5/puppet.conf.5 +70 -24
- data/man/man8/puppet-agent.8 +8 -5
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +6 -6
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +2 -2
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +32 -1
- data/man/man8/puppet-filebucket.8 +3 -3
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +2 -2
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +7 -4
- 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 +2 -2
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +2 -2
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
- data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/provider/applytest/applytest.rb +2 -0
- data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/type/applytest.rb +25 -0
- data/spec/fixtures/unit/forge/bacula-releases.json +128 -0
- data/spec/fixtures/unit/forge/bacula.tar.gz +0 -0
- data/spec/fixtures/unit/provider/package/puppetserver_gem/gem-list-local-packages +30 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
- data/spec/integration/application/agent_spec.rb +263 -54
- data/spec/integration/application/apply_spec.rb +168 -149
- data/spec/integration/application/doc_spec.rb +16 -6
- data/spec/integration/application/filebucket_spec.rb +70 -21
- data/spec/integration/application/help_spec.rb +42 -0
- data/spec/integration/application/lookup_spec.rb +13 -0
- data/spec/integration/application/module_spec.rb +68 -0
- data/spec/integration/application/plugin_spec.rb +53 -3
- data/spec/integration/configurer_spec.rb +14 -0
- data/spec/integration/data_binding_spec.rb +82 -0
- data/spec/integration/defaults_spec.rb +20 -3
- data/spec/integration/directory_environments_spec.rb +17 -17
- data/spec/integration/environments/setting_hooks_spec.rb +1 -1
- data/spec/integration/indirector/facts/facter_spec.rb +8 -6
- data/spec/integration/network/http_pool_spec.rb +26 -9
- data/spec/integration/node/environment_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +11 -0
- data/spec/integration/resource/type_collection_spec.rb +2 -6
- data/spec/integration/transaction_spec.rb +4 -9
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/execution_spec.rb +22 -0
- data/spec/integration/util/windows/adsi_spec.rb +5 -3
- data/spec/integration/util/windows/monkey_patches/dir_spec.rb +11 -0
- data/spec/integration/util/windows/process_spec.rb +26 -32
- data/spec/integration/util/windows/registry_spec.rb +7 -17
- data/spec/integration/util/windows/user_spec.rb +47 -5
- data/spec/integration/util_spec.rb +7 -33
- data/spec/lib/puppet_spec/matchers.rb +0 -80
- data/spec/lib/puppet_spec/puppetserver.rb +8 -0
- data/spec/lib/puppet_spec/settings.rb +6 -1
- data/spec/shared_contexts/types_setup.rb +2 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/unit/agent_spec.rb +8 -6
- data/spec/unit/application/agent_spec.rb +3 -5
- data/spec/unit/application/config_spec.rb +224 -4
- data/spec/unit/application/doc_spec.rb +2 -2
- data/spec/unit/application/face_base_spec.rb +6 -4
- data/spec/unit/application/facts_spec.rb +41 -10
- data/spec/unit/application/filebucket_spec.rb +0 -2
- data/spec/unit/application/man_spec.rb +52 -0
- data/spec/unit/application/resource_spec.rb +3 -1
- data/spec/unit/application/ssl_spec.rb +15 -2
- data/spec/unit/application_spec.rb +60 -13
- data/spec/unit/configurer/downloader_spec.rb +10 -0
- data/spec/unit/configurer/fact_handler_spec.rb +4 -4
- data/spec/unit/configurer_spec.rb +86 -37
- data/spec/unit/confine/feature_spec.rb +1 -1
- data/spec/unit/confine_spec.rb +10 -3
- data/spec/unit/context/trusted_information_spec.rb +10 -4
- data/spec/unit/defaults_spec.rb +20 -1
- data/spec/unit/environments_spec.rb +176 -32
- data/spec/unit/face/config_spec.rb +65 -12
- data/spec/unit/face/node_spec.rb +2 -13
- data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
- data/spec/unit/file_serving/http_metadata_spec.rb +37 -14
- data/spec/unit/file_serving/metadata_spec.rb +3 -3
- data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
- data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
- data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
- data/spec/unit/file_serving/terminus_selector_spec.rb +45 -26
- data/spec/unit/file_system/uniquefile_spec.rb +18 -0
- data/spec/unit/file_system_spec.rb +1 -2
- data/spec/unit/forge/module_release_spec.rb +2 -7
- data/spec/unit/functions/inline_epp_spec.rb +26 -1
- data/spec/unit/http/client_spec.rb +64 -9
- data/spec/unit/http/resolver_spec.rb +24 -5
- data/spec/unit/http/response_spec.rb +6 -0
- data/spec/unit/http/service/ca_spec.rb +2 -3
- data/spec/unit/http/service/compiler_spec.rb +51 -3
- data/spec/unit/http/service/file_server_spec.rb +2 -3
- data/spec/unit/http/service/puppetserver_spec.rb +82 -0
- data/spec/unit/http/service/report_spec.rb +2 -3
- data/spec/unit/http/service_spec.rb +1 -2
- data/spec/unit/http/session_spec.rb +8 -21
- data/spec/unit/indirector/catalog/json_spec.rb +1 -1
- data/spec/unit/indirector/catalog/rest_spec.rb +1 -1
- data/spec/unit/indirector/face_spec.rb +0 -1
- data/spec/unit/indirector/facts/facter_spec.rb +0 -1
- data/spec/unit/indirector/facts/json_spec.rb +255 -0
- data/spec/unit/indirector/facts/rest_spec.rb +1 -1
- data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
- data/spec/unit/indirector/file_metadata/http_spec.rb +27 -0
- data/spec/unit/indirector/indirection_spec.rb +8 -12
- data/spec/unit/indirector/json_spec.rb +8 -8
- data/spec/unit/indirector/key/file_spec.rb +0 -1
- data/spec/unit/indirector/msgpack_spec.rb +8 -8
- data/spec/unit/indirector/node/json_spec.rb +33 -0
- data/spec/unit/indirector/node/rest_spec.rb +1 -1
- data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
- data/spec/unit/indirector/report/yaml_spec.rb +72 -8
- data/spec/unit/indirector/request_spec.rb +5 -5
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/indirector/status/rest_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +7 -7
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/interface_spec.rb +3 -3
- data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +20 -0
- data/spec/unit/network/authconfig_spec.rb +0 -3
- data/spec/unit/network/format_support_spec.rb +3 -2
- data/spec/unit/network/http/api/indirected_routes_spec.rb +2 -10
- data/spec/unit/network/http/api/master/v3/environments_spec.rb +12 -23
- data/spec/unit/network/http/connection_spec.rb +42 -32
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/node/environment_spec.rb +18 -1
- data/spec/unit/parser/ast/block_expression_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +3 -19
- data/spec/unit/parser/environment_compiler_spec.rb +7 -0
- data/spec/unit/parser/resource_spec.rb +14 -8
- data/spec/unit/parser/scope_spec.rb +1 -1
- data/spec/unit/parser/templatewrapper_spec.rb +4 -3
- data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +15 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +71 -1
- data/spec/unit/pops/lookup/lookup_spec.rb +25 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +1 -11
- data/spec/unit/property_spec.rb +1 -0
- data/spec/unit/provider/exec_spec.rb +4 -3
- data/spec/unit/provider/nameservice_spec.rb +66 -65
- data/spec/unit/provider/package/apt_spec.rb +76 -3
- data/spec/unit/provider/package/aptitude_spec.rb +1 -0
- data/spec/unit/provider/package/base_spec.rb +6 -5
- data/spec/unit/provider/package/dpkg_spec.rb +22 -7
- data/spec/unit/provider/package/openbsd_spec.rb +2 -0
- data/spec/unit/provider/package/pacman_spec.rb +18 -12
- data/spec/unit/provider/package/pip2_spec.rb +36 -0
- data/spec/unit/provider/package/pip_spec.rb +6 -11
- data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
- data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
- data/spec/unit/provider/package/puppetserver_gem_spec.rb +137 -0
- data/spec/unit/provider/package/yum_spec.rb +31 -0
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/service/base_spec.rb +2 -4
- data/spec/unit/provider/service/bsd_spec.rb +5 -1
- data/spec/unit/provider/service/daemontools_spec.rb +1 -1
- data/spec/unit/provider/service/debian_spec.rb +3 -5
- data/spec/unit/provider/service/freebsd_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_spec.rb +4 -5
- data/spec/unit/provider/service/init_spec.rb +45 -5
- data/spec/unit/provider/service/launchd_spec.rb +5 -6
- data/spec/unit/provider/service/openrc_spec.rb +4 -5
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/runit_spec.rb +2 -1
- data/spec/unit/provider/service/smf_spec.rb +1 -1
- data/spec/unit/provider/service/src_spec.rb +3 -5
- data/spec/unit/provider/service/systemd_spec.rb +3 -6
- data/spec/unit/provider/service/upstart_spec.rb +4 -5
- data/spec/unit/provider/service/windows_spec.rb +50 -14
- data/spec/unit/provider/user/aix_spec.rb +5 -0
- data/spec/unit/provider/user/hpux_spec.rb +1 -1
- data/spec/unit/provider/user/openbsd_spec.rb +1 -0
- data/spec/unit/provider/user/pw_spec.rb +2 -0
- data/spec/unit/provider/user/useradd_spec.rb +23 -16
- data/spec/unit/provider/user/windows_adsi_spec.rb +82 -0
- data/spec/unit/provider_spec.rb +8 -10
- data/spec/unit/puppet_pal_2pec.rb +40 -0
- data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
- data/spec/unit/reports/store_spec.rb +17 -13
- data/spec/unit/resource/capability_finder_spec.rb +6 -1
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +14 -13
- data/spec/unit/rest/route_spec.rb +4 -4
- data/spec/unit/settings_spec.rb +576 -239
- data/spec/unit/ssl/base_spec.rb +0 -1
- data/spec/unit/ssl/host_spec.rb +0 -5
- data/spec/unit/ssl/ssl_provider_spec.rb +82 -50
- data/spec/unit/test/test_helper_spec.rb +17 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
- data/spec/unit/transaction/event_manager_spec.rb +14 -11
- data/spec/unit/transaction/persistence_spec.rb +15 -0
- data/spec/unit/transaction/report_spec.rb +3 -1
- data/spec/unit/transaction_spec.rb +13 -4
- data/spec/unit/type/file/content_spec.rb +0 -1
- data/spec/unit/type/file/selinux_spec.rb +0 -2
- data/spec/unit/type/file/source_spec.rb +4 -4
- data/spec/unit/type/file_spec.rb +122 -102
- data/spec/unit/type/filebucket_spec.rb +1 -1
- data/spec/unit/type/group_spec.rb +13 -6
- data/spec/unit/type/resources_spec.rb +7 -7
- data/spec/unit/type/service_spec.rb +210 -1
- data/spec/unit/type/tidy_spec.rb +0 -1
- data/spec/unit/type/user_spec.rb +31 -2
- data/spec/unit/type_spec.rb +52 -2
- data/spec/unit/util/at_fork_spec.rb +2 -2
- data/spec/unit/util/autoload_spec.rb +5 -1
- data/spec/unit/util/backups_spec.rb +1 -2
- data/spec/unit/util/character_encoding_spec.rb +4 -4
- data/spec/unit/util/checksums_spec.rb +16 -0
- data/spec/unit/util/command_line_spec.rb +11 -6
- data/spec/unit/util/execution_spec.rb +15 -11
- data/spec/unit/util/inifile_spec.rb +6 -14
- data/spec/unit/util/log_spec.rb +8 -7
- data/spec/unit/util/logging_spec.rb +3 -3
- data/spec/unit/util/posix_spec.rb +363 -15
- data/spec/unit/util/rubygems_spec.rb +2 -2
- data/spec/unit/util/run_mode_spec.rb +6 -6
- data/spec/unit/util/selinux_spec.rb +76 -52
- data/spec/unit/util/storage_spec.rb +3 -1
- data/spec/unit/util/suidmanager_spec.rb +44 -41
- data/spec/unit/util/windows/api_types_spec.rb +104 -40
- data/spec/unit/util/windows/service_spec.rb +4 -4
- data/spec/unit/util_spec.rb +16 -9
- data/spec/unit/x509/cert_provider_spec.rb +1 -1
- metadata +52 -53
- data/spec/integration/faces/config_spec.rb +0 -91
- data/spec/integration/faces/documentation_spec.rb +0 -57
- data/spec/integration/file_bucket/file_spec.rb +0 -50
- data/spec/integration/file_serving/content_spec.rb +0 -7
- data/spec/integration/file_serving/fileset_spec.rb +0 -12
- data/spec/integration/file_serving/metadata_spec.rb +0 -8
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -20
- data/spec/integration/file_system/uniquefile_spec.rb +0 -26
- data/spec/integration/module_tool/forge_spec.rb +0 -51
- data/spec/integration/module_tool/tar/mini_spec.rb +0 -28
- data/spec/integration/provider/service/init_spec.rb +0 -48
- data/spec/integration/provider/service/systemd_spec.rb +0 -25
- data/spec/integration/provider/service/windows_spec.rb +0 -50
- data/spec/integration/reference/providers_spec.rb +0 -21
- data/spec/integration/reports_spec.rb +0 -13
- data/spec/integration/ssl/certificate_request_spec.rb +0 -44
- data/spec/integration/ssl/host_spec.rb +0 -72
- data/spec/integration/ssl/key_spec.rb +0 -99
- data/spec/integration/test/test_helper_spec.rb +0 -31
- data/spec/shared_behaviours/file_serving_model.rb +0 -51
- data/spec/unit/face/catalog_spec.rb +0 -6
- data/spec/unit/face/man_spec.rb +0 -25
- data/spec/unit/face/module_spec.rb +0 -3
- data/spec/unit/man_spec.rb +0 -31
| @@ -72,6 +72,88 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet::Util:: | |
| 72 72 | 
             
                end
         | 
| 73 73 | 
             
              end
         | 
| 74 74 |  | 
| 75 | 
            +
              describe "when setting roles" do
         | 
| 76 | 
            +
                context "when role_membership => minimum" do
         | 
| 77 | 
            +
                  before :each do
         | 
| 78 | 
            +
                    resource[:role_membership] = :minimum
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  it "should set the given role when user has no roles" do
         | 
| 82 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
         | 
| 85 | 
            +
                    provider.roles = 'givenRole1'
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  it "should set only the misssing role when user already has other roles" do
         | 
| 89 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1')
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole2']).and_return(nil)
         | 
| 92 | 
            +
                    provider.roles = 'givenRole1,givenRole2'
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  it "should never remove any roles" do
         | 
| 96 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1')
         | 
| 97 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:set_rights).and_return(nil)
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                    expect(Puppet::Util::Windows::User).not_to receive(:remove_rights)
         | 
| 100 | 
            +
                    provider.roles = 'givenRole1,givenRole2'
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                context "when role_membership => inclusive" do
         | 
| 105 | 
            +
                  before :each do
         | 
| 106 | 
            +
                    resource[:role_membership] = :inclusive
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                  it "should remove the unwanted role" do
         | 
| 110 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
         | 
| 113 | 
            +
                    provider.roles = 'givenRole1'
         | 
| 114 | 
            +
                  end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  it "should add the missing role and remove the unwanted one" do
         | 
| 117 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole3']).and_return(nil)
         | 
| 120 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
         | 
| 121 | 
            +
                    provider.roles = 'givenRole1,givenRole3'
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  it "should not set any roles when the user already has given role" do
         | 
| 125 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
         | 
| 126 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                    expect(Puppet::Util::Windows::User).not_to receive(:set_rights)
         | 
| 129 | 
            +
                    provider.roles = 'givenRole1'
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  it "should set the given role when user has no roles" do
         | 
| 133 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
         | 
| 136 | 
            +
                    provider.roles = 'givenRole1'
         | 
| 137 | 
            +
                  end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                  it "should not remove any roles when user has no roles" do
         | 
| 140 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
         | 
| 141 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                    expect(Puppet::Util::Windows::User).not_to receive(:remove_rights)
         | 
| 144 | 
            +
                    provider.roles = 'givenRole1'
         | 
| 145 | 
            +
                  end
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                  it "should remove all roles when none given" do
         | 
| 148 | 
            +
                    allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                    expect(Puppet::Util::Windows::User).not_to receive(:set_rights)
         | 
| 151 | 
            +
                    expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole1', 'givenRole2']).and_return(nil)
         | 
| 152 | 
            +
                    provider.roles = ''
         | 
| 153 | 
            +
                  end
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
              end
         | 
| 156 | 
            +
             | 
| 75 157 | 
             
              describe "#groups_insync?" do
         | 
| 76 158 | 
             
                let(:group1) { double(:account => 'group1', :domain => '.', :sid => 'group1sid') }
         | 
| 77 159 | 
             
                let(:group2) { double(:account => 'group2', :domain => '.', :sid => 'group2sid') }
         | 
    
        data/spec/unit/provider_spec.rb
    CHANGED
    
    | @@ -648,39 +648,37 @@ describe Puppet::Provider do | |
| 648 648 | 
             
                it "delegates instance execute to Puppet::Util::Execution" do
         | 
| 649 649 | 
             
                  expect(Puppet::Util::Execution).to receive(:execute).with("a_command", { :option => "value" })
         | 
| 650 650 |  | 
| 651 | 
            -
                  provider.new. | 
| 651 | 
            +
                  provider.new.execute("a_command", { :option => "value" })
         | 
| 652 652 | 
             
                end
         | 
| 653 653 |  | 
| 654 654 | 
             
                it "delegates class execute to Puppet::Util::Execution" do
         | 
| 655 655 | 
             
                  expect(Puppet::Util::Execution).to receive(:execute).with("a_command", { :option => "value" })
         | 
| 656 656 |  | 
| 657 | 
            -
                  provider. | 
| 657 | 
            +
                  provider.execute("a_command", { :option => "value" })
         | 
| 658 658 | 
             
                end
         | 
| 659 659 |  | 
| 660 660 | 
             
                it "delegates instance execpipe to Puppet::Util::Execution" do
         | 
| 661 | 
            -
                   | 
| 662 | 
            -
                  expect(Puppet::Util::Execution).to receive(:execpipe).with("a_command", true, block)
         | 
| 661 | 
            +
                  allow(Puppet::Util::Execution).to receive(:execpipe).with("a_command", true).and_yield('some output')
         | 
| 663 662 |  | 
| 664 | 
            -
                  provider.new. | 
| 663 | 
            +
                  expect { |b| provider.new.execpipe("a_command", true, &b) }.to yield_with_args('some output')
         | 
| 665 664 | 
             
                end
         | 
| 666 665 |  | 
| 667 666 | 
             
                it "delegates class execpipe to Puppet::Util::Execution" do
         | 
| 668 | 
            -
                   | 
| 669 | 
            -
                  expect(Puppet::Util::Execution).to receive(:execpipe).with("a_command", true, block)
         | 
| 667 | 
            +
                  allow(Puppet::Util::Execution).to receive(:execpipe).with("a_command", true).and_yield('some output')
         | 
| 670 668 |  | 
| 671 | 
            -
                  provider. | 
| 669 | 
            +
                  expect { |b| provider.execpipe("a_command", true, &b) }.to yield_with_args('some output')
         | 
| 672 670 | 
             
                end
         | 
| 673 671 |  | 
| 674 672 | 
             
                it "delegates instance execfail to Puppet::Util::Execution" do
         | 
| 675 673 | 
             
                  expect(Puppet::Util::Execution).to receive(:execfail).with("a_command", "an exception to raise")
         | 
| 676 674 |  | 
| 677 | 
            -
                  provider.new. | 
| 675 | 
            +
                  provider.new.execfail("a_command", "an exception to raise")
         | 
| 678 676 | 
             
                end
         | 
| 679 677 |  | 
| 680 678 | 
             
                it "delegates class execfail to Puppet::Util::Execution" do
         | 
| 681 679 | 
             
                  expect(Puppet::Util::Execution).to receive(:execfail).with("a_command", "an exception to raise")
         | 
| 682 680 |  | 
| 683 | 
            -
                  provider. | 
| 681 | 
            +
                  provider.execfail("a_command", "an exception to raise")
         | 
| 684 682 | 
             
                end
         | 
| 685 683 | 
             
              end
         | 
| 686 684 |  | 
| @@ -708,6 +708,46 @@ describe 'Puppet Pal' do | |
| 708 708 | 
             
                    end
         | 
| 709 709 | 
             
                  end
         | 
| 710 710 |  | 
| 711 | 
            +
                  context 'facts are supported such that' do
         | 
| 712 | 
            +
                    it 'they are obtained if they are not given' do
         | 
| 713 | 
            +
                      facts = Puppet::Node::Facts.new(Puppet[:certname], 'puppetversion' => Puppet.version)
         | 
| 714 | 
            +
                      Puppet::Node::Facts.indirection.save(facts)
         | 
| 715 | 
            +
             | 
| 716 | 
            +
                      testing_env_dir # creates the structure
         | 
| 717 | 
            +
                      result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath ) do |ctx|
         | 
| 718 | 
            +
                        ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[puppetversion] == '#{Puppet.version}'") }
         | 
| 719 | 
            +
                      end
         | 
| 720 | 
            +
                      expect(result).to eq(true)
         | 
| 721 | 
            +
                    end
         | 
| 722 | 
            +
             | 
| 723 | 
            +
                    it 'can be given as a hash when creating the environment' do
         | 
| 724 | 
            +
                      testing_env_dir # creates the structure
         | 
| 725 | 
            +
                      result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
         | 
| 726 | 
            +
                        ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 42") }
         | 
| 727 | 
            +
                      end
         | 
| 728 | 
            +
                      expect(result).to eq(true)
         | 
| 729 | 
            +
                    end
         | 
| 730 | 
            +
             | 
| 731 | 
            +
                    it 'can be overridden with a hash when creating a script compiler' do
         | 
| 732 | 
            +
                      testing_env_dir # creates the structure
         | 
| 733 | 
            +
                      result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
         | 
| 734 | 
            +
                        ctx.with_script_compiler(facts: { 'myfact' => 43 }) {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 43") }
         | 
| 735 | 
            +
                      end
         | 
| 736 | 
            +
                      expect(result).to eq(true)
         | 
| 737 | 
            +
                    end
         | 
| 738 | 
            +
             | 
| 739 | 
            +
                    it 'can be disabled with the :set_local_facts option' do
         | 
| 740 | 
            +
                      Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42}) do |ctx|
         | 
| 741 | 
            +
                        ctx.with_script_compiler(facts: { 'myfact' => 42 }, set_local_facts: false) do |compiler|
         | 
| 742 | 
            +
                          expect { compiler.evaluate_string('$facts') }.to raise_error(
         | 
| 743 | 
            +
                            Puppet::PreformattedError,
         | 
| 744 | 
            +
                            /Unknown variable: 'facts'/
         | 
| 745 | 
            +
                          )
         | 
| 746 | 
            +
                        end
         | 
| 747 | 
            +
                      end
         | 
| 748 | 
            +
                    end
         | 
| 749 | 
            +
                  end
         | 
| 750 | 
            +
             | 
| 711 751 | 
             
                  context 'supports tasks such that' do
         | 
| 712 752 | 
             
                    it '"task_signature" returns the signatures of a generic task' do
         | 
| 713 753 | 
             
                      result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do |ctx|
         | 
| @@ -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|
         | 
| @@ -6,53 +6,57 @@ require 'pathname' | |
| 6 6 | 
             
            require 'tempfile'
         | 
| 7 7 | 
             
            require 'fileutils'
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
            describe processor do
         | 
| 9 | 
            +
            describe Puppet::Reports.report(:store) do
         | 
| 12 10 | 
             
              describe "#process" do
         | 
| 13 11 | 
             
                include PuppetSpec::Files
         | 
| 12 | 
            +
             | 
| 14 13 | 
             
                before :each do
         | 
| 15 14 | 
             
                  Puppet[:reportdir] = File.join(tmpdir('reports'), 'reports')
         | 
| 16 | 
            -
             | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                let(:report) do
         | 
| 18 | 
            +
                  report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml'))
         | 
| 19 | 
            +
                  report.extend(described_class)
         | 
| 20 | 
            +
                  report
         | 
| 17 21 | 
             
                end
         | 
| 18 22 |  | 
| 19 23 | 
             
                it "should create a report directory for the client if one doesn't exist" do
         | 
| 20 | 
            -
                   | 
| 24 | 
            +
                  report.process
         | 
| 21 25 |  | 
| 22 | 
            -
                  expect(File).to be_directory(File.join(Puppet[:reportdir],  | 
| 26 | 
            +
                  expect(File).to be_directory(File.join(Puppet[:reportdir], report.host))
         | 
| 23 27 | 
             
                end
         | 
| 24 28 |  | 
| 25 29 | 
             
                it "should write the report to the file in YAML" do
         | 
| 26 30 | 
             
                  allow(Time).to receive(:now).and_return(Time.utc(2011,01,06,12,00,00))
         | 
| 27 | 
            -
                   | 
| 31 | 
            +
                  report.process
         | 
| 28 32 |  | 
| 29 | 
            -
                  expect(File.read(File.join(Puppet[:reportdir],  | 
| 33 | 
            +
                  expect(File.read(File.join(Puppet[:reportdir], report.host, "201101061200.yaml"))).to eq(report.to_yaml)
         | 
| 30 34 | 
             
                end
         | 
| 31 35 |  | 
| 32 36 | 
             
                it "rejects invalid hostnames" do
         | 
| 33 | 
            -
                   | 
| 37 | 
            +
                  report.host = ".."
         | 
| 34 38 | 
             
                  expect(Puppet::FileSystem).not_to receive(:exist?)
         | 
| 35 | 
            -
                  expect {  | 
| 39 | 
            +
                  expect { report.process }.to raise_error(ArgumentError, /Invalid node/)
         | 
| 36 40 | 
             
                end
         | 
| 37 41 | 
             
              end
         | 
| 38 42 |  | 
| 39 43 | 
             
              describe "::destroy" do
         | 
| 40 44 | 
             
                it "rejects invalid hostnames" do
         | 
| 41 45 | 
             
                  expect(Puppet::FileSystem).not_to receive(:unlink)
         | 
| 42 | 
            -
                  expect {  | 
| 46 | 
            +
                  expect { described_class.destroy("..") }.to raise_error(ArgumentError, /Invalid node/)
         | 
| 43 47 | 
             
                end
         | 
| 44 48 | 
             
              end
         | 
| 45 49 |  | 
| 46 50 | 
             
              describe "::validate_host" do
         | 
| 47 51 | 
             
                ['..', 'hello/', '/hello', 'he/llo', 'hello/..', '.'].each do |node|
         | 
| 48 52 | 
             
                  it "rejects #{node.inspect}" do
         | 
| 49 | 
            -
                    expect {  | 
| 53 | 
            +
                    expect { described_class.validate_host(node) }.to raise_error(ArgumentError, /Invalid node/)
         | 
| 50 54 | 
             
                  end
         | 
| 51 55 | 
             
                end
         | 
| 52 56 |  | 
| 53 57 | 
             
                ['.hello', 'hello.', '..hi', 'hi..'].each do |node|
         | 
| 54 58 | 
             
                  it "accepts #{node.inspect}" do
         | 
| 55 | 
            -
                     | 
| 59 | 
            +
                    described_class.validate_host(node)
         | 
| 56 60 | 
             
                  end
         | 
| 57 61 | 
             
                end
         | 
| 58 62 | 
             
              end
         | 
| @@ -16,7 +16,12 @@ describe Puppet::Resource::CapabilityFinder do | |
| 16 16 | 
             
                  Puppet.push_context({:loaders => loaders, :current_environment => env})
         | 
| 17 17 | 
             
                  if mock_pdb
         | 
| 18 18 | 
             
                    module Puppet::Util::Puppetdb
         | 
| 19 | 
            -
                       | 
| 19 | 
            +
                      def query_puppetdb(query); end
         | 
| 20 | 
            +
                      module_function :query_puppetdb
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                      class Http
         | 
| 23 | 
            +
                        def self.action(url); end
         | 
| 24 | 
            +
                      end
         | 
| 20 25 | 
             
                    end
         | 
| 21 26 | 
             
                  end
         | 
| 22 27 | 
             
                  make_cap_type
         | 
| @@ -554,7 +554,7 @@ describe Puppet::Resource::Type do | |
| 554 554 |  | 
| 555 555 | 
             
                it "should not create a subscope for the :main class" do
         | 
| 556 556 | 
             
                  allow(@resource).to receive(:title).and_return(:main)
         | 
| 557 | 
            -
                  expect(@ | 
| 557 | 
            +
                  expect(@scope).not_to receive(:newscope)
         | 
| 558 558 | 
             
                  expect(@type).to receive(:set_resource_parameters).with(@resource, @scope)
         | 
| 559 559 |  | 
| 560 560 | 
             
                  @type.evaluate_code(@resource)
         | 
    
        data/spec/unit/resource_spec.rb
    CHANGED
    
    | @@ -283,7 +283,7 @@ describe Puppet::Resource do | |
| 283 283 | 
             
                let(:scope)    { Puppet::Parser::Scope.new(compiler) }
         | 
| 284 284 |  | 
| 285 285 | 
             
                def ast_leaf(value)
         | 
| 286 | 
            -
                  Puppet::Parser::AST::Leaf.new( | 
| 286 | 
            +
                  Puppet::Parser::AST::Leaf.new(value: value)
         | 
| 287 287 | 
             
                end
         | 
| 288 288 |  | 
| 289 289 | 
             
                it "should fail when asked to set default values and it is not a parser resource" do
         | 
| @@ -321,7 +321,7 @@ describe Puppet::Resource do | |
| 321 321 |  | 
| 322 322 | 
             
                describe "when the resource type is :hostclass" do
         | 
| 323 323 | 
             
                  let(:environment_name) { "testing env" }
         | 
| 324 | 
            -
                  let(:fact_values) { {  | 
| 324 | 
            +
                  let(:fact_values) { { 'a' => 1 } }
         | 
| 325 325 | 
             
                  let(:port) { Puppet::Parser::AST::Leaf.new(:value => '80') }
         | 
| 326 326 |  | 
| 327 327 | 
             
                  def inject_and_set_defaults(resource, scope)
         | 
| @@ -330,10 +330,7 @@ describe Puppet::Resource do | |
| 330 330 |  | 
| 331 331 | 
             
                  before do
         | 
| 332 332 | 
             
                    environment.known_resource_types.add(apache)
         | 
| 333 | 
            -
             | 
| 334 | 
            -
                    allow(scope).to receive(:host).and_return('host')
         | 
| 335 | 
            -
                    allow(scope).to receive(:environment).and_return(environment)
         | 
| 336 | 
            -
                    allow(scope).to receive(:facts).and_return(Puppet::Node::Facts.new("facts", fact_values))
         | 
| 333 | 
            +
                    scope.set_facts(fact_values)
         | 
| 337 334 | 
             
                  end
         | 
| 338 335 |  | 
| 339 336 | 
             
                  context 'with a default value expression' do
         | 
| @@ -389,7 +386,7 @@ describe Puppet::Resource do | |
| 389 386 | 
             
                    context "when a value is provided" do
         | 
| 390 387 | 
             
                      let(:port_parameter) do
         | 
| 391 388 | 
             
                        Puppet::Parser::Resource::Param.new(
         | 
| 392 | 
            -
                           | 
| 389 | 
            +
                          name: 'port', value: '8080'
         | 
| 393 390 | 
             
                        )
         | 
| 394 391 | 
             
                      end
         | 
| 395 392 |  | 
| @@ -414,7 +411,7 @@ describe Puppet::Resource do | |
| 414 411 | 
             
                        expect_lookup('apache::port', returns: '443')
         | 
| 415 412 |  | 
| 416 413 | 
             
                        rs = Puppet::Parser::Resource.new("class", "apache", :scope => scope,
         | 
| 417 | 
            -
                          :parameters => [Puppet::Parser::Resource::Param.new( | 
| 414 | 
            +
                          :parameters => [Puppet::Parser::Resource::Param.new(name: 'port', value: nil)])
         | 
| 418 415 |  | 
| 419 416 | 
             
                        rs.resource_type.set_resource_parameters(rs, scope)
         | 
| 420 417 | 
             
                        expect(rs[:port]).to eq('443')
         | 
| @@ -627,11 +624,15 @@ describe Puppet::Resource do | |
| 627 624 | 
             
                  expect(resource.to_hash[:myvar]).to eq("bob")
         | 
| 628 625 | 
             
                end
         | 
| 629 626 |  | 
| 630 | 
            -
                it "should set :name to the title if :name is not present for non- | 
| 631 | 
            -
                   | 
| 632 | 
            -
                   | 
| 633 | 
            -
             | 
| 634 | 
            -
             | 
| 627 | 
            +
                it "should set :name to the title if :name is not present for non-existent types" do
         | 
| 628 | 
            +
                  resource = Puppet::Resource.new :doesnotexist, "bar"
         | 
| 629 | 
            +
                  expect(resource.to_hash[:name]).to eq("bar")
         | 
| 630 | 
            +
                end
         | 
| 631 | 
            +
             | 
| 632 | 
            +
                it "should set :name to the title if :name is not present for a definition" do
         | 
| 633 | 
            +
                  type = Puppet::Resource::Type.new(:definition, :foo)
         | 
| 634 | 
            +
                  environment.known_resource_types.add(type)
         | 
| 635 | 
            +
                  resource = Puppet::Resource.new :foo, "bar", :environment => environment
         | 
| 635 636 | 
             
                  expect(resource.to_hash[:name]).to eq("bar")
         | 
| 636 637 | 
             
                end
         | 
| 637 638 | 
             
              end
         | 
| @@ -30,7 +30,7 @@ describe Puppet::Rest::Route do | |
| 30 30 |  | 
| 31 31 | 
             
                  it "yields a base URL with Puppet's configured server and port when no defaults are specified" do
         | 
| 32 32 | 
             
                    Puppet[:server] = 'configured.net'
         | 
| 33 | 
            -
                    Puppet[: | 
| 33 | 
            +
                    Puppet[:serverport] = 8140
         | 
| 34 34 | 
             
                    fallback_route = Puppet::Rest::Route.new(api: '/fakeapi/v1/')
         | 
| 35 35 | 
             
                    count = 0
         | 
| 36 36 | 
             
                    rval = fallback_route.with_base_url(dns_resolver) do |url|
         | 
| @@ -55,9 +55,9 @@ describe Puppet::Rest::Route do | |
| 55 55 | 
             
                    expect(rval).to eq('Block return value')
         | 
| 56 56 | 
             
                  end
         | 
| 57 57 |  | 
| 58 | 
            -
                  it 'falls back to :server and : | 
| 58 | 
            +
                  it 'falls back to :server and :serverport if nil is passed' do
         | 
| 59 59 | 
             
                    Puppet[:server] = 'one.net'
         | 
| 60 | 
            -
                    Puppet[: | 
| 60 | 
            +
                    Puppet[:serverport] = 111
         | 
| 61 61 | 
             
                    nil_route = Puppet::Rest::Route.new(api: '/fakeapi/v1/',
         | 
| 62 62 | 
             
                                                        server_setting: nil,
         | 
| 63 63 | 
             
                                                        port_setting: nil)
         | 
| @@ -109,7 +109,7 @@ describe Puppet::Rest::Route do | |
| 109 109 |  | 
| 110 110 | 
             
                    it "should fall back to the default server when the block raises a SystemCallError" do
         | 
| 111 111 | 
             
                      Puppet[:server] = "testserver"
         | 
| 112 | 
            -
                      Puppet[: | 
| 112 | 
            +
                      Puppet[:serverport] = 555
         | 
| 113 113 |  | 
| 114 114 | 
             
                      count = 0
         | 
| 115 115 | 
             
                      rval = route.with_base_url(Puppet::Network::Resolver.new) do |url|
         | 
    
        data/spec/unit/settings_spec.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ describe Puppet::Settings do | |
| 9 9 | 
             
              include Matchers::Resource
         | 
| 10 10 |  | 
| 11 11 | 
             
              let(:main_config_file_default_location) do
         | 
| 12 | 
            -
                File.join(Puppet::Util::RunMode[: | 
| 12 | 
            +
                File.join(Puppet::Util::RunMode[:server].conf_dir, "puppet.conf")
         | 
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 15 | 
             
              let(:user_config_file_default_location) do
         | 
| @@ -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,16 +103,16 @@ 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 | 
            -
                  expect(@settings.preferred_run_mode).to eq(: | 
| 108 | 
            +
                  expect(@settings.preferred_run_mode).to eq(:server)
         | 
| 118 109 | 
             
                end
         | 
| 119 110 |  | 
| 120 111 | 
             
                it "creates ancestor directories for all required app 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 = []
         | 
| @@ -326,7 +320,7 @@ describe Puppet::Settings do | |
| 326 320 | 
             
                end
         | 
| 327 321 |  | 
| 328 322 | 
             
                it "should identify configured settings from the specified run mode" do
         | 
| 329 | 
            -
                  user_config_text = "[ | 
| 323 | 
            +
                  user_config_text = "[server]\nmyval = foo"
         | 
| 330 324 |  | 
| 331 325 | 
             
                  allow(Puppet.features).to receive(:root?).and_return(false)
         | 
| 332 326 | 
             
                  expect(Puppet::FileSystem).to receive(:exist?).
         | 
| @@ -337,7 +331,7 @@ describe Puppet::Settings do | |
| 337 331 | 
             
                    and_return(user_config_text).ordered
         | 
| 338 332 |  | 
| 339 333 | 
             
                  @settings.send(:parse_config_files)
         | 
| 340 | 
            -
                  expect(@settings.set_by_config?(:myval, nil, : | 
| 334 | 
            +
                  expect(@settings.set_by_config?(:myval, nil, :server)).to be_truthy
         | 
| 341 335 | 
             
                end
         | 
| 342 336 |  | 
| 343 337 | 
             
                it "should not identify configured settings from an unspecified run mode" do
         | 
| @@ -382,7 +376,7 @@ describe Puppet::Settings do | |
| 382 376 |  | 
| 383 377 | 
             
                it "should clear the cache when the preferred_run_mode is changed" do
         | 
| 384 378 | 
             
                  expect(@settings).to receive(:flush_cache)
         | 
| 385 | 
            -
                  @settings.preferred_run_mode = : | 
| 379 | 
            +
                  @settings.preferred_run_mode = :server
         | 
| 386 380 | 
             
                end
         | 
| 387 381 |  | 
| 388 382 | 
             
                it "should not clear other values when setting getopt-specific values" do
         | 
| @@ -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 = []
         | 
| 478 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
         | 
| 479 649 |  | 
| 480 | 
            -
                       | 
| 650 | 
            +
                      @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
         | 
| 481 651 |  | 
| 482 | 
            -
                      @settings. | 
| 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 = []
         | 
| 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
         | 
| 670 | 
            +
             | 
| 671 | 
            +
                      @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :agent))
         | 
| 672 | 
            +
             | 
| 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,26 +831,44 @@ 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
         | 
| 660 847 |  | 
| 848 | 
            +
                [:master, :server].each do |run_mode|
         | 
| 849 | 
            +
                  describe "when run mode is '#{run_mode}'" do
         | 
| 850 | 
            +
                    before(:each) { @settings.preferred_run_mode = run_mode }
         | 
| 851 | 
            +
             | 
| 852 | 
            +
                    it "returns values set in the 'master' section if the 'server' section does not exist" do
         | 
| 853 | 
            +
                      File.write(config_file, "[main]\none = mainval\n[master]\none = modeval\n")
         | 
| 854 | 
            +
                      @settings.initialize_global_settings
         | 
| 855 | 
            +
             | 
| 856 | 
            +
                      expect(@settings[:one]).to eq("modeval")
         | 
| 857 | 
            +
                    end
         | 
| 858 | 
            +
             | 
| 859 | 
            +
                    it "prioritizes values set in the 'server' section if set" do
         | 
| 860 | 
            +
                      File.write(config_file,  "[main]\none = mainval\n[server]\none = serverval\n[master]\none = masterval\n")
         | 
| 861 | 
            +
                      @settings.initialize_global_settings
         | 
| 862 | 
            +
             | 
| 863 | 
            +
                      expect(@settings[:one]).to eq("serverval")
         | 
| 864 | 
            +
                    end
         | 
| 865 | 
            +
                  end
         | 
| 866 | 
            +
                end
         | 
| 867 | 
            +
             | 
| 661 868 | 
             
                it "should not return values outside of its search path" do
         | 
| 662 | 
            -
                   | 
| 663 | 
            -
                   | 
| 664 | 
            -
             | 
| 869 | 
            +
                  File.write(config_file, "[other]\none = oval\n")
         | 
| 870 | 
            +
                  @settings.initialize_global_settings
         | 
| 871 | 
            +
             | 
| 665 872 | 
             
                  expect(@settings[:one]).to eq("ONE")
         | 
| 666 873 | 
             
                end
         | 
| 667 874 |  | 
| @@ -683,7 +890,7 @@ describe Puppet::Settings do | |
| 683 890 | 
             
                    expect(Puppet::FileSystem).to receive(:exist?).with(main_config_file_default_location).and_return(false)
         | 
| 684 891 | 
             
                    expect(Puppet::FileSystem).not_to receive(:exist?).with(user_config_file_default_location)
         | 
| 685 892 |  | 
| 686 | 
            -
                    @settings. | 
| 893 | 
            +
                    @settings.initialize_global_settings
         | 
| 687 894 | 
             
                  end
         | 
| 688 895 | 
             
                end
         | 
| 689 896 |  | 
| @@ -693,7 +900,7 @@ describe Puppet::Settings do | |
| 693 900 |  | 
| 694 901 | 
             
                    expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
         | 
| 695 902 |  | 
| 696 | 
            -
                    @settings. | 
| 903 | 
            +
                    @settings.initialize_global_settings
         | 
| 697 904 | 
             
                  end
         | 
| 698 905 | 
             
                end
         | 
| 699 906 |  | 
| @@ -702,7 +909,7 @@ describe Puppet::Settings do | |
| 702 909 | 
             
                    expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(true)
         | 
| 703 910 | 
             
                    expect(@settings).to receive(:read_file).and_raise('Permission denied')
         | 
| 704 911 |  | 
| 705 | 
            -
                    expect{ @settings. | 
| 912 | 
            +
                    expect{ @settings.initialize_global_settings }.to raise_error(RuntimeError, /Could not load #{user_config_file_default_location}: Permission denied/)
         | 
| 706 913 | 
             
                  end
         | 
| 707 914 |  | 
| 708 915 | 
             
                  it "does not fail if the file is not readable and when `require_config` is false" do
         | 
| @@ -712,7 +919,7 @@ describe Puppet::Settings do | |
| 712 919 | 
             
                    expect(@settings).not_to receive(:parse_config)
         | 
| 713 920 | 
             
                    expect(Puppet).to receive(:log_exception)
         | 
| 714 921 |  | 
| 715 | 
            -
                    expect{ @settings. | 
| 922 | 
            +
                    expect{ @settings.initialize_global_settings([], false) }.not_to raise_error
         | 
| 716 923 | 
             
                  end
         | 
| 717 924 |  | 
| 718 925 | 
             
                  it "reads the file if it is readable" do
         | 
| @@ -720,7 +927,7 @@ describe Puppet::Settings do | |
| 720 927 | 
             
                    expect(@settings).to receive(:read_file).and_return('server = host.string')
         | 
| 721 928 | 
             
                    expect(@settings).to receive(:parse_config)
         | 
| 722 929 |  | 
| 723 | 
            -
                    @settings. | 
| 930 | 
            +
                    @settings.initialize_global_settings
         | 
| 724 931 | 
             
                  end
         | 
| 725 932 | 
             
                end
         | 
| 726 933 |  | 
| @@ -729,7 +936,7 @@ describe Puppet::Settings do | |
| 729 936 | 
             
                    expect(Puppet::FileSystem).to receive(:exist?).with(user_config_file_default_location).and_return(false)
         | 
| 730 937 | 
             
                    expect(@settings).not_to receive(:parse_config)
         | 
| 731 938 |  | 
| 732 | 
            -
                    @settings. | 
| 939 | 
            +
                    @settings.initialize_global_settings
         | 
| 733 940 | 
             
                  end
         | 
| 734 941 | 
             
                end
         | 
| 735 942 | 
             
              end
         | 
| @@ -739,43 +946,41 @@ describe Puppet::Settings do | |
| 739 946 | 
             
                  @settings = Puppet::Settings.new
         | 
| 740 947 | 
             
                  allow(@settings).to receive(:service_user_available?).and_return(true)
         | 
| 741 948 | 
             
                  allow(@settings).to receive(:service_group_available?).and_return(true)
         | 
| 742 | 
            -
                  @file =  | 
| 743 | 
            -
                  @userconfig = make_absolute("/test/userconfigfile")
         | 
| 949 | 
            +
                  @file = tmpfile("somefile")
         | 
| 744 950 | 
             
                  @settings.define_settings :section, :user => { :default => "suser", :desc => "doc" }, :group => { :default => "sgroup", :desc => "doc" }
         | 
| 745 951 | 
             
                  @settings.define_settings :section,
         | 
| 746 952 | 
             
                      :config => { :type => :file, :default => @file, :desc => "eh" },
         | 
| 747 953 | 
             
                      :one => { :default => "ONE", :desc => "a" },
         | 
| 748 954 | 
             
                      :two => { :default => "$one TWO", :desc => "b" },
         | 
| 749 955 | 
             
                      :three => { :default => "$one $two THREE", :desc => "c" }
         | 
| 750 | 
            -
             | 
| 751 | 
            -
                   | 
| 752 | 
            -
                  allow( | 
| 956 | 
            +
             | 
| 957 | 
            +
                  userconfig = tmpfile("userconfig")
         | 
| 958 | 
            +
                  allow(@settings).to receive(:user_config_file).and_return(userconfig)
         | 
| 753 959 | 
             
                end
         | 
| 754 960 |  | 
| 755 961 | 
             
                it "should not ignore the report setting" do
         | 
| 756 962 | 
             
                  @settings.define_settings :section, :report => { :default => "false", :desc => "a" }
         | 
| 757 | 
            -
                   | 
| 758 | 
            -
                  myfile = File.expand_path(@file)
         | 
| 759 | 
            -
                  @settings[:config] = myfile
         | 
| 760 | 
            -
                  text = <<-CONF
         | 
| 963 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 761 964 | 
             
                    [puppetd]
         | 
| 762 | 
            -
             | 
| 965 | 
            +
                    report=true
         | 
| 763 966 | 
             
                  CONF
         | 
| 764 | 
            -
             | 
| 765 | 
            -
                   | 
| 766 | 
            -
             | 
| 967 | 
            +
             | 
| 968 | 
            +
                  @settings.initialize_global_settings
         | 
| 969 | 
            +
             | 
| 767 970 | 
             
                  expect(@settings[:report]).to be_truthy
         | 
| 768 971 | 
             
                end
         | 
| 769 972 |  | 
| 770 973 | 
             
                it "should use its current ':config' value for the file to parse" do
         | 
| 771 | 
            -
                  myfile =  | 
| 772 | 
            -
                   | 
| 773 | 
            -
             | 
| 774 | 
            -
             | 
| 974 | 
            +
                  myfile = tmpfile('myfile')
         | 
| 975 | 
            +
                  File.write(myfile, <<~CONF)
         | 
| 976 | 
            +
                    [main]
         | 
| 977 | 
            +
                    one=myfile
         | 
| 978 | 
            +
                  CONF
         | 
| 775 979 |  | 
| 776 | 
            -
                   | 
| 980 | 
            +
                  @settings[:config] = myfile
         | 
| 981 | 
            +
                  @settings.initialize_global_settings
         | 
| 777 982 |  | 
| 778 | 
            -
                  @settings. | 
| 983 | 
            +
                  expect(@settings[:one]).to eq('myfile')
         | 
| 779 984 | 
             
                end
         | 
| 780 985 |  | 
| 781 986 | 
             
                it "should not try to parse non-existent files" do
         | 
| @@ -783,42 +988,50 @@ describe Puppet::Settings do | |
| 783 988 |  | 
| 784 989 | 
             
                  expect(File).not_to receive(:read).with(@file)
         | 
| 785 990 |  | 
| 786 | 
            -
                  @settings. | 
| 991 | 
            +
                  @settings.initialize_global_settings
         | 
| 787 992 | 
             
                end
         | 
| 788 993 |  | 
| 789 994 | 
             
                it "should return values set in the configuration file" do
         | 
| 790 | 
            -
                   | 
| 791 | 
            -
             | 
| 792 | 
            -
             | 
| 793 | 
            -
                   | 
| 794 | 
            -
             | 
| 995 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 996 | 
            +
                    [main]
         | 
| 997 | 
            +
                    one = fileval
         | 
| 998 | 
            +
                  CONF
         | 
| 999 | 
            +
             | 
| 1000 | 
            +
                  @settings.initialize_global_settings
         | 
| 795 1001 | 
             
                  expect(@settings[:one]).to eq("fileval")
         | 
| 796 1002 | 
             
                end
         | 
| 797 1003 |  | 
| 798 1004 | 
             
                #484 - this should probably be in the regression area
         | 
| 799 1005 | 
             
                it "should not throw an exception on unknown parameters" do
         | 
| 800 | 
            -
                   | 
| 801 | 
            -
             | 
| 802 | 
            -
             | 
| 1006 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1007 | 
            +
                    [main]
         | 
| 1008 | 
            +
                    nosuchparam = mval
         | 
| 1009 | 
            +
                  CONF
         | 
| 1010 | 
            +
             | 
| 1011 | 
            +
                  expect { @settings.initialize_global_settings }.not_to raise_error
         | 
| 803 1012 | 
             
                end
         | 
| 804 1013 |  | 
| 805 1014 | 
             
                it "should convert booleans in the configuration file into Ruby booleans" do
         | 
| 806 | 
            -
                   | 
| 807 | 
            -
             | 
| 808 | 
            -
             | 
| 809 | 
            -
             | 
| 810 | 
            -
                   | 
| 811 | 
            -
             | 
| 1015 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1016 | 
            +
                    [main]
         | 
| 1017 | 
            +
                    one = true
         | 
| 1018 | 
            +
                    two = false
         | 
| 1019 | 
            +
                  CONF
         | 
| 1020 | 
            +
             | 
| 1021 | 
            +
                  @settings.initialize_global_settings
         | 
| 1022 | 
            +
             | 
| 812 1023 | 
             
                  expect(@settings[:one]).to eq(true)
         | 
| 813 1024 | 
             
                  expect(@settings[:two]).to eq(false)
         | 
| 814 1025 | 
             
                end
         | 
| 815 1026 |  | 
| 816 1027 | 
             
                it "should convert integers in the configuration file into Ruby Integers" do
         | 
| 817 | 
            -
                   | 
| 818 | 
            -
             | 
| 819 | 
            -
             | 
| 820 | 
            -
                   | 
| 821 | 
            -
             | 
| 1028 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1029 | 
            +
                    [main]
         | 
| 1030 | 
            +
                    one = 65
         | 
| 1031 | 
            +
                  CONF
         | 
| 1032 | 
            +
             | 
| 1033 | 
            +
                  @settings.initialize_global_settings
         | 
| 1034 | 
            +
             | 
| 822 1035 | 
             
                  expect(@settings[:one]).to eq(65)
         | 
| 823 1036 | 
             
                end
         | 
| 824 1037 |  | 
| @@ -849,57 +1062,193 @@ describe Puppet::Settings do | |
| 849 1062 | 
             
                end
         | 
| 850 1063 |  | 
| 851 1064 | 
             
                it "should support loading metadata (owner, group, or mode) from a run_mode section in the configuration file" do
         | 
| 852 | 
            -
                  default_values = {}
         | 
| 853 | 
            -
                  PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.keys.each do |key|
         | 
| 854 | 
            -
                    default_values[key] = 'default value'
         | 
| 855 | 
            -
                  end
         | 
| 856 1065 | 
             
                  @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
         | 
| 857 | 
            -
                  @settings.define_settings : | 
| 1066 | 
            +
                  @settings.define_settings :server, :myfile => { :type => :file, :default => make_absolute("/myfile"), :desc => "a" }
         | 
| 858 1067 |  | 
| 859 1068 | 
             
                  otherfile = make_absolute("/other/file")
         | 
| 860 | 
            -
                   | 
| 861 | 
            -
             | 
| 862 | 
            -
             | 
| 863 | 
            -
                   | 
| 1069 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1070 | 
            +
                    [server]
         | 
| 1071 | 
            +
                    myfile = #{otherfile} {mode = 664}
         | 
| 1072 | 
            +
                  CONF
         | 
| 864 1073 |  | 
| 865 1074 | 
             
                  # will start initialization as user
         | 
| 866 1075 | 
             
                  expect(@settings.preferred_run_mode).to eq(:user)
         | 
| 867 | 
            -
                  @settings. | 
| 1076 | 
            +
                  @settings.initialize_global_settings
         | 
| 868 1077 |  | 
| 869 | 
            -
                  # change app run_mode to  | 
| 870 | 
            -
                  @settings.initialize_app_defaults( | 
| 871 | 
            -
                  expect(@settings.preferred_run_mode).to eq(: | 
| 1078 | 
            +
                  # change app run_mode to server
         | 
| 1079 | 
            +
                  @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
         | 
| 1080 | 
            +
                  expect(@settings.preferred_run_mode).to eq(:server)
         | 
| 872 1081 |  | 
| 873 1082 | 
             
                  # initializing the app should have reloaded the metadata based on run_mode
         | 
| 874 1083 | 
             
                  expect(@settings[:myfile]).to eq(otherfile)
         | 
| 875 1084 | 
             
                  expect(metadata(@settings.setting(:myfile))).to eq({:mode => "664"})
         | 
| 876 1085 | 
             
                end
         | 
| 877 1086 |  | 
| 878 | 
            -
                 | 
| 879 | 
            -
                   | 
| 880 | 
            -
             | 
| 881 | 
            -
                     | 
| 1087 | 
            +
                context "when setting serverport and masterport" do
         | 
| 1088 | 
            +
                  before(:each) do
         | 
| 1089 | 
            +
                    @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
         | 
| 1090 | 
            +
                    @settings.define_settings :server, :masterport => { :desc => "a", :default => 1000 }
         | 
| 1091 | 
            +
                    @settings.define_settings :server, :serverport => { :type => :alias, :alias_for => :masterport }
         | 
| 1092 | 
            +
                    @settings.define_settings :server, :ca_port => { :desc => "a", :default => "$serverport" }
         | 
| 1093 | 
            +
                    @settings.define_settings :server, :report_port => { :desc => "a", :default => "$serverport" }
         | 
| 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))
         | 
| 1101 | 
            +
                    expect(@settings.preferred_run_mode).to eq(:agent)
         | 
| 1102 | 
            +
                  end
         | 
| 1103 | 
            +
             | 
| 1104 | 
            +
                  context 'with serverport in main and masterport in agent' do
         | 
| 1105 | 
            +
                    let(:text) do
         | 
| 1106 | 
            +
                      "[main]
         | 
| 1107 | 
            +
                  serverport = 444
         | 
| 1108 | 
            +
                  [agent]
         | 
| 1109 | 
            +
                  masterport = 445
         | 
| 1110 | 
            +
                  "
         | 
| 1111 | 
            +
                    end
         | 
| 1112 | 
            +
             | 
| 1113 | 
            +
                    it { expect(@settings[:serverport]).to eq(444) }
         | 
| 1114 | 
            +
                    it { expect(@settings[:ca_port]).to eq("444") }
         | 
| 1115 | 
            +
                    it { expect(@settings[:report_port]).to eq("444") }
         | 
| 1116 | 
            +
                    it { expect(@settings[:masterport]).to eq(445) }
         | 
| 1117 | 
            +
                  end
         | 
| 1118 | 
            +
             | 
| 1119 | 
            +
                  context 'with serverport and masterport in main' do
         | 
| 1120 | 
            +
                    let(:text) do
         | 
| 1121 | 
            +
                      "[main]
         | 
| 1122 | 
            +
                  serverport = 445
         | 
| 1123 | 
            +
                  masterport = 444
         | 
| 1124 | 
            +
                  "
         | 
| 1125 | 
            +
                    end
         | 
| 1126 | 
            +
             | 
| 1127 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1128 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1129 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1130 | 
            +
                    it { expect(@settings[:masterport]).to eq(444) }
         | 
| 882 1131 | 
             
                  end
         | 
| 883 1132 |  | 
| 1133 | 
            +
                  context 'with serverport and masterport in agent' do
         | 
| 1134 | 
            +
                    let(:text) do
         | 
| 1135 | 
            +
                      "[agent]
         | 
| 1136 | 
            +
                  serverport = 445
         | 
| 1137 | 
            +
                  masterport = 444
         | 
| 1138 | 
            +
                  "
         | 
| 1139 | 
            +
                    end
         | 
| 1140 | 
            +
             | 
| 1141 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1142 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1143 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1144 | 
            +
                    it { expect(@settings[:masterport]).to eq(444) }
         | 
| 1145 | 
            +
                  end
         | 
| 1146 | 
            +
             | 
| 1147 | 
            +
                  context 'with both serverport and masterport in main and agent' do
         | 
| 1148 | 
            +
                    let(:text) do
         | 
| 1149 | 
            +
                      "[main]
         | 
| 1150 | 
            +
                  serverport = 447
         | 
| 1151 | 
            +
                  masterport = 442
         | 
| 1152 | 
            +
                  [agent]
         | 
| 1153 | 
            +
                  serverport = 445
         | 
| 1154 | 
            +
                  masterport = 444
         | 
| 1155 | 
            +
                  "
         | 
| 1156 | 
            +
                    end
         | 
| 1157 | 
            +
             | 
| 1158 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1159 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1160 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1161 | 
            +
                    it { expect(@settings[:masterport]).to eq(444) }
         | 
| 1162 | 
            +
                  end
         | 
| 1163 | 
            +
             | 
| 1164 | 
            +
                  context 'with serverport in agent and masterport in main' do
         | 
| 1165 | 
            +
                    let(:text) do
         | 
| 1166 | 
            +
                      "[agent]
         | 
| 1167 | 
            +
                  serverport = 444
         | 
| 1168 | 
            +
                  [main]
         | 
| 1169 | 
            +
                  masterport = 445
         | 
| 1170 | 
            +
                  "
         | 
| 1171 | 
            +
                    end
         | 
| 1172 | 
            +
             | 
| 1173 | 
            +
                    it { expect(@settings[:serverport]).to eq(444) }
         | 
| 1174 | 
            +
                    it { expect(@settings[:ca_port]).to eq("444") }
         | 
| 1175 | 
            +
                    it { expect(@settings[:report_port]).to eq("444") }
         | 
| 1176 | 
            +
                    it { expect(@settings[:masterport]).to eq(445) }
         | 
| 1177 | 
            +
                  end
         | 
| 1178 | 
            +
             | 
| 1179 | 
            +
                  context 'with masterport in main' do
         | 
| 1180 | 
            +
                    let(:text) do
         | 
| 1181 | 
            +
                      "[main]
         | 
| 1182 | 
            +
                  masterport = 445
         | 
| 1183 | 
            +
                  "
         | 
| 1184 | 
            +
                    end
         | 
| 1185 | 
            +
             | 
| 1186 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1187 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1188 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1189 | 
            +
                    it { expect(@settings[:masterport]).to eq(445) }
         | 
| 1190 | 
            +
                  end
         | 
| 1191 | 
            +
             | 
| 1192 | 
            +
                  context 'with masterport in agent' do
         | 
| 1193 | 
            +
                    let(:text) do
         | 
| 1194 | 
            +
                      "[agent]
         | 
| 1195 | 
            +
                  masterport = 445
         | 
| 1196 | 
            +
                  "
         | 
| 1197 | 
            +
                    end
         | 
| 1198 | 
            +
             | 
| 1199 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1200 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1201 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1202 | 
            +
                    it { expect(@settings[:masterport]).to eq(445) }
         | 
| 1203 | 
            +
                  end
         | 
| 1204 | 
            +
             | 
| 1205 | 
            +
                  context 'with serverport in agent' do
         | 
| 1206 | 
            +
                    let(:text) do
         | 
| 1207 | 
            +
                      "[agent]
         | 
| 1208 | 
            +
                  serverport = 445
         | 
| 1209 | 
            +
                  "
         | 
| 1210 | 
            +
                    end
         | 
| 1211 | 
            +
             | 
| 1212 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1213 | 
            +
                    it { expect(@settings[:masterport]).to eq(1000) }
         | 
| 1214 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1215 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1216 | 
            +
                  end
         | 
| 1217 | 
            +
             | 
| 1218 | 
            +
                  context 'with serverport in main' do
         | 
| 1219 | 
            +
                    let(:text) do
         | 
| 1220 | 
            +
                      "[main]
         | 
| 1221 | 
            +
                  serverport = 445
         | 
| 1222 | 
            +
                  "
         | 
| 1223 | 
            +
                    end
         | 
| 1224 | 
            +
             | 
| 1225 | 
            +
                    it { expect(@settings[:serverport]).to eq(445) }
         | 
| 1226 | 
            +
                    it { expect(@settings[:masterport]).to eq(1000) }
         | 
| 1227 | 
            +
                    it { expect(@settings[:ca_port]).to eq("445") }
         | 
| 1228 | 
            +
                    it { expect(@settings[:report_port]).to eq("445") }
         | 
| 1229 | 
            +
                  end
         | 
| 1230 | 
            +
                end
         | 
| 1231 | 
            +
             | 
| 1232 | 
            +
                it "does not use the metadata from the same setting in a different section" do
         | 
| 884 1233 | 
             
                  file = make_absolute("/file")
         | 
| 885 1234 | 
             
                  default_mode = "0600"
         | 
| 886 1235 | 
             
                  @settings.define_settings :main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS
         | 
| 887 | 
            -
                  @settings.define_settings : | 
| 1236 | 
            +
                  @settings.define_settings :server, :myfile => { :type => :file, :default => file, :desc => "a", :mode => default_mode }
         | 
| 888 1237 |  | 
| 889 | 
            -
                   | 
| 890 | 
            -
             | 
| 891 | 
            -
             | 
| 892 | 
            -
             | 
| 893 | 
            -
             | 
| 894 | 
            -
                   | 
| 1238 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1239 | 
            +
                    [server]
         | 
| 1240 | 
            +
                    myfile = #{file}/foo
         | 
| 1241 | 
            +
                    [agent]
         | 
| 1242 | 
            +
                    myfile = #{file} {mode = 664}
         | 
| 1243 | 
            +
                  CONF
         | 
| 895 1244 |  | 
| 896 1245 | 
             
                  # will start initialization as user
         | 
| 897 1246 | 
             
                  expect(@settings.preferred_run_mode).to eq(:user)
         | 
| 898 | 
            -
                  @settings. | 
| 1247 | 
            +
                  @settings.initialize_global_settings
         | 
| 899 1248 |  | 
| 900 | 
            -
                  # change app run_mode to  | 
| 901 | 
            -
                  @settings.initialize_app_defaults( | 
| 902 | 
            -
                  expect(@settings.preferred_run_mode).to eq(: | 
| 1249 | 
            +
                  # change app run_mode to server
         | 
| 1250 | 
            +
                  @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:run_mode => :server))
         | 
| 1251 | 
            +
                  expect(@settings.preferred_run_mode).to eq(:server)
         | 
| 903 1252 |  | 
| 904 1253 | 
             
                  # initializing the app should have reloaded the metadata based on run_mode
         | 
| 905 1254 | 
             
                  expect(@settings[:myfile]).to eq("#{file}/foo")
         | 
| @@ -910,11 +1259,12 @@ describe Puppet::Settings do | |
| 910 1259 | 
             
                  values = []
         | 
| 911 1260 | 
             
                  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
         | 
| 912 1261 |  | 
| 913 | 
            -
                   | 
| 914 | 
            -
             | 
| 915 | 
            -
             | 
| 916 | 
            -
                   | 
| 917 | 
            -
                  @settings. | 
| 1262 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1263 | 
            +
                    [main]
         | 
| 1264 | 
            +
                    mysetting = setval
         | 
| 1265 | 
            +
                  CONF
         | 
| 1266 | 
            +
                  @settings.initialize_global_settings
         | 
| 1267 | 
            +
             | 
| 918 1268 | 
             
                  expect(values).to eq(["setval"])
         | 
| 919 1269 | 
             
                end
         | 
| 920 1270 |  | 
| @@ -922,13 +1272,14 @@ describe Puppet::Settings do | |
| 922 1272 | 
             
                  values = []
         | 
| 923 1273 | 
             
                  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
         | 
| 924 1274 |  | 
| 925 | 
            -
                   | 
| 926 | 
            -
             | 
| 927 | 
            -
             | 
| 928 | 
            -
             | 
| 929 | 
            -
             | 
| 930 | 
            -
                   | 
| 931 | 
            -
                  @settings. | 
| 1275 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1276 | 
            +
                    [user]
         | 
| 1277 | 
            +
                    mysetting = setval
         | 
| 1278 | 
            +
                    [main]
         | 
| 1279 | 
            +
                    mysetting = other
         | 
| 1280 | 
            +
                  CONF
         | 
| 1281 | 
            +
                  @settings.initialize_global_settings
         | 
| 1282 | 
            +
             | 
| 932 1283 | 
             
                  expect(values).to eq(["setval"])
         | 
| 933 1284 | 
             
                end
         | 
| 934 1285 |  | 
| @@ -937,11 +1288,12 @@ describe Puppet::Settings do | |
| 937 1288 | 
             
                  @settings.define_settings :section, :base => {:default => "yay", :desc => "a", :hook => proc { |v| values << v }}
         | 
| 938 1289 | 
             
                  @settings.define_settings :section, :mysetting => {:default => "defval", :desc => "a", :hook => proc { |v| values << v }}
         | 
| 939 1290 |  | 
| 940 | 
            -
                   | 
| 941 | 
            -
             | 
| 942 | 
            -
             | 
| 943 | 
            -
                   | 
| 944 | 
            -
                  @settings. | 
| 1291 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1292 | 
            +
                    [main]
         | 
| 1293 | 
            +
                    mysetting = $base/setval
         | 
| 1294 | 
            +
                  CONF
         | 
| 1295 | 
            +
                  @settings.initialize_global_settings
         | 
| 1296 | 
            +
             | 
| 945 1297 | 
             
                  expect(values).to eq(["yay/setval"])
         | 
| 946 1298 | 
             
                end
         | 
| 947 1299 |  | 
| @@ -951,23 +1303,25 @@ describe Puppet::Settings do | |
| 951 1303 | 
             
                                                                     :hook => proc { |v| hook_invoked = true },
         | 
| 952 1304 | 
             
                                                                     :call_hook => :on_initialize_and_write, }
         | 
| 953 1305 |  | 
| 1306 | 
            +
                  # This test relies on `confdir` defaulting to nil which causes the default
         | 
| 1307 | 
            +
                  # value of `deferred=$confdir/goose` to raise an interpolation error during
         | 
| 1308 | 
            +
                  # global initialization, and the hook to be skipped
         | 
| 954 1309 | 
             
                  @settings.define_settings(:main,
         | 
| 955 | 
            -
             | 
| 956 | 
            -
             | 
| 957 | 
            -
                    :codedir      => { :type => :directory, :default => nil, :desc => "codedir" },
         | 
| 958 | 
            -
                    :vardir       => { :type => :directory, :default => nil, :desc => "vardir" })
         | 
| 1310 | 
            +
                                            PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS.merge(
         | 
| 1311 | 
            +
                                              :confdir => { :type => :directory, :default => nil, :desc => "confdir" }))
         | 
| 959 1312 |  | 
| 960 | 
            -
                   | 
| 961 | 
            -
             | 
| 962 | 
            -
             | 
| 1313 | 
            +
                  File.write(@file, <<~EOD)
         | 
| 1314 | 
            +
                    [main]
         | 
| 1315 | 
            +
                    deferred=$confdir/goose
         | 
| 963 1316 | 
             
                  EOD
         | 
| 964 1317 |  | 
| 965 | 
            -
                  allow(@settings).to receive(:read_file).and_return(text)
         | 
| 966 1318 | 
             
                  @settings.initialize_global_settings
         | 
| 967 1319 |  | 
| 968 1320 | 
             
                  expect(hook_invoked).to be_falsey
         | 
| 969 1321 |  | 
| 970 | 
            -
                   | 
| 1322 | 
            +
                  # And now that we initialize app defaults with `confdir`, then `deferred`
         | 
| 1323 | 
            +
                  # can be interpolated and its hook called
         | 
| 1324 | 
            +
                  @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
         | 
| 971 1325 |  | 
| 972 1326 | 
             
                  expect(hook_invoked).to be_truthy
         | 
| 973 1327 | 
             
                  expect(@settings[:deferred]).to eq(File.expand_path('/path/to/confdir/goose'))
         | 
| @@ -976,45 +1330,33 @@ describe Puppet::Settings do | |
| 976 1330 | 
             
                it "does not require the value for a setting without a hook to resolve during global setup" do
         | 
| 977 1331 | 
             
                  @settings.define_settings :section, :can_cause_problems  => {:desc => '' }
         | 
| 978 1332 |  | 
| 979 | 
            -
                  @settings.define_settings(:main,
         | 
| 980 | 
            -
                    :logdir       => { :type => :directory, :default => nil, :desc => "logdir" },
         | 
| 981 | 
            -
                    :confdir      => { :type => :directory, :default => nil, :desc => "confdir" },
         | 
| 982 | 
            -
                    :codedir      => { :type => :directory, :default => nil, :desc => "codedir" },
         | 
| 983 | 
            -
                    :vardir       => { :type => :directory, :default => nil, :desc => "vardir" })
         | 
| 1333 | 
            +
                  @settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
         | 
| 984 1334 |  | 
| 985 | 
            -
                   | 
| 1335 | 
            +
                  File.write(@file, <<~EOD)
         | 
| 986 1336 | 
             
                  [main]
         | 
| 987 1337 | 
             
                  can_cause_problems=$confdir/goose
         | 
| 988 1338 | 
             
                  EOD
         | 
| 989 1339 |  | 
| 990 | 
            -
                  allow(@settings).to receive(:read_file).and_return(text)
         | 
| 991 1340 | 
             
                  @settings.initialize_global_settings
         | 
| 992 | 
            -
                  @settings.initialize_app_defaults(: | 
| 1341 | 
            +
                  @settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES.merge(:confdir => '/path/to/confdir'))
         | 
| 993 1342 |  | 
| 994 | 
            -
                  expect(@settings[:can_cause_problems]).to eq( | 
| 1343 | 
            +
                  expect(@settings[:can_cause_problems]).to eq('/path/to/confdir/goose')
         | 
| 995 1344 | 
             
                end
         | 
| 996 1345 |  | 
| 997 1346 | 
             
                it "should allow empty values" do
         | 
| 998 1347 | 
             
                  @settings.define_settings :section, :myarg => { :default => "myfile", :desc => "a" }
         | 
| 999 1348 |  | 
| 1000 | 
            -
                   | 
| 1001 | 
            -
             | 
| 1002 | 
            -
             | 
| 1003 | 
            -
                   | 
| 1004 | 
            -
                  @settings. | 
| 1349 | 
            +
                  File.write(@file, <<~CONF)
         | 
| 1350 | 
            +
                    [main]
         | 
| 1351 | 
            +
                    myarg =
         | 
| 1352 | 
            +
                  CONF
         | 
| 1353 | 
            +
                  @settings.initialize_global_settings
         | 
| 1354 | 
            +
             | 
| 1005 1355 | 
             
                  expect(@settings[:myarg]).to eq("")
         | 
| 1006 1356 | 
             
                end
         | 
| 1007 1357 |  | 
| 1008 1358 | 
             
                describe "deprecations" do
         | 
| 1009 1359 | 
             
                  let(:settings) { Puppet::Settings.new }
         | 
| 1010 | 
            -
                  let(:app_defaults) {
         | 
| 1011 | 
            -
                    {
         | 
| 1012 | 
            -
                      :logdir     => "/dev/null",
         | 
| 1013 | 
            -
                      :confdir    => "/dev/null",
         | 
| 1014 | 
            -
                      :codedir    => "/dev/null",
         | 
| 1015 | 
            -
                      :vardir     => "/dev/null",
         | 
| 1016 | 
            -
                    }
         | 
| 1017 | 
            -
                  }
         | 
| 1018 1360 |  | 
| 1019 1361 | 
             
                  def assert_accessing_setting_is_deprecated(settings, setting)
         | 
| 1020 1362 | 
             
                    expect(Puppet).to receive(:deprecation_warning).with("Accessing '#{setting}' as a setting is deprecated.")
         | 
| @@ -1024,12 +1366,7 @@ describe Puppet::Settings do | |
| 1024 1366 | 
             
                  end
         | 
| 1025 1367 |  | 
| 1026 1368 | 
             
                  before(:each) do
         | 
| 1027 | 
            -
                    settings.define_settings(:main,  | 
| 1028 | 
            -
                      :logdir => { :default => 'a', :desc => 'a' },
         | 
| 1029 | 
            -
                      :confdir => { :default => 'b', :desc => 'b' },
         | 
| 1030 | 
            -
                      :vardir => { :default => 'c', :desc => 'c' },
         | 
| 1031 | 
            -
                      :codedir => { :default => 'd', :desc => 'd' },
         | 
| 1032 | 
            -
                    })
         | 
| 1369 | 
            +
                    settings.define_settings(:main, PuppetSpec::Settings::TEST_APP_DEFAULT_DEFINITIONS)
         | 
| 1033 1370 | 
             
                  end
         | 
| 1034 1371 |  | 
| 1035 1372 | 
             
                  context "complete" do
         | 
| @@ -1050,7 +1387,7 @@ describe Puppet::Settings do | |
| 1050 1387 | 
             
                      completely_deprecated_settings.parse_config(<<-CONF)
         | 
| 1051 1388 | 
             
                        completely_deprecated_setting='should warn'
         | 
| 1052 1389 | 
             
                      CONF
         | 
| 1053 | 
            -
                      completely_deprecated_settings.initialize_app_defaults( | 
| 1390 | 
            +
                      completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
         | 
| 1054 1391 | 
             
                    end
         | 
| 1055 1392 |  | 
| 1056 1393 | 
             
                    it "warns when set on the commandline" do
         | 
| @@ -1058,7 +1395,7 @@ describe Puppet::Settings do | |
| 1058 1395 |  | 
| 1059 1396 | 
             
                      args = ["--completely_deprecated_setting", "/some/value"]
         | 
| 1060 1397 | 
             
                      completely_deprecated_settings.send(:parse_global_options, args)
         | 
| 1061 | 
            -
                      completely_deprecated_settings.initialize_app_defaults( | 
| 1398 | 
            +
                      completely_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
         | 
| 1062 1399 | 
             
                    end
         | 
| 1063 1400 |  | 
| 1064 1401 | 
             
                    it "warns when set in code" do
         | 
| @@ -1083,7 +1420,7 @@ describe Puppet::Settings do | |
| 1083 1420 | 
             
                      partially_deprecated_settings.parse_config(<<-CONF)
         | 
| 1084 1421 | 
             
                        partially_deprecated_setting='should warn'
         | 
| 1085 1422 | 
             
                      CONF
         | 
| 1086 | 
            -
                      partially_deprecated_settings.initialize_app_defaults( | 
| 1423 | 
            +
                      partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
         | 
| 1087 1424 | 
             
                    end
         | 
| 1088 1425 |  | 
| 1089 1426 | 
             
                    it "does not warn when manifest is set on command line" do
         | 
| @@ -1091,7 +1428,7 @@ describe Puppet::Settings do | |
| 1091 1428 |  | 
| 1092 1429 | 
             
                      args = ["--partially_deprecated_setting", "/some/value"]
         | 
| 1093 1430 | 
             
                      partially_deprecated_settings.send(:parse_global_options, args)
         | 
| 1094 | 
            -
                      partially_deprecated_settings.initialize_app_defaults( | 
| 1431 | 
            +
                      partially_deprecated_settings.initialize_app_defaults(PuppetSpec::Settings::TEST_APP_DEFAULT_VALUES)
         | 
| 1095 1432 | 
             
                    end
         | 
| 1096 1433 |  | 
| 1097 1434 | 
             
                    it "warns when set in code" do
         | 
| @@ -1184,23 +1521,24 @@ describe Puppet::Settings do | |
| 1184 1521 |  | 
| 1185 1522 | 
             
              describe "when reparsing its configuration" do
         | 
| 1186 1523 | 
             
                before do
         | 
| 1187 | 
            -
                  @file =  | 
| 1188 | 
            -
                  @ | 
| 1524 | 
            +
                  @file = tmpfile("testfile")
         | 
| 1525 | 
            +
                  Puppet::FileSystem.touch(@file)
         | 
| 1526 | 
            +
             | 
| 1189 1527 | 
             
                  @settings = Puppet::Settings.new
         | 
| 1190 1528 | 
             
                  @settings.define_settings :section,
         | 
| 1191 1529 | 
             
                      :config => { :type => :file, :default => @file, :desc => "a" },
         | 
| 1192 1530 | 
             
                      :one => { :default => "ONE", :desc => "a" },
         | 
| 1193 1531 | 
             
                      :two => { :default => "$one TWO", :desc => "b" },
         | 
| 1194 1532 | 
             
                      :three => { :default => "$one $two THREE", :desc => "c" }
         | 
| 1195 | 
            -
             | 
| 1196 | 
            -
                   | 
| 1197 | 
            -
                  allow(@settings).to receive(:user_config_file).and_return( | 
| 1533 | 
            +
             | 
| 1534 | 
            +
                  userconfig = tmpfile("userconfig")
         | 
| 1535 | 
            +
                  allow(@settings).to receive(:user_config_file).and_return(userconfig)
         | 
| 1198 1536 | 
             
                end
         | 
| 1199 1537 |  | 
| 1200 1538 | 
             
                it "does not create the WatchedFile instance and should not parse if the file does not exist" do
         | 
| 1201 | 
            -
                   | 
| 1202 | 
            -
                  expect(Puppet::Util::WatchedFile).not_to receive(:new)
         | 
| 1539 | 
            +
                  Puppet::FileSystem.unlink(@file)
         | 
| 1203 1540 |  | 
| 1541 | 
            +
                  expect(Puppet::Util::WatchedFile).not_to receive(:new)
         | 
| 1204 1542 | 
             
                  expect(@settings).not_to receive(:parse_config_files)
         | 
| 1205 1543 |  | 
| 1206 1544 | 
             
                  @settings.reparse_config_files
         | 
| @@ -1239,8 +1577,8 @@ describe Puppet::Settings do | |
| 1239 1577 | 
             
                    @settings[:one] = "init"
         | 
| 1240 1578 |  | 
| 1241 1579 | 
             
                    # Now replace the value
         | 
| 1242 | 
            -
                     | 
| 1243 | 
            -
             | 
| 1580 | 
            +
                    File.write(@file, "[main]\none = disk-replace\n")
         | 
| 1581 | 
            +
             | 
| 1244 1582 | 
             
                    @settings.reparse_config_files
         | 
| 1245 1583 | 
             
                    expect(@settings[:one]).to eq("disk-replace")
         | 
| 1246 1584 | 
             
                  end
         | 
| @@ -1249,23 +1587,20 @@ describe Puppet::Settings do | |
| 1249 1587 | 
             
                it "should retain parameters set by cli when configuration files are reparsed" do
         | 
| 1250 1588 | 
             
                  @settings.handlearg("--one", "clival")
         | 
| 1251 1589 |  | 
| 1252 | 
            -
                   | 
| 1253 | 
            -
                   | 
| 1254 | 
            -
                  @settings.send(:parse_config_files)
         | 
| 1590 | 
            +
                  File.write(@file, "[main]\none = on-disk\n")
         | 
| 1591 | 
            +
                  @settings.initialize_global_settings
         | 
| 1255 1592 |  | 
| 1256 1593 | 
             
                  expect(@settings[:one]).to eq("clival")
         | 
| 1257 1594 | 
             
                end
         | 
| 1258 1595 |  | 
| 1259 1596 | 
             
                it "should remove in-memory values that are no longer set in the file" do
         | 
| 1260 1597 | 
             
                  # Init the value
         | 
| 1261 | 
            -
                   | 
| 1262 | 
            -
                  expect(@settings).to receive(:read_file).and_return(text)
         | 
| 1598 | 
            +
                  File.write(@file, "[main]\none = disk-init\n")
         | 
| 1263 1599 | 
             
                  @settings.send(:parse_config_files)
         | 
| 1264 1600 | 
             
                  expect(@settings[:one]).to eq("disk-init")
         | 
| 1265 1601 |  | 
| 1266 1602 | 
             
                  # Now replace the value
         | 
| 1267 | 
            -
                   | 
| 1268 | 
            -
                  expect(@settings).to receive(:read_file).and_return(text)
         | 
| 1603 | 
            +
                  File.write(@file, "[main]\ntwo = disk-replace\n")
         | 
| 1269 1604 | 
             
                  @settings.send(:parse_config_files)
         | 
| 1270 1605 |  | 
| 1271 1606 | 
             
                  # The originally-overridden value should be replaced with the default
         | 
| @@ -1277,14 +1612,12 @@ describe Puppet::Settings do | |
| 1277 1612 |  | 
| 1278 1613 | 
             
                it "should retain in-memory values if the file has a syntax error" do
         | 
| 1279 1614 | 
             
                  # Init the value
         | 
| 1280 | 
            -
                   | 
| 1281 | 
            -
                   | 
| 1282 | 
            -
                  @settings.send(:parse_config_files)
         | 
| 1615 | 
            +
                  File.write(@file, "[main]\none = initial-value\n")
         | 
| 1616 | 
            +
                  @settings.initialize_global_settings
         | 
| 1283 1617 | 
             
                  expect(@settings[:one]).to eq("initial-value")
         | 
| 1284 1618 |  | 
| 1285 1619 | 
             
                  # Now replace the value with something bogus
         | 
| 1286 | 
            -
                   | 
| 1287 | 
            -
                  expect(@settings).to receive(:read_file).with(@file).and_return(text)
         | 
| 1620 | 
            +
                  File.write(@file, "[main]\nkenny = killed-by-what-follows\n1 is 2, blah blah florp\n")
         | 
| 1288 1621 | 
             
                  @settings.send(:parse_config_files)
         | 
| 1289 1622 |  | 
| 1290 1623 | 
             
                  # The originally-overridden value should not be replaced with the default
         | 
| @@ -1296,46 +1629,49 @@ describe Puppet::Settings do | |
| 1296 1629 | 
             
              end
         | 
| 1297 1630 |  | 
| 1298 1631 | 
             
              it "should provide a method for creating a catalog of resources from its configuration" do
         | 
| 1299 | 
            -
                expect(Puppet::Settings.new).to  | 
| 1632 | 
            +
                expect(Puppet::Settings.new.to_catalog).to be_an_instance_of(Puppet::Resource::Catalog)
         | 
| 1300 1633 | 
             
              end
         | 
| 1301 1634 |  | 
| 1302 1635 | 
             
              describe "when creating a catalog" do
         | 
| 1636 | 
            +
                let(:maindir) { make_absolute('/maindir') }
         | 
| 1637 | 
            +
                let(:seconddir) { make_absolute('/seconddir') }
         | 
| 1638 | 
            +
                let(:otherdir) { make_absolute('/otherdir') }
         | 
| 1639 | 
            +
             | 
| 1303 1640 | 
             
                before do
         | 
| 1304 1641 | 
             
                  @settings = Puppet::Settings.new
         | 
| 1305 1642 | 
             
                  allow(@settings).to receive(:service_user_available?).and_return(true)
         | 
| 1306 | 
            -
                  @prefix = Puppet.features.posix? ? "" : "C:"
         | 
| 1307 1643 | 
             
                end
         | 
| 1308 1644 |  | 
| 1309 1645 | 
             
                it "should add all file resources to the catalog if no sections have been specified" do
         | 
| 1310 1646 | 
             
                  @settings.define_settings :main,
         | 
| 1311 | 
            -
                      :maindir => { :type => :directory, :default =>  | 
| 1312 | 
            -
                      :seconddir => { :type => :directory, :default =>  | 
| 1647 | 
            +
                      :maindir => { :type => :directory, :default => maindir, :desc => "a"},
         | 
| 1648 | 
            +
                      :seconddir => { :type => :directory, :default => seconddir, :desc => "a"}
         | 
| 1313 1649 | 
             
                  @settings.define_settings :other,
         | 
| 1314 | 
            -
                      :otherdir => { :type => :directory, :default =>  | 
| 1650 | 
            +
                      :otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
         | 
| 1315 1651 |  | 
| 1316 1652 | 
             
                  catalog = @settings.to_catalog
         | 
| 1317 1653 |  | 
| 1318 | 
            -
                  [ | 
| 1654 | 
            +
                  [maindir, seconddir, otherdir].each do |path|
         | 
| 1319 1655 | 
             
                    expect(catalog.resource(:file, path)).to be_instance_of(Puppet::Resource)
         | 
| 1320 1656 | 
             
                  end
         | 
| 1321 1657 | 
             
                end
         | 
| 1322 1658 |  | 
| 1323 1659 | 
             
                it "should add only files in the specified sections if section names are provided" do
         | 
| 1324 | 
            -
                  @settings.define_settings :main, :maindir => { :type => :directory, :default =>  | 
| 1325 | 
            -
                  @settings.define_settings :other, :otherdir => { :type => :directory, :default =>  | 
| 1660 | 
            +
                  @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
         | 
| 1661 | 
            +
                  @settings.define_settings :other, :otherdir => { :type => :directory, :default => otherdir, :desc => "a" }
         | 
| 1326 1662 | 
             
                  catalog = @settings.to_catalog(:main)
         | 
| 1327 | 
            -
                  expect(catalog.resource(:file,  | 
| 1328 | 
            -
                  expect(catalog.resource(:file,  | 
| 1663 | 
            +
                  expect(catalog.resource(:file, otherdir)).to be_nil
         | 
| 1664 | 
            +
                  expect(catalog.resource(:file, maindir)).to be_instance_of(Puppet::Resource)
         | 
| 1329 1665 | 
             
                end
         | 
| 1330 1666 |  | 
| 1331 1667 | 
             
                it "should not try to add the same file twice" do
         | 
| 1332 | 
            -
                  @settings.define_settings :main, :maindir => { :type => :directory, :default =>  | 
| 1333 | 
            -
                  @settings.define_settings :other, :otherdir => { :type => :directory, :default =>  | 
| 1668 | 
            +
                  @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
         | 
| 1669 | 
            +
                  @settings.define_settings :other, :otherdir => { :type => :directory, :default => maindir, :desc => "a" }
         | 
| 1334 1670 | 
             
                  expect { @settings.to_catalog }.not_to raise_error
         | 
| 1335 1671 | 
             
                end
         | 
| 1336 1672 |  | 
| 1337 1673 | 
             
                it "should ignore files whose :to_resource method returns nil" do
         | 
| 1338 | 
            -
                  @settings.define_settings :main, :maindir => { :type => :directory, :default =>  | 
| 1674 | 
            +
                  @settings.define_settings :main, :maindir => { :type => :directory, :default => maindir, :desc => "a" }
         | 
| 1339 1675 | 
             
                  expect(@settings.setting(:maindir)).to receive(:to_resource).and_return(nil)
         | 
| 1340 1676 |  | 
| 1341 1677 | 
             
                  expect_any_instance_of(Puppet::Resource::Catalog).not_to receive(:add_resource)
         | 
| @@ -1365,6 +1701,7 @@ describe Puppet::Settings do | |
| 1365 1701 | 
             
                describe "adding default directory environment to the catalog" do
         | 
| 1366 1702 | 
             
                  let(:tmpenv) { tmpdir("envs") }
         | 
| 1367 1703 | 
             
                  let(:default_path) { "#{tmpenv}/environments" }
         | 
| 1704 | 
            +
             | 
| 1368 1705 | 
             
                  before(:each) do
         | 
| 1369 1706 | 
             
                    @settings.define_settings :main,
         | 
| 1370 1707 | 
             
                      :environment     => { :default => "production", :desc => "env"},
         | 
| @@ -1900,18 +2237,18 @@ describe Puppet::Settings do | |
| 1900 2237 | 
             
                end
         | 
| 1901 2238 |  | 
| 1902 2239 | 
             
                it "should set preferred run mode from --run_mode <foo> string without error" do
         | 
| 1903 | 
            -
                  args = ["--run_mode", " | 
| 1904 | 
            -
                  expect(settings).not_to receive(:handlearg).with("--run_mode", " | 
| 2240 | 
            +
                  args = ["--run_mode", "server"]
         | 
| 2241 | 
            +
                  expect(settings).not_to receive(:handlearg).with("--run_mode", "server")
         | 
| 1905 2242 | 
             
                  expect { settings.send(:parse_global_options, args) } .to_not raise_error
         | 
| 1906 | 
            -
                  expect(Puppet.settings.preferred_run_mode).to eq(: | 
| 2243 | 
            +
                  expect(Puppet.settings.preferred_run_mode).to eq(:server)
         | 
| 1907 2244 | 
             
                  expect(args.empty?).to eq(true)
         | 
| 1908 2245 | 
             
                end
         | 
| 1909 2246 |  | 
| 1910 2247 | 
             
                it "should set preferred run mode from --run_mode=<foo> string without error" do
         | 
| 1911 | 
            -
                  args = ["--run_mode= | 
| 1912 | 
            -
                  expect(settings).not_to receive(:handlearg).with("--run_mode", " | 
| 2248 | 
            +
                  args = ["--run_mode=server"]
         | 
| 2249 | 
            +
                  expect(settings).not_to receive(:handlearg).with("--run_mode", "server")
         | 
| 1913 2250 | 
             
                  expect { settings.send(:parse_global_options, args) }.to_not raise_error
         | 
| 1914 | 
            -
                  expect(Puppet.settings.preferred_run_mode).to eq(: | 
| 2251 | 
            +
                  expect(Puppet.settings.preferred_run_mode).to eq(:server)
         | 
| 1915 2252 | 
             
                  expect(args.empty?).to eq(true)
         | 
| 1916 2253 | 
             
                end
         | 
| 1917 2254 | 
             
              end
         |