puppet 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -7
- data/README.md +1 -1
- data/Rakefile +20 -0
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/osx/puppet.plist +2 -4
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/client.init +65 -12
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +5 -1
- data/ext/redhat/server.init +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +27 -27
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +21 -39
- data/lib/hiera/puppet_function.rb +5 -5
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +4 -4
- data/lib/puppet/application/agent.rb +28 -14
- data/lib/puppet/application/apply.rb +17 -4
- data/lib/puppet/application/cert.rb +16 -0
- data/lib/puppet/application/filebucket.rb +78 -4
- data/lib/puppet/application/lookup.rb +356 -0
- data/lib/puppet/application/master.rb +5 -1
- data/lib/puppet/configurer.rb +9 -5
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers/data_adapter.rb +7 -68
- data/lib/puppet/data_providers/data_function_support.rb +5 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
- data/lib/puppet/data_providers/hiera_config.rb +106 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
- data/lib/puppet/data_providers/hiera_support.rb +37 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
- data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
- data/lib/puppet/data_providers.rb +12 -13
- data/lib/puppet/defaults.rb +14 -3
- data/lib/puppet/environments.rb +94 -6
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/file_system/windows.rb +3 -1
- data/lib/puppet/functions/assert_type.rb +48 -12
- data/lib/puppet/functions/defined.rb +79 -48
- data/lib/puppet/functions/each.rb +85 -27
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/filter.rb +60 -25
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +65 -3
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +77 -4
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/functions/lookup.rb +19 -17
- data/lib/puppet/functions/map.rb +56 -21
- data/lib/puppet/functions/match.rb +29 -12
- data/lib/puppet/functions/reduce.rb +95 -58
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/functions.rb +2 -4
- data/lib/puppet/indirector/catalog/compiler.rb +3 -3
- data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/indirection.rb +6 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/request.rb +7 -8
- data/lib/puppet/indirector/resource_type/parser.rb +5 -3
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +32 -9
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/node/environment.rb +9 -2
- data/lib/puppet/node.rb +11 -5
- data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +300 -12
- data/lib/puppet/parser/environment_compiler.rb +165 -0
- data/lib/puppet/parser/functions/assert_type.rb +46 -16
- data/lib/puppet/parser/functions/defined.rb +105 -68
- data/lib/puppet/parser/functions/each.rb +85 -27
- data/lib/puppet/parser/functions/epp.rb +29 -37
- data/lib/puppet/parser/functions/filter.rb +59 -23
- data/lib/puppet/parser/functions/hiera.rb +83 -27
- data/lib/puppet/parser/functions/hiera_array.rb +71 -28
- data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
- data/lib/puppet/parser/functions/hiera_include.rb +81 -40
- data/lib/puppet/parser/functions/inline_epp.rb +35 -60
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- data/lib/puppet/parser/functions/map.rb +55 -20
- data/lib/puppet/parser/functions/match.rb +27 -12
- data/lib/puppet/parser/functions/reduce.rb +97 -60
- data/lib/puppet/parser/functions/with.rb +16 -8
- data/lib/puppet/parser/resource.rb +103 -21
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/plugins/data_providers.rb +12 -60
- data/lib/puppet/pops/adapters.rb +12 -0
- data/lib/puppet/pops/binder/binder.rb +2 -2
- data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/injector.rb +4 -4
- data/lib/puppet/pops/binder/key_factory.rb +3 -9
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
- data/lib/puppet/pops/evaluator/closure.rb +8 -8
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +10 -6
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
- data/lib/puppet/pops/functions/dispatcher.rb +3 -3
- data/lib/puppet/pops/issues.rb +11 -3
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/lookup/explainer.rb +402 -0
- data/lib/puppet/pops/lookup/invocation.rb +117 -0
- data/lib/puppet/pops/lookup.rb +25 -47
- data/lib/puppet/pops/merge_strategy.rb +73 -5
- data/lib/puppet/pops/model/factory.rb +38 -3
- data/lib/puppet/pops/model/model_label_provider.rb +10 -1
- data/lib/puppet/pops/model/model_meta.rb +19 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +65 -2
- data/lib/puppet/pops/parser/eparser.rb +1569 -1241
- data/lib/puppet/pops/parser/lexer2.rb +32 -1
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/parser_support.rb +25 -13
- data/lib/puppet/pops/patterns.rb +3 -0
- data/lib/puppet/pops/types/enumeration.rb +1 -2
- data/lib/puppet/pops/types/type_asserter.rb +16 -15
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +171 -1020
- data/lib/puppet/pops/types/type_factory.rb +87 -148
- data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
- data/lib/puppet/pops/types/type_parser.rb +118 -129
- data/lib/puppet/pops/types/types.rb +1394 -255
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/pops/validation/checker4_0.rb +49 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +3 -1
- data/lib/puppet/pops/validation.rb +7 -2
- data/lib/puppet/pops.rb +19 -17
- data/lib/puppet/provider/augeas/augeas.rb +50 -0
- data/lib/puppet/provider/exec.rb +6 -1
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/package/dnf.rb +41 -0
- data/lib/puppet/provider/package/gem.rb +7 -2
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -0
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/yum.rb +20 -9
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +21 -0
- data/lib/puppet/provider/service/init.rb +6 -0
- data/lib/puppet/provider/service/launchd.rb +36 -7
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +43 -2
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +25 -5
- data/lib/puppet/provider/sshkey/parsed.rb +19 -9
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +10 -4
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource/capability_finder.rb +95 -0
- data/lib/puppet/resource/catalog.rb +47 -7
- data/lib/puppet/resource/status.rb +0 -2
- data/lib/puppet/resource/type.rb +238 -44
- data/lib/puppet/resource/type_collection.rb +60 -2
- data/lib/puppet/resource.rb +50 -73
- data/lib/puppet/settings/file_setting.rb +10 -9
- data/lib/puppet/settings.rb +2 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/ssl/oids.rb +9 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
- data/lib/puppet/transaction/resource_harness.rb +9 -4
- data/lib/puppet/transaction.rb +8 -1
- data/lib/puppet/type/augeas.rb +8 -0
- data/lib/puppet/type/file/source.rb +14 -12
- data/lib/puppet/type/package.rb +9 -6
- data/lib/puppet/type/user.rb +4 -2
- data/lib/puppet/type.rb +78 -7
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/util/execution.rb +18 -2
- data/lib/puppet/util/tagging.rb +7 -1
- data/lib/puppet/util/windows/adsi.rb +5 -2
- data/lib/puppet/util/windows/security.rb +4 -1
- data/lib/puppet/util/windows/taskscheduler.rb +1 -1
- data/lib/puppet/util.rb +9 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +12 -0
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/integration/data_binding_spec.rb +229 -0
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/parser/compiler_spec.rb +30 -24
- data/spec/integration/parser/resource_expressions_spec.rb +4 -4
- data/spec/integration/parser/undef_param_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +3 -1
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/type/package_spec.rb +2 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +18 -0
- data/spec/lib/matchers/include_in_order.rb +2 -2
- data/spec/shared_behaviours/iterative_functions.rb +8 -8
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +0 -8
- data/spec/unit/application/agent_spec.rb +5 -0
- data/spec/unit/application/apply_spec.rb +9 -1
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/lookup_spec.rb +195 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/appmgmt_spec.rb +657 -0
- data/spec/unit/capability_spec.rb +414 -0
- data/spec/unit/configurer_spec.rb +7 -1
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
- data/spec/unit/environments_spec.rb +2 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_system_spec.rb +20 -0
- data/spec/unit/functions/assert_type_spec.rb +5 -7
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +2 -2
- data/spec/unit/functions/filter_spec.rb +18 -0
- data/spec/unit/functions/hiera_spec.rb +2 -2
- data/spec/unit/functions/lookup_spec.rb +200 -9
- data/spec/unit/functions/regsubst_spec.rb +17 -8
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +2 -2
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +58 -72
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
- data/spec/unit/indirector/indirection_spec.rb +13 -2
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +236 -0
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +14 -19
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/node_spec.rb +27 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +86 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +2 -20
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +20 -11
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +39 -0
- data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/parser/parser_spec.rb +18 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
- data/spec/unit/pops/types/type_factory_spec.rb +12 -12
- data/spec/unit/pops/types/type_parser_spec.rb +15 -12
- data/spec/unit/pops/validator/validator_spec.rb +68 -0
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
- data/spec/unit/provider/package/dnf_spec.rb +92 -0
- data/spec/unit/provider/package/gem_spec.rb +7 -0
- data/spec/unit/provider/package/nim_spec.rb +6 -6
- data/spec/unit/provider/package/rpm_spec.rb +25 -2
- data/spec/unit/provider/package/windows/package_spec.rb +41 -0
- data/spec/unit/provider/package/yum_spec.rb +35 -12
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
- data/spec/unit/provider/service/debian_spec.rb +28 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +6 -0
- data/spec/unit/provider/service/launchd_spec.rb +85 -10
- data/spec/unit/provider/service/openrc_spec.rb +1 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/smf_spec.rb +30 -5
- data/spec/unit/provider/service/src_spec.rb +20 -4
- data/spec/unit/provider/service/systemd_spec.rb +79 -29
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +2 -1
- data/spec/unit/provider/zone/solaris_spec.rb +19 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +56 -0
- data/spec/unit/resource/catalog_spec.rb +31 -8
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +23 -5
- data/spec/unit/settings/file_setting_spec.rb +31 -0
- data/spec/unit/settings_spec.rb +91 -2
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/host_spec.rb +2 -2
- data/spec/unit/ssl/oids_spec.rb +8 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
- data/spec/unit/transaction/report_spec.rb +24 -1
- data/spec/unit/transaction_spec.rb +7 -0
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +1 -1
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util/windows/adsi_spec.rb +13 -0
- data/spec/unit/util_spec.rb +21 -2
- metadata +173 -7
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/spec/integration/data_binding.rb +0 -104
|
@@ -10,7 +10,6 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
10
10
|
described_class.stubs(:which).with('systemctl').returns '/bin/systemctl'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
let :provider do
|
|
15
14
|
described_class.new(:name => 'sshd.service')
|
|
16
15
|
end
|
|
@@ -19,14 +18,14 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
19
18
|
|
|
20
19
|
osfamily.each do |osfamily|
|
|
21
20
|
it "should be the default provider on #{osfamily}" do
|
|
22
|
-
Facter.
|
|
21
|
+
Facter.stubs(:value).with(:osfamily).returns(osfamily)
|
|
23
22
|
expect(described_class.default?).to be_truthy
|
|
24
23
|
end
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should be the default provider on rhel7" do
|
|
28
|
-
Facter.
|
|
29
|
-
Facter.
|
|
27
|
+
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
|
28
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
|
|
30
29
|
expect(described_class.default?).to be_truthy
|
|
31
30
|
end
|
|
32
31
|
|
|
@@ -36,7 +35,7 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
36
35
|
# caused short-circuiting of the logic used by default.all? in the
|
|
37
36
|
# provider. As a workaround we need to use stubs() instead of
|
|
38
37
|
# expects() here.
|
|
39
|
-
Facter.
|
|
38
|
+
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
|
40
39
|
Facter.stubs(:value).with(:operatingsystem).returns(:redhat)
|
|
41
40
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
|
|
42
41
|
expect(described_class.default?).not_to be_truthy
|
|
@@ -45,57 +44,64 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
45
44
|
|
|
46
45
|
[ 17, 18, 19, 20, 21 ].each do |ver|
|
|
47
46
|
it "should be the default provider on fedora#{ver}" do
|
|
48
|
-
Facter.
|
|
49
|
-
Facter.
|
|
50
|
-
Facter.
|
|
47
|
+
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
|
48
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:fedora)
|
|
49
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
|
|
51
50
|
expect(described_class.default?).to be_truthy
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
it "should be the default provider on sles12" do
|
|
56
|
-
Facter.
|
|
57
|
-
Facter.
|
|
55
|
+
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
|
56
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("12")
|
|
58
57
|
expect(described_class.default?).to be_truthy
|
|
59
58
|
end
|
|
60
59
|
|
|
61
60
|
it "should be the default provider on opensuse13" do
|
|
62
|
-
Facter.
|
|
63
|
-
Facter.
|
|
61
|
+
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
|
62
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("13")
|
|
64
63
|
expect(described_class.default?).to be_truthy
|
|
65
64
|
end
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Facter.
|
|
70
|
-
Facter.
|
|
71
|
-
expect(described_class.default?).
|
|
66
|
+
# tumbleweed is a rolling release with date-based major version numbers
|
|
67
|
+
it "should be the default provider on tumbleweed" do
|
|
68
|
+
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
|
69
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("20150829")
|
|
70
|
+
expect(described_class.default?).to be_truthy
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# leap is the next generation suse release
|
|
74
|
+
it "should be the default provider on leap" do
|
|
75
|
+
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
|
76
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("42")
|
|
77
|
+
expect(described_class.default?).to be_truthy
|
|
72
78
|
end
|
|
73
79
|
|
|
74
80
|
it "should not be the default provider on debian7" do
|
|
75
|
-
Facter.
|
|
76
|
-
Facter.
|
|
77
|
-
Facter.
|
|
81
|
+
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
|
82
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:debian)
|
|
83
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
|
|
78
84
|
expect(described_class.default?).not_to be_truthy
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
it "should be the default provider on debian8" do
|
|
82
|
-
Facter.
|
|
83
|
-
Facter.
|
|
84
|
-
Facter.
|
|
88
|
+
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
|
89
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:debian)
|
|
90
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("8")
|
|
85
91
|
expect(described_class.default?).to be_truthy
|
|
86
92
|
end
|
|
87
93
|
|
|
88
94
|
it "should not be the default provider on ubuntu14.04" do
|
|
89
|
-
Facter.
|
|
90
|
-
Facter.
|
|
91
|
-
Facter.
|
|
95
|
+
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
|
96
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
|
|
97
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("14.04")
|
|
92
98
|
expect(described_class.default?).not_to be_truthy
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
it "should be the default provider on ubuntu15.04" do
|
|
96
|
-
Facter.
|
|
97
|
-
Facter.
|
|
98
|
-
Facter.
|
|
102
|
+
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
|
103
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
|
|
104
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("15.04")
|
|
99
105
|
expect(described_class.default?).to be_truthy
|
|
100
106
|
end
|
|
101
107
|
|
|
@@ -132,6 +138,7 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
132
138
|
|
|
133
139
|
it "should start the service with systemctl start otherwise" do
|
|
134
140
|
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
|
141
|
+
provider.expects(:systemctl).with('unmask', 'sshd.service')
|
|
135
142
|
provider.expects(:execute).with(['/bin/systemctl','start','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
|
|
136
143
|
provider.start
|
|
137
144
|
end
|
|
@@ -263,6 +270,49 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
|
263
270
|
end
|
|
264
271
|
end
|
|
265
272
|
|
|
273
|
+
describe "#debian_enabled?" do
|
|
274
|
+
[104, 106].each do |status|
|
|
275
|
+
it "should return true when invoke-rc.d returns #{status}" do
|
|
276
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
|
277
|
+
provider.stubs(:system)
|
|
278
|
+
$CHILD_STATUS.expects(:exitstatus).returns(status)
|
|
279
|
+
expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:true)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
[101, 105].each do |status|
|
|
284
|
+
it "should return true when status is #{status} and there are at least 4 start links" do
|
|
285
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
|
286
|
+
provider.stubs(:system)
|
|
287
|
+
provider.expects(:get_start_link_count).returns(4)
|
|
288
|
+
$CHILD_STATUS.expects(:exitstatus).twice.returns(status)
|
|
289
|
+
expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:true)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
it "should return false when status is #{status} and there are less than 4 start links" do
|
|
293
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
|
294
|
+
provider.stubs(:system)
|
|
295
|
+
provider.expects(:get_start_link_count).returns(1)
|
|
296
|
+
$CHILD_STATUS.expects(:exitstatus).twice.returns(status)
|
|
297
|
+
expect(provider.debian_enabled?({:LoadState => "loaded", :UnitFileState => "UnitFileState"})).to eq(:false)
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
describe "#get_start_link_count" do
|
|
303
|
+
it "should strip the '.service' from the search if present in the resource name" do
|
|
304
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
|
|
305
|
+
Dir.expects(:glob).with("/etc/rc*.d/S??sshd").returns(['files'])
|
|
306
|
+
provider.get_start_link_count
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it "should use the full service name if it does not include '.service'" do
|
|
310
|
+
provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
|
|
311
|
+
Dir.expects(:glob).with("/etc/rc*.d/S??sshd").returns(['files'])
|
|
312
|
+
provider.get_start_link_count
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
266
316
|
it "(#16451) has command systemctl without being fully qualified" do
|
|
267
317
|
expect(described_class.instance_variable_get(:@commands)).to include(:systemctl => 'systemctl')
|
|
268
318
|
end
|
|
@@ -261,7 +261,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
|
261
261
|
@resource = Puppet::Type.type(:ssh_authorized_key).new(:name => "foo", :target => "/tmp/.ssh_dir/place_to_put_authorized_keys")
|
|
262
262
|
@provider = provider_class.new(@resource)
|
|
263
263
|
|
|
264
|
-
expect { @provider.flush }.to raise_error
|
|
264
|
+
expect { @provider.flush }.to raise_error(Puppet::Error, /Cannot write SSH authorized keys without user/)
|
|
265
265
|
end
|
|
266
266
|
end
|
|
267
267
|
|
|
@@ -68,4 +68,27 @@ describe "sshkey parsed provider" do
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
+
|
|
72
|
+
context 'default ssh_known_hosts target path' do
|
|
73
|
+
['9.10', '9.11', '10.10'].each do |version|
|
|
74
|
+
it 'should be `/etc/ssh_known_hosts` when OSX version 10.10 or older`' do
|
|
75
|
+
Facter.expects(:value).with(:operatingsystem).returns('Darwin')
|
|
76
|
+
Facter.expects(:value).with(:macosx_productversion_major).returns(version)
|
|
77
|
+
expect(subject.default_target).to eq('/etc/ssh_known_hosts')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
['10.11', '10.13', '11.0', '11.11'].each do |version|
|
|
82
|
+
it 'should be `/etc/ssh/ssh_known_hosts` when OSX version 10.11 or newer`' do
|
|
83
|
+
Facter.expects(:value).with(:operatingsystem).returns('Darwin')
|
|
84
|
+
Facter.expects(:value).with(:macosx_productversion_major).returns(version)
|
|
85
|
+
expect(subject.default_target).to eq('/etc/ssh/ssh_known_hosts')
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'should be `/etc/ssh/ssh_known_hosts` on other operating systems' do
|
|
90
|
+
Facter.expects(:value).with(:operatingsystem).returns('RedHat')
|
|
91
|
+
expect(subject.default_target).to eq('/etc/ssh/ssh_known_hosts')
|
|
92
|
+
end
|
|
93
|
+
end
|
|
71
94
|
end
|
|
@@ -232,7 +232,8 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
|
|
|
232
232
|
resource[:name] = 'DOMAIN\testdomainuser'
|
|
233
233
|
Puppet::Util::Windows::ADSI::Group.expects(:exists?).with(resource[:name]).returns(false)
|
|
234
234
|
connection.expects(:Create)
|
|
235
|
-
connection.expects(:
|
|
235
|
+
connection.expects(:Get).with('UserFlags')
|
|
236
|
+
connection.expects(:Put).with('UserFlags', true)
|
|
236
237
|
connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
|
|
237
238
|
|
|
238
239
|
expect{ provider.create }.to raise_error(
|
|
@@ -149,6 +149,25 @@ net:
|
|
|
149
149
|
})
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
|
+
describe "with an invalid or unrecognized config" do
|
|
153
|
+
it "should produce an error message with provider context when given an invalid config" do
|
|
154
|
+
erroneous_zone_info =<<-EOF
|
|
155
|
+
physical: net1'
|
|
156
|
+
EOF
|
|
157
|
+
|
|
158
|
+
provider.expects(:zonecfg).with(:info).returns(erroneous_zone_info)
|
|
159
|
+
provider.expects('err').with("Ignoring ' physical: net1''")
|
|
160
|
+
provider.getconfig
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
it "should produce a debugging message with provider context when given an unrecognized config" do
|
|
165
|
+
unrecognized_zone_info = "dummy"
|
|
166
|
+
provider.expects(:zonecfg).with(:info).returns(unrecognized_zone_info)
|
|
167
|
+
provider.expects('debug').with("Ignoring zone output 'dummy'")
|
|
168
|
+
provider.getconfig
|
|
169
|
+
end
|
|
170
|
+
end
|
|
152
171
|
end
|
|
153
172
|
context "#flush" do
|
|
154
173
|
it "should correctly execute pending commands" do
|
data/spec/unit/reports_spec.rb
CHANGED
|
@@ -43,6 +43,16 @@ describe Puppet::Reports, " when registering report types" do
|
|
|
43
43
|
Puppet::Reports.register_report(:testing) { }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
it "should allow a successful report to be reloaded" do
|
|
47
|
+
Puppet::Reports.register_report(:testing) { }
|
|
48
|
+
Puppet::Reports.register_report(:testing) { }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should allow a failed report to be reloaded and show the correct exception both times" do
|
|
52
|
+
expect { Puppet::Reports.register_report(:testing) { raise TypeError, 'failed report' } }.to raise_error(TypeError)
|
|
53
|
+
expect { Puppet::Reports.register_report(:testing) { raise TypeError, 'failed report' } }.to raise_error(TypeError)
|
|
54
|
+
end
|
|
55
|
+
|
|
46
56
|
it "should extend the report type with the Puppet::Util::Docs module" do
|
|
47
57
|
mod = stub 'module', :define_method => true
|
|
48
58
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require_relative '../pops/parser/parser_rspec_helper'
|
|
4
|
+
require 'puppet/resource/capability_finder'
|
|
5
|
+
|
|
6
|
+
describe Puppet::Resource::CapabilityFinder do
|
|
7
|
+
context 'when PuppetDB is not configured' do
|
|
8
|
+
it 'should error' do
|
|
9
|
+
Puppet::Util.expects(:const_defined?).with('Puppetdb').returns false
|
|
10
|
+
expect { Puppet::Resource::CapabilityFinder.find('production', nil, nil) }.to raise_error(/PuppetDB is not available/)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'when PuppetDB is configured' do
|
|
15
|
+
around(:each) do |example|
|
|
16
|
+
mock_pdb = !Puppet::Util.const_defined?('Puppetdb')
|
|
17
|
+
if mock_pdb
|
|
18
|
+
class Puppet::Util::Puppetdb
|
|
19
|
+
class Http; end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
begin
|
|
23
|
+
make_cap_type
|
|
24
|
+
example.run
|
|
25
|
+
ensure
|
|
26
|
+
Puppet::Util.send(:remove_const, 'Puppetdb') if mock_pdb
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class MockResponse
|
|
31
|
+
def body
|
|
32
|
+
'[{"type": "Cap", "title": "cap", "parameters": { "host" : "ahost" }}]'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def make_cap_type
|
|
37
|
+
Puppet::Type.newtype :cap, :is_capability => true do
|
|
38
|
+
newparam :name
|
|
39
|
+
newparam :host
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should call Puppet::Util::PuppetDB::Http.action' do
|
|
44
|
+
Puppet::Util::Puppetdb::Http.expects(:action).returns(MockResponse.new)
|
|
45
|
+
result = Puppet::Resource::CapabilityFinder.find('production', nil, Puppet::Resource.new('Cap', 'cap'))
|
|
46
|
+
expect(result['host']).to eq('ahost')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should use pass code_id in query to Puppet::Util::PuppetDB::Http.action' do
|
|
50
|
+
code_id = 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe'
|
|
51
|
+
Puppet::Util::Puppetdb::Http.expects(:action).with(regexp_matches(Regexp.new(CGI.escape('"=","code_id","' + code_id + "")))).returns(MockResponse.new)
|
|
52
|
+
result = Puppet::Resource::CapabilityFinder.find('production', code_id, Puppet::Resource.new('Cap', 'cap'))
|
|
53
|
+
expect(result['host']).to eq('ahost')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -86,6 +86,11 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
|
86
86
|
expect(@catalog.server_version).to eq(5)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
it "defaults code_id to nil" do
|
|
90
|
+
catalog = Puppet::Resource::Catalog.new("host")
|
|
91
|
+
expect(catalog.code_id).to be_nil
|
|
92
|
+
end
|
|
93
|
+
|
|
89
94
|
describe "when compiling" do
|
|
90
95
|
it "should accept tags" do
|
|
91
96
|
config = Puppet::Resource::Catalog.new("mynode")
|
|
@@ -253,6 +258,16 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
|
253
258
|
r == @r1
|
|
254
259
|
end.edge?(@r1,@r2)).not_to be
|
|
255
260
|
end
|
|
261
|
+
|
|
262
|
+
it "copies the version" do
|
|
263
|
+
@original.version = '123'
|
|
264
|
+
expect(@original.filter.version).to eq(@original.version)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it 'copies the code_id' do
|
|
268
|
+
@original.code_id = 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe'
|
|
269
|
+
expect(@original.filter.code_id).to eq(@original.code_id)
|
|
270
|
+
end
|
|
256
271
|
end
|
|
257
272
|
|
|
258
273
|
describe "when functioning as a resource container" do
|
|
@@ -782,17 +797,23 @@ describe Puppet::Resource::Catalog, "when converting to pson" do
|
|
|
782
797
|
@catalog = Puppet::Resource::Catalog.new("myhost")
|
|
783
798
|
end
|
|
784
799
|
|
|
785
|
-
|
|
786
|
-
|
|
800
|
+
{ :name => 'myhost',
|
|
801
|
+
:version => 42,
|
|
802
|
+
:code_id => 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe'
|
|
803
|
+
}.each do |param, value|
|
|
804
|
+
it "emits a #{param} equal to #{value.inspect}" do
|
|
805
|
+
@catalog.send(param.to_s + "=", value)
|
|
806
|
+
pson = PSON.parse(@catalog.to_pson)
|
|
807
|
+
|
|
808
|
+
expect(pson[param.to_s]).to eq(@catalog.send(param))
|
|
809
|
+
end
|
|
787
810
|
end
|
|
788
811
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
812
|
+
it "emits an array of classes" do
|
|
813
|
+
@catalog.add_class('foo')
|
|
814
|
+
pson = PSON.parse(@catalog.to_pson)
|
|
792
815
|
|
|
793
|
-
|
|
794
|
-
Puppet::Resource::Catalog.from_data_hash PSON.parse @catalog.to_pson
|
|
795
|
-
end
|
|
816
|
+
expect(pson['classes']).to eq(['foo'])
|
|
796
817
|
end
|
|
797
818
|
|
|
798
819
|
it "should convert its resources to a PSON-encoded array and store it as the 'resources' data" do
|
|
@@ -831,6 +852,7 @@ describe Puppet::Resource::Catalog, "when converting from pson" do
|
|
|
831
852
|
|
|
832
853
|
it "should create it with the provided name" do
|
|
833
854
|
@data['version'] = 50
|
|
855
|
+
@data['code_id'] = 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe'
|
|
834
856
|
@data['tags'] = %w{one two}
|
|
835
857
|
@data['classes'] = %w{one two}
|
|
836
858
|
@data['edges'] = [Puppet::Relationship.new("File[/foo]", "File[/bar]",
|
|
@@ -844,6 +866,7 @@ describe Puppet::Resource::Catalog, "when converting from pson" do
|
|
|
844
866
|
|
|
845
867
|
expect(catalog.name).to eq('myhost')
|
|
846
868
|
expect(catalog.version).to eq(@data['version'])
|
|
869
|
+
expect(catalog.code_id).to eq(@data['code_id'])
|
|
847
870
|
expect(catalog).to be_tagged("one")
|
|
848
871
|
expect(catalog).to be_tagged("two")
|
|
849
872
|
|
|
@@ -76,16 +76,18 @@ describe Puppet::Resource::TypeCollection do
|
|
|
76
76
|
end.to raise_error(Puppet::ParseError, /cannot be redefined/)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
it "should remove all nodes, classes, and
|
|
79
|
+
it "should remove all nodes, classes, definitions, and applications when cleared" do
|
|
80
80
|
loader = Puppet::Resource::TypeCollection.new(environment)
|
|
81
81
|
loader.add Puppet::Resource::Type.new(:hostclass, "class")
|
|
82
82
|
loader.add Puppet::Resource::Type.new(:definition, "define")
|
|
83
83
|
loader.add Puppet::Resource::Type.new(:node, "node")
|
|
84
|
+
loader.add Puppet::Resource::Type.new(:application, "application")
|
|
84
85
|
|
|
85
86
|
loader.clear
|
|
86
87
|
expect(loader.hostclass("class")).to be_nil
|
|
87
88
|
expect(loader.definition("define")).to be_nil
|
|
88
89
|
expect(loader.node("node")).to be_nil
|
|
90
|
+
expect(loader.node("application")).to be_nil
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
describe "when looking up names" do
|
|
@@ -153,7 +155,8 @@ describe Puppet::Resource::TypeCollection do
|
|
|
153
155
|
end
|
|
154
156
|
end
|
|
155
157
|
|
|
156
|
-
%w{hostclass node definition}
|
|
158
|
+
KINDS = %w{hostclass node definition application}
|
|
159
|
+
KINDS.each do |data|
|
|
157
160
|
describe "behavior of add for #{data}" do
|
|
158
161
|
|
|
159
162
|
it "should return the added #{data}" do
|
|
@@ -175,6 +178,24 @@ describe Puppet::Resource::TypeCollection do
|
|
|
175
178
|
it "should return nil when asked for a #{data} that has not been added" do
|
|
176
179
|
expect(Puppet::Resource::TypeCollection.new(environment).send(data, "foo")).to be_nil
|
|
177
180
|
end
|
|
181
|
+
|
|
182
|
+
if data != "node"
|
|
183
|
+
it "should fail if an application with the same name is added" do
|
|
184
|
+
loader = Puppet::Resource::TypeCollection.new(environment)
|
|
185
|
+
instance = Puppet::Resource::Type.new(data, "foo")
|
|
186
|
+
application = Puppet::Resource::Type.new(:application, "foo")
|
|
187
|
+
loader.add(instance)
|
|
188
|
+
expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "should fail if there is an application with the same name" do
|
|
192
|
+
loader = Puppet::Resource::TypeCollection.new(environment)
|
|
193
|
+
application = Puppet::Resource::Type.new(:application, "foo")
|
|
194
|
+
instance = Puppet::Resource::Type.new(data, "foo")
|
|
195
|
+
loader.add(instance)
|
|
196
|
+
expect { loader.add(application) }.to raise_error(Puppet::ParseError, /redefine/)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
178
199
|
end
|
|
179
200
|
end
|
|
180
201
|
|
|
@@ -766,7 +766,7 @@ describe Puppet::Resource::Type do
|
|
|
766
766
|
source = Puppet::Resource::Type.new(:hostclass, "foo", :code => scode)
|
|
767
767
|
|
|
768
768
|
dest.merge(source)
|
|
769
|
-
expect(dest.code.children.
|
|
769
|
+
expect(dest.code.children.map { |c| c.value }).to eq(%w{dest source})
|
|
770
770
|
end
|
|
771
771
|
end
|
|
772
772
|
end
|
data/spec/unit/resource_spec.rb
CHANGED
|
@@ -331,13 +331,15 @@ describe Puppet::Resource do
|
|
|
331
331
|
end
|
|
332
332
|
|
|
333
333
|
it "should query the data_binding terminus using a namespaced key" do
|
|
334
|
+
Puppet::DataBinding.indirection.expects(:find).with('lookup_options', any_parameters).throws(:no_such_key)
|
|
334
335
|
Puppet::DataBinding.indirection.expects(:find).with(
|
|
335
336
|
'apache::port', all_of(has_key(:environment), has_key(:variables)))
|
|
336
337
|
resource.set_default_parameters(scope)
|
|
337
338
|
end
|
|
338
339
|
|
|
339
340
|
it "should use the value from the data_binding terminus" do
|
|
340
|
-
Puppet::DataBinding.indirection.expects(:find).
|
|
341
|
+
Puppet::DataBinding.indirection.expects(:find).with('lookup_options', any_parameters).throws(:no_such_key)
|
|
342
|
+
Puppet::DataBinding.indirection.expects(:find).with('apache::port', any_parameters).returns('443')
|
|
341
343
|
|
|
342
344
|
resource.set_default_parameters(scope)
|
|
343
345
|
|
|
@@ -345,7 +347,8 @@ describe Puppet::Resource do
|
|
|
345
347
|
end
|
|
346
348
|
|
|
347
349
|
it "should use the default value if the data_binding terminus returns nil" do
|
|
348
|
-
Puppet::DataBinding.indirection.expects(:find).
|
|
350
|
+
Puppet::DataBinding.indirection.expects(:find).with('lookup_options', any_parameters).throws(:no_such_key)
|
|
351
|
+
Puppet::DataBinding.indirection.expects(:find).with('apache::port', any_parameters).returns(nil)
|
|
349
352
|
|
|
350
353
|
resource.set_default_parameters(scope)
|
|
351
354
|
|
|
@@ -353,7 +356,8 @@ describe Puppet::Resource do
|
|
|
353
356
|
end
|
|
354
357
|
|
|
355
358
|
it "should fail with error message about data binding on a hiera failure" do
|
|
356
|
-
Puppet::DataBinding.indirection.expects(:find).
|
|
359
|
+
Puppet::DataBinding.indirection.expects(:find).with('lookup_options', any_parameters).throws(:no_such_key)
|
|
360
|
+
Puppet::DataBinding.indirection.expects(:find).with('apache::port', any_parameters).raises(Puppet::DataBinding::LookupError, 'Forgettabotit')
|
|
357
361
|
expect {
|
|
358
362
|
resource.set_default_parameters(scope)
|
|
359
363
|
}.to raise_error(Puppet::Error, /Error from DataBinding 'hiera' while looking up 'apache::port':.*Forgettabotit/)
|
|
@@ -428,11 +432,11 @@ describe Puppet::Resource do
|
|
|
428
432
|
end
|
|
429
433
|
|
|
430
434
|
it "should fail if invalid parameters are used" do
|
|
431
|
-
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.to raise_error
|
|
435
|
+
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.to raise_error(Puppet::Error, /no parameter named 'nosuchparam'/)
|
|
432
436
|
end
|
|
433
437
|
|
|
434
438
|
it "should fail if the resource type cannot be resolved" do
|
|
435
|
-
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.to raise_error
|
|
439
|
+
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.to raise_error(ArgumentError, /Invalid resource type/)
|
|
436
440
|
end
|
|
437
441
|
end
|
|
438
442
|
|
|
@@ -657,6 +661,20 @@ describe Puppet::Resource do
|
|
|
657
661
|
)
|
|
658
662
|
end
|
|
659
663
|
|
|
664
|
+
it "should escape internal single quotes in a title" do
|
|
665
|
+
singlequote_resource = Puppet::Resource.new("one::two", "/my/file'b'a'r",
|
|
666
|
+
:parameters => {
|
|
667
|
+
:ensure => 'present',
|
|
668
|
+
}
|
|
669
|
+
)
|
|
670
|
+
expect(singlequote_resource.to_manifest).to eq <<-HEREDOC.gsub(/^\s{8}/, '').gsub(/\n$/, '')
|
|
671
|
+
one::two { '/my/file\\'b\\'a\\'r':
|
|
672
|
+
ensure => 'present',
|
|
673
|
+
}
|
|
674
|
+
HEREDOC
|
|
675
|
+
|
|
676
|
+
end
|
|
677
|
+
|
|
660
678
|
it "should align, sort and add trailing commas to attributes with ensure first" do
|
|
661
679
|
expect(@resource.to_manifest).to eq <<-HEREDOC.gsub(/^\s{8}/, '').gsub(/\n$/, '')
|
|
662
680
|
one::two { '/my/file':
|
|
@@ -295,4 +295,35 @@ describe Puppet::Settings::FileSetting do
|
|
|
295
295
|
expect(filesetting.munge(':memory:')).to eq(':memory:')
|
|
296
296
|
end
|
|
297
297
|
end
|
|
298
|
+
|
|
299
|
+
context "when opening", :unless => Puppet.features.microsoft_windows? do
|
|
300
|
+
let(:path) do
|
|
301
|
+
tmpfile('file_setting_spec')
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
let(:setting) do
|
|
305
|
+
settings = mock("settings", :value => path)
|
|
306
|
+
FileSetting.new(:name => :mysetting, :desc => "creates a file", :settings => settings)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it "creates a file with mode 0640" do
|
|
310
|
+
setting.mode = '0640'
|
|
311
|
+
|
|
312
|
+
expect(File).to_not be_exist(path)
|
|
313
|
+
setting.open('w')
|
|
314
|
+
|
|
315
|
+
expect(File).to be_exist(path)
|
|
316
|
+
expect(Puppet::FileSystem.stat(path).mode & 0777).to eq(0640)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
it "preserves the mode of an existing file" do
|
|
320
|
+
setting.mode = '0640'
|
|
321
|
+
|
|
322
|
+
Puppet::FileSystem.touch(path)
|
|
323
|
+
Puppet::FileSystem.chmod(0644, path)
|
|
324
|
+
setting.open('w')
|
|
325
|
+
|
|
326
|
+
expect(Puppet::FileSystem.stat(path).mode & 0777).to eq(0644)
|
|
327
|
+
end
|
|
328
|
+
end
|
|
298
329
|
end
|