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
data/spec/unit/settings_spec.rb
CHANGED
|
@@ -44,7 +44,7 @@ describe Puppet::Settings do
|
|
|
44
44
|
it "should not allow specification of default values associated with a section as an array" do
|
|
45
45
|
expect {
|
|
46
46
|
@settings.define_settings(:section, :myvalue => ["defaultval", "my description"])
|
|
47
|
-
}.to raise_error
|
|
47
|
+
}.to raise_error(ArgumentError, /setting definition for 'myvalue' is not a hash!/)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should not allow duplicate parameter specifications" do
|
|
@@ -287,6 +287,95 @@ describe Puppet::Settings do
|
|
|
287
287
|
expect(@settings.set_by_cli?(:myval)).to be_falsey
|
|
288
288
|
end
|
|
289
289
|
|
|
290
|
+
it "should find no configured settings by default" do
|
|
291
|
+
expect(@settings.set_by_config?(:myval)).to be_falsey
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it "should identify configured settings in memory" do
|
|
295
|
+
@settings.instance_variable_get(:@value_sets)[:memory].expects(:lookup).with(:myval).returns('foo')
|
|
296
|
+
expect(@settings.set_by_config?(:myval)).to be_truthy
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
it "should identify configured settings from CLI" do
|
|
300
|
+
@settings.instance_variable_get(:@value_sets)[:cli].expects(:lookup).with(:myval).returns('foo')
|
|
301
|
+
expect(@settings.set_by_config?(:myval)).to be_truthy
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it "should not identify configured settings from environment by default" do
|
|
305
|
+
Puppet.lookup(:environments).expects(:get_conf).with(Puppet[:environment].to_sym).never
|
|
306
|
+
expect(@settings.set_by_config?(:manifest)).to be_falsey
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it "should identify configured settings from environment by when an environment is specified" do
|
|
310
|
+
foo = mock('environment', :manifest => 'foo')
|
|
311
|
+
Puppet.lookup(:environments).expects(:get_conf).with(Puppet[:environment].to_sym).returns(foo)
|
|
312
|
+
expect(@settings.set_by_config?(:manifest, Puppet[:environment])).to be_truthy
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
it "should identify configured settings from the preferred run mode" do
|
|
316
|
+
user_config_text = "[#{@settings.preferred_run_mode}]\nmyval = foo"
|
|
317
|
+
seq = sequence "config_file_sequence"
|
|
318
|
+
|
|
319
|
+
Puppet.features.stubs(:root?).returns(false)
|
|
320
|
+
Puppet::FileSystem.expects(:exist?).
|
|
321
|
+
with(user_config_file_default_location).
|
|
322
|
+
returns(true).in_sequence(seq)
|
|
323
|
+
@settings.expects(:read_file).
|
|
324
|
+
with(user_config_file_default_location).
|
|
325
|
+
returns(user_config_text).in_sequence(seq)
|
|
326
|
+
|
|
327
|
+
@settings.send(:parse_config_files)
|
|
328
|
+
expect(@settings.set_by_config?(:myval)).to be_truthy
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
it "should identify configured settings from the specified run mode" do
|
|
332
|
+
user_config_text = "[master]\nmyval = foo"
|
|
333
|
+
seq = sequence "config_file_sequence"
|
|
334
|
+
|
|
335
|
+
Puppet.features.stubs(:root?).returns(false)
|
|
336
|
+
Puppet::FileSystem.expects(:exist?).
|
|
337
|
+
with(user_config_file_default_location).
|
|
338
|
+
returns(true).in_sequence(seq)
|
|
339
|
+
@settings.expects(:read_file).
|
|
340
|
+
with(user_config_file_default_location).
|
|
341
|
+
returns(user_config_text).in_sequence(seq)
|
|
342
|
+
|
|
343
|
+
@settings.send(:parse_config_files)
|
|
344
|
+
expect(@settings.set_by_config?(:myval, nil, :master)).to be_truthy
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it "should not identify configured settings from an unspecified run mode" do
|
|
348
|
+
user_config_text = "[zaz]\nmyval = foo"
|
|
349
|
+
seq = sequence "config_file_sequence"
|
|
350
|
+
|
|
351
|
+
Puppet.features.stubs(:root?).returns(false)
|
|
352
|
+
Puppet::FileSystem.expects(:exist?).
|
|
353
|
+
with(user_config_file_default_location).
|
|
354
|
+
returns(true).in_sequence(seq)
|
|
355
|
+
@settings.expects(:read_file).
|
|
356
|
+
with(user_config_file_default_location).
|
|
357
|
+
returns(user_config_text).in_sequence(seq)
|
|
358
|
+
|
|
359
|
+
@settings.send(:parse_config_files)
|
|
360
|
+
expect(@settings.set_by_config?(:myval)).to be_falsey
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
it "should identify configured settings from the main section" do
|
|
364
|
+
user_config_text = "[main]\nmyval = foo"
|
|
365
|
+
seq = sequence "config_file_sequence"
|
|
366
|
+
|
|
367
|
+
Puppet.features.stubs(:root?).returns(false)
|
|
368
|
+
Puppet::FileSystem.expects(:exist?).
|
|
369
|
+
with(user_config_file_default_location).
|
|
370
|
+
returns(true).in_sequence(seq)
|
|
371
|
+
@settings.expects(:read_file).
|
|
372
|
+
with(user_config_file_default_location).
|
|
373
|
+
returns(user_config_text).in_sequence(seq)
|
|
374
|
+
|
|
375
|
+
@settings.send(:parse_config_files)
|
|
376
|
+
expect(@settings.set_by_config?(:myval)).to be_truthy
|
|
377
|
+
end
|
|
378
|
+
|
|
290
379
|
it "should clear the cache when setting getopt-specific values" do
|
|
291
380
|
@settings.define_settings :mysection,
|
|
292
381
|
:one => { :default => "whah", :desc => "yay" },
|
|
@@ -1734,7 +1823,7 @@ describe Puppet::Settings do
|
|
|
1734
1823
|
end
|
|
1735
1824
|
|
|
1736
1825
|
describe "default_certname" do
|
|
1737
|
-
describe "using hostname and
|
|
1826
|
+
describe "using hostname and domain" do
|
|
1738
1827
|
before :each do
|
|
1739
1828
|
Puppet::Settings.stubs(:hostname_fact).returns("testhostname")
|
|
1740
1829
|
Puppet::Settings.stubs(:domain_fact).returns("domain.test.")
|
|
@@ -332,9 +332,10 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
|
332
332
|
@applier.expects(:puts).with "h1"
|
|
333
333
|
|
|
334
334
|
@ca.expects(:print).with("host2").returns nil
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
|
|
336
|
+
expect {
|
|
337
|
+
@applier.apply(@ca)
|
|
338
|
+
}.to raise_error(ArgumentError, /Could not find certificate for host2/)
|
|
338
339
|
end
|
|
339
340
|
end
|
|
340
341
|
end
|
|
@@ -777,7 +777,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
|
777
777
|
it "should raise an error if the certificate or CSR cannot be found" do
|
|
778
778
|
Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
|
|
779
779
|
Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myhost").returns nil
|
|
780
|
-
expect { @ca.fingerprint("myhost") }.to raise_error
|
|
780
|
+
expect { @ca.fingerprint("myhost") }.to raise_error(ArgumentError, /Could not find a certificate/)
|
|
781
781
|
end
|
|
782
782
|
|
|
783
783
|
it "should try to find a CSR if no certificate can be found" do
|
|
@@ -863,8 +863,10 @@ describe Puppet::SSL::CertificateAuthority do
|
|
|
863
863
|
@cert.expects(:content).returns "mycert"
|
|
864
864
|
|
|
865
865
|
@store.expects(:verify).with("mycert").returns false
|
|
866
|
+
@store.expects(:error)
|
|
867
|
+
@store.expects(:error_string)
|
|
866
868
|
|
|
867
|
-
expect { @ca.verify("me") }.to raise_error
|
|
869
|
+
expect { @ca.verify("me") }.to raise_error(Puppet::SSL::CertificateAuthority::CertificateVerificationError)
|
|
868
870
|
end
|
|
869
871
|
|
|
870
872
|
describe "certificate_is_alive?" do
|
|
@@ -963,7 +965,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
|
963
965
|
@ca.inventory.expects(:serials).with("host").returns []
|
|
964
966
|
|
|
965
967
|
@ca.crl.expects(:revoke).never
|
|
966
|
-
expect { @ca.revoke('host') }.to raise_error
|
|
968
|
+
expect { @ca.revoke('host') }.to raise_error(ArgumentError, /Could not find a serial number for host/)
|
|
967
969
|
end
|
|
968
970
|
|
|
969
971
|
context "revocation by serial number (#16798)" do
|
data/spec/unit/ssl/host_spec.rb
CHANGED
|
@@ -422,7 +422,7 @@ describe Puppet::SSL::Host do
|
|
|
422
422
|
@key.stubs(:generate)
|
|
423
423
|
Puppet::SSL::Key.indirection.expects(:save).raises "eh"
|
|
424
424
|
|
|
425
|
-
expect { @host.generate_key }.to raise_error
|
|
425
|
+
expect { @host.generate_key }.to raise_error(RuntimeError)
|
|
426
426
|
expect(@host.key).to be_nil
|
|
427
427
|
end
|
|
428
428
|
|
|
@@ -496,7 +496,7 @@ describe Puppet::SSL::Host do
|
|
|
496
496
|
Puppet::SSL::CertificateRequest.indirection.expects(:prepare).returns(terminus)
|
|
497
497
|
terminus.expects(:save).with { |req| req.instance == @request && req.key == "myname" }.raises "eh"
|
|
498
498
|
|
|
499
|
-
expect { @host.generate_certificate_request }.to raise_error
|
|
499
|
+
expect { @host.generate_certificate_request }.to raise_error(RuntimeError)
|
|
500
500
|
|
|
501
501
|
expect(@host.instance_eval { @certificate_request }).to be_nil
|
|
502
502
|
end
|
data/spec/unit/ssl/oids_spec.rb
CHANGED
|
@@ -25,6 +25,14 @@ describe Puppet::SSL::Oids do
|
|
|
25
25
|
'pp_department' => "1.3.6.1.4.1.34380.1.1.15",
|
|
26
26
|
'pp_cluster' => "1.3.6.1.4.1.34380.1.1.16",
|
|
27
27
|
'pp_provisioner' => "1.3.6.1.4.1.34380.1.1.17",
|
|
28
|
+
'pp_region' => "1.3.6.1.4.1.34380.1.1.18",
|
|
29
|
+
'pp_datacenter' => "1.3.6.1.4.1.34380.1.1.19",
|
|
30
|
+
'pp_zone' => "1.3.6.1.4.1.34380.1.1.20",
|
|
31
|
+
'pp_network' => "1.3.6.1.4.1.34380.1.1.21",
|
|
32
|
+
'pp_securitypolicy' => "1.3.6.1.4.1.34380.1.1.22",
|
|
33
|
+
'pp_cloudplatform' => "1.3.6.1.4.1.34380.1.1.23",
|
|
34
|
+
'pp_apptier' => "1.3.6.1.4.1.34380.1.1.24",
|
|
35
|
+
'pp_hostname' => "1.3.6.1.4.1.34380.1.1.25",
|
|
28
36
|
'ppPrivCertExt' => '1.3.6.1.4.1.34380.1.2',
|
|
29
37
|
}.each_pair do |sn, oid|
|
|
30
38
|
it "defines #{sn} as #{oid}" do
|
|
@@ -52,6 +52,48 @@ describe Puppet::Transaction::AdditionalResourceGenerator do
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
Puppet::Type.newtype(:autorequire) do
|
|
56
|
+
newparam(:name) do
|
|
57
|
+
isnamevar
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
autorequire(:notify) do
|
|
61
|
+
self[:name]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Puppet::Type.newtype(:gen_auto) do
|
|
66
|
+
newparam(:name) do
|
|
67
|
+
isnamevar
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
newparam(:eval_after) do
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def generate()
|
|
74
|
+
[ Puppet::Type.type(:autorequire).new(:name => self[:eval_after]) ]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
Puppet::Type.newtype(:empty) do
|
|
79
|
+
newparam(:name) do
|
|
80
|
+
isnamevar
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
Puppet::Type.newtype(:gen_empty) do
|
|
85
|
+
newparam(:name) do
|
|
86
|
+
isnamevar
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
newparam(:eval_after) do
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def generate()
|
|
93
|
+
[ Puppet::Type.type(:empty).new(:name => self[:eval_after], :require => "Notify[#{self[:eval_after]}]") ]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
55
97
|
context "when applying eval_generate" do
|
|
56
98
|
it "should add the generated resources to the catalog" do
|
|
57
99
|
catalog = compile_to_ral(<<-MANIFEST)
|
|
@@ -368,13 +410,44 @@ describe Puppet::Transaction::AdditionalResourceGenerator do
|
|
|
368
410
|
"Notify[after]"))
|
|
369
411
|
end
|
|
370
412
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
413
|
+
it "runs autorequire on the generated resource" do
|
|
414
|
+
graph = relationships_after_generating(<<-MANIFEST, 'Gen_auto[thing]')
|
|
415
|
+
gen_auto { thing:
|
|
416
|
+
eval_after => hello,
|
|
417
|
+
}
|
|
374
418
|
|
|
375
|
-
|
|
419
|
+
notify { hello: }
|
|
420
|
+
notify { goodbye: }
|
|
421
|
+
MANIFEST
|
|
376
422
|
|
|
377
|
-
|
|
423
|
+
expect(order_resources_traversed_in(graph)).to(
|
|
424
|
+
include_in_order("Gen_auto[thing]",
|
|
425
|
+
"Notify[hello]",
|
|
426
|
+
"Autorequire[hello]",
|
|
427
|
+
"Notify[goodbye]"))
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
it "evaluates metaparameters on the generated resource" do
|
|
431
|
+
graph = relationships_after_generating(<<-MANIFEST, 'Gen_empty[thing]')
|
|
432
|
+
gen_empty { thing:
|
|
433
|
+
eval_after => hello,
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
notify { hello: }
|
|
437
|
+
notify { goodbye: }
|
|
438
|
+
MANIFEST
|
|
439
|
+
|
|
440
|
+
expect(order_resources_traversed_in(graph)).to(
|
|
441
|
+
include_in_order("Gen_empty[thing]",
|
|
442
|
+
"Notify[hello]",
|
|
443
|
+
"Empty[hello]",
|
|
444
|
+
"Notify[goodbye]"))
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def relationships_after_generating(manifest, resource_to_generate)
|
|
448
|
+
catalog = compile_to_ral(manifest)
|
|
449
|
+
generate_resources_in(catalog, nil, resource_to_generate)
|
|
450
|
+
relationship_graph_for(catalog)
|
|
378
451
|
end
|
|
379
452
|
|
|
380
453
|
def generate_resources_in(catalog, relationship_graph, resource_to_generate)
|
|
@@ -404,6 +404,16 @@ describe Puppet::Transaction::Report do
|
|
|
404
404
|
expect(error_report.render).to validate_against('api/schemas/report.json')
|
|
405
405
|
end
|
|
406
406
|
|
|
407
|
+
it "can make a round trip through yaml" do
|
|
408
|
+
report = generate_report
|
|
409
|
+
|
|
410
|
+
yaml_output = report.render(:yaml)
|
|
411
|
+
tripped = Puppet::Transaction::Report.convert_from(:yaml, yaml_output)
|
|
412
|
+
|
|
413
|
+
expect(yaml_output).to match(/^--- /)
|
|
414
|
+
expect_equivalent_reports(tripped, report)
|
|
415
|
+
end
|
|
416
|
+
|
|
407
417
|
def expect_equivalent_reports(tripped, report)
|
|
408
418
|
expect(tripped.host).to eq(report.host)
|
|
409
419
|
expect(tripped.time.to_i).to eq(report.time.to_i)
|
|
@@ -451,13 +461,26 @@ describe Puppet::Transaction::Report do
|
|
|
451
461
|
expect(status.skipped).to eq(expected.skipped)
|
|
452
462
|
expect(status.change_count).to eq(expected.change_count)
|
|
453
463
|
expect(status.out_of_sync_count).to eq(expected.out_of_sync_count)
|
|
454
|
-
expect(status.events).to eq(expected.events)
|
|
464
|
+
expect(status.events.map(&:to_data_hash)).to eq(expected.events.map(&:to_data_hash))
|
|
455
465
|
end
|
|
456
466
|
end
|
|
457
467
|
|
|
458
468
|
def generate_report
|
|
469
|
+
event_hash = {
|
|
470
|
+
:audited => false,
|
|
471
|
+
:property => 'message',
|
|
472
|
+
:previous_value => 'absent',
|
|
473
|
+
:desired_value => 'a resource',
|
|
474
|
+
:historical_value => nil,
|
|
475
|
+
:message => "defined 'message' as 'a resource'",
|
|
476
|
+
:name => :message_changed,
|
|
477
|
+
:status => 'success',
|
|
478
|
+
}
|
|
479
|
+
event = Puppet::Transaction::Event.new(event_hash)
|
|
480
|
+
|
|
459
481
|
status = Puppet::Resource::Status.new(Puppet::Type.type(:notify).new(:title => "a resource"))
|
|
460
482
|
status.changed = true
|
|
483
|
+
status.add_event(event)
|
|
461
484
|
|
|
462
485
|
report = Puppet::Transaction::Report.new('apply', 1357986, 'test_environment', "df34516e-4050-402d-a166-05b03b940749")
|
|
463
486
|
report << Puppet::Util::Log.new(:level => :warning, :message => "log message")
|
|
@@ -721,6 +721,13 @@ describe Puppet::Transaction, " when determining tags" do
|
|
|
721
721
|
expect(@transaction).to be_tagged("one::two")
|
|
722
722
|
end
|
|
723
723
|
|
|
724
|
+
it "should tag one::two only as 'one::two' and not 'one', 'two', and 'one::two'" do
|
|
725
|
+
@transaction.tags = "one::two"
|
|
726
|
+
expect(@transaction).to be_tagged("one::two")
|
|
727
|
+
expect(@transaction).to_not be_tagged("one")
|
|
728
|
+
expect(@transaction).to_not be_tagged("two")
|
|
729
|
+
end
|
|
730
|
+
|
|
724
731
|
it "should accept a comma-delimited string" do
|
|
725
732
|
@transaction.tags = "one, two"
|
|
726
733
|
expect(@transaction).to be_tagged("one")
|
data/spec/unit/type/exec_spec.rb
CHANGED
|
@@ -396,16 +396,24 @@ describe Puppet::Type.type(:exec) do
|
|
|
396
396
|
end
|
|
397
397
|
end
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
describe 'when timeout is exceeded' do
|
|
400
|
+
subject do
|
|
401
|
+
ruby_path = Puppet::Util::Execution.ruby_path()
|
|
402
|
+
Puppet::Type.type(:exec).new(:name => "#{ruby_path} -e 'sleep 1'", :timeout => '0.1')
|
|
403
|
+
end
|
|
401
404
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
context 'on POSIX', :unless => Puppet.features.microsoft_windows? do
|
|
406
|
+
it 'sends a SIGTERM and raises a Puppet::Error' do
|
|
407
|
+
Process.expects(:kill).at_least_once
|
|
408
|
+
expect { subject.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
|
|
409
|
+
end
|
|
410
|
+
end
|
|
407
411
|
|
|
408
|
-
|
|
412
|
+
context 'on Windows', :if => Puppet.features.microsoft_windows? do
|
|
413
|
+
it 'raises a Puppet::Error' do
|
|
414
|
+
expect { subject.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
|
|
415
|
+
end
|
|
416
|
+
end
|
|
409
417
|
end
|
|
410
418
|
|
|
411
419
|
it "should convert timeout to a float" do
|
data/spec/unit/type/host_spec.rb
CHANGED
|
@@ -68,15 +68,15 @@ describe host do
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "should not accept malformed IPv4 addresses like 192.168.0.300" do
|
|
71
|
-
expect { @class.new(:name => "foo", :ip => '192.168.0.300') }.to raise_error
|
|
71
|
+
expect { @class.new(:name => "foo", :ip => '192.168.0.300') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "should reject over-long IPv4 addresses" do
|
|
75
|
-
expect { @class.new(:name => "foo", :ip => '10.10.10.10.10') }.to raise_error
|
|
75
|
+
expect { @class.new(:name => "foo", :ip => '10.10.10.10.10') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should not accept malformed IP addresses like 2001:0dg8:85a3:08d3:1319:8a2e:0370:7344" do
|
|
79
|
-
expect { @class.new(:name => "foo", :ip => '2001:0dg8:85a3:08d3:1319:8a2e:0370:7344') }.to raise_error
|
|
79
|
+
expect { @class.new(:name => "foo", :ip => '2001:0dg8:85a3:08d3:1319:8a2e:0370:7344') }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# Assorted, annotated IPv6 passes.
|
|
@@ -598,7 +598,7 @@ describe host do
|
|
|
598
598
|
"::2222:3333:4444:5555:6666:7777:8888:",
|
|
599
599
|
].each do |ip|
|
|
600
600
|
it "should reject #{ip.inspect} as an IPv6 address" do
|
|
601
|
-
expect { @class.new(:name => "foo", :ip => ip) }.to raise_error
|
|
601
|
+
expect { @class.new(:name => "foo", :ip => ip) }.to raise_error(Puppet::ResourceError, /Parameter ip failed/)
|
|
602
602
|
end
|
|
603
603
|
end
|
|
604
604
|
|
data/spec/unit/type/tidy_spec.rb
CHANGED
|
@@ -66,7 +66,7 @@ describe tidy do
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "should not allow arbitrary values" do
|
|
69
|
-
expect { @tidy[:recurse] = "whatever" }.to raise_error
|
|
69
|
+
expect { @tidy[:recurse] = "whatever" }.to raise_error(Puppet::ResourceError, /Parameter recurse failed/)
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -76,13 +76,13 @@ describe tidy do
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should object if matches is given with recurse is not specified" do
|
|
79
|
-
expect { @tidy[:matches] = '*.doh' }.to raise_error
|
|
79
|
+
expect { @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
|
|
80
80
|
end
|
|
81
81
|
it "should object if matches is given and recurse is 0" do
|
|
82
|
-
expect { @tidy[:recurse] = 0; @tidy[:matches] = '*.doh' }.to raise_error
|
|
82
|
+
expect { @tidy[:recurse] = 0; @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
|
|
83
83
|
end
|
|
84
84
|
it "should object if matches is given and recurse is false" do
|
|
85
|
-
expect { @tidy[:recurse] = false; @tidy[:matches] = '*.doh' }.to raise_error
|
|
85
|
+
expect { @tidy[:recurse] = false; @tidy[:matches] = '*.doh' }.to raise_error(Puppet::ResourceError, /Parameter matches failed/)
|
|
86
86
|
end
|
|
87
87
|
it "should not object if matches is given and recurse is > 0" do
|
|
88
88
|
expect { @tidy[:recurse] = 1; @tidy[:matches] = '*.doh' }.not_to raise_error
|
data/spec/unit/type/user_spec.rb
CHANGED
|
@@ -344,13 +344,20 @@ describe Puppet::Type.type(:user) do
|
|
|
344
344
|
end
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
-
describe "when managing comment
|
|
348
|
-
|
|
349
|
-
value = 'abcd™'
|
|
350
|
-
expect(value.encoding).to eq(Encoding::UTF_8)
|
|
351
|
-
user = described_class.new(:name => 'foo', :comment => value)
|
|
352
|
-
|
|
353
|
-
|
|
347
|
+
describe "when managing comment" do
|
|
348
|
+
before :each do
|
|
349
|
+
@value = 'abcd™'
|
|
350
|
+
expect(@value.encoding).to eq(Encoding::UTF_8)
|
|
351
|
+
@user = described_class.new(:name => 'foo', :comment => @value)
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
it "should be converted to ASCII_8BIT for ruby 1.9 / 2.0", :if => RUBY_VERSION < "2.1.0" && String.method_defined?(:encode) do
|
|
355
|
+
expect(@user[:comment].encoding).to eq(Encoding::ASCII_8BIT)
|
|
356
|
+
expect(@user[:comment]).to eq(@value.force_encoding(Encoding::ASCII_8BIT))
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
it "must not be converted for ruby >= 2.1", :if => RUBY_VERSION >= "2.1.0" do
|
|
360
|
+
expect(@user[:comment].encoding).to eq(Encoding::UTF_8)
|
|
354
361
|
end
|
|
355
362
|
end
|
|
356
363
|
|
data/spec/unit/type/vlan_spec.rb
CHANGED
|
@@ -38,7 +38,7 @@ describe Puppet::Type.type(:vlan) do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should fail if vlan name is not a number" do
|
|
41
|
-
expect { Puppet::Type.type(:vlan).new(:name => "notanumber", :ensure => :present) }.to raise_error
|
|
41
|
+
expect { Puppet::Type.type(:vlan).new(:name => "notanumber", :ensure => :present) }.to raise_error(Puppet::ResourceError, /Parameter name failed on Vlan/)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
data/spec/unit/type_spec.rb
CHANGED
|
@@ -522,7 +522,7 @@ describe Puppet::Type, :unless => Puppet.features.microsoft_windows? do
|
|
|
522
522
|
end
|
|
523
523
|
|
|
524
524
|
it "should fail if any invalid attributes have been provided" do
|
|
525
|
-
expect { Puppet::Type.type(:mount).new(:title => "/foo", :nosuchattr => "whatever") }.to raise_error(Puppet::Error, /
|
|
525
|
+
expect { Puppet::Type.type(:mount).new(:title => "/foo", :nosuchattr => "whatever") }.to raise_error(Puppet::Error, /no parameter named 'nosuchattr'/)
|
|
526
526
|
end
|
|
527
527
|
|
|
528
528
|
context "when an attribute fails validation" do
|
|
@@ -9,7 +9,7 @@ describe Puppet::Util::Ldap::Generator do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "should require a parameter name at initialization" do
|
|
12
|
-
expect { Puppet::Util::Ldap::Generator.new }.to raise_error
|
|
12
|
+
expect { Puppet::Util::Ldap::Generator.new }.to raise_error(ArgumentError, /wrong number of arguments/)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should always return its name as a string" do
|
|
@@ -133,7 +133,7 @@ describe Puppet::Util::NetworkDevice::Cisco::Device do
|
|
|
133
133
|
describe "when entering enable password" do
|
|
134
134
|
it "should raise an error if no enable password has been set" do
|
|
135
135
|
@cisco.enable_password = nil
|
|
136
|
-
expect{ @cisco.enable }.to raise_error
|
|
136
|
+
expect{ @cisco.enable }.to raise_error(RuntimeError, /Can't issue "enable" to enter privileged/)
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
it "should send the enable command and expect an enable prompt" do
|
|
@@ -65,7 +65,7 @@ describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh
|
|
|
65
65
|
|
|
66
66
|
it "should raise an error if shell channel creation fails" do
|
|
67
67
|
@channel.expects(:send_channel_request).with("shell").yields(@channel, false)
|
|
68
|
-
expect { @transport.connect }.to raise_error
|
|
68
|
+
expect { @transport.connect }.to raise_error(RuntimeError, /failed to open ssh shell channel/)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "should register an on_data and on_extended_data callback" do
|
|
@@ -35,7 +35,7 @@ describe Puppet::Util::NetworkDevice do
|
|
|
35
35
|
|
|
36
36
|
it "should raise an error if the remote device instance can't be created" do
|
|
37
37
|
Puppet::Util::NetworkDevice.stubs(:require).raises("error")
|
|
38
|
-
expect { Puppet::Util::NetworkDevice.init(@device) }.to raise_error
|
|
38
|
+
expect { Puppet::Util::NetworkDevice.init(@device) }.to raise_error(RuntimeError, /Can't load test for name/)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should let caller to access the singleton device" do
|
|
@@ -188,7 +188,11 @@ describe Puppet::Util::Storage do
|
|
|
188
188
|
Dir.mkdir(Puppet[:statefile])
|
|
189
189
|
Puppet::Util::Storage.cache(:yayness)
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
if Puppet.features.microsoft_windows?
|
|
192
|
+
expect { Puppet::Util::Storage.store }.to raise_error(Puppet::Util::Windows::Error, /Access is denied/)
|
|
193
|
+
else
|
|
194
|
+
expect { Puppet::Util::Storage.store }.to raise_error(Errno::EISDIR, /Is a directory/)
|
|
195
|
+
end
|
|
192
196
|
|
|
193
197
|
Dir.rmdir(Puppet[:statefile])
|
|
194
198
|
end
|
|
@@ -183,6 +183,19 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
|
|
|
183
183
|
user.password = 'pwd'
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
+
it "should be able manage a user without a password" do
|
|
187
|
+
adsi_user.expects(:SetPassword).with('pwd').never
|
|
188
|
+
adsi_user.expects(:SetInfo).at_least_once
|
|
189
|
+
|
|
190
|
+
flagname = "UserFlags"
|
|
191
|
+
fADS_UF_DONT_EXPIRE_PASSWD = 0x10000
|
|
192
|
+
|
|
193
|
+
adsi_user.expects(:Get).with(flagname).returns(0)
|
|
194
|
+
adsi_user.expects(:Put).with(flagname, fADS_UF_DONT_EXPIRE_PASSWD)
|
|
195
|
+
|
|
196
|
+
user.password = nil
|
|
197
|
+
end
|
|
198
|
+
|
|
186
199
|
it "should generate the correct URI" do
|
|
187
200
|
Puppet::Util::Windows::SID.stubs(:octet_string_to_sid_object).returns(sid)
|
|
188
201
|
expect(user.uri).to eq("WinNT://testcomputername/#{username},user")
|
data/spec/unit/util_spec.rb
CHANGED
|
@@ -229,11 +229,30 @@ describe Puppet::Util do
|
|
|
229
229
|
(0..256).each {|n| IO.stubs(:new) }
|
|
230
230
|
end
|
|
231
231
|
|
|
232
|
-
it "should close all open file descriptors except stdin/stdout/stderr" do
|
|
232
|
+
it "should close all open file descriptors except stdin/stdout/stderr when /proc/self/fd exists" do
|
|
233
|
+
# This is ugly, but I can't really think of a better way to do it without
|
|
234
|
+
# letting it actually close fds, which seems risky
|
|
235
|
+
fds = [".", "..","0","1","2","3","5","100","1000"]
|
|
236
|
+
fds.each do |fd|
|
|
237
|
+
if fd == '.' || fd == '..'
|
|
238
|
+
next
|
|
239
|
+
elsif ['0', '1', '2'].include? fd
|
|
240
|
+
IO.expects(:new).with(fd.to_i).never
|
|
241
|
+
else
|
|
242
|
+
IO.expects(:new).with(fd.to_i).returns mock('io', :close)
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
Dir.stubs(:foreach).with('/proc/self/fd').multiple_yields(*fds)
|
|
247
|
+
Puppet::Util.safe_posix_fork
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it "should close all open file descriptors except stdin/stdout/stderr when /proc/self/fd doesn't exists" do
|
|
233
251
|
# This is ugly, but I can't really think of a better way to do it without
|
|
234
252
|
# letting it actually close fds, which seems risky
|
|
235
253
|
(0..2).each {|n| IO.expects(:new).with(n).never}
|
|
236
|
-
(3..256).each {|n| IO.expects(:new).with(n).returns mock('io', :close)
|
|
254
|
+
(3..256).each { |n| IO.expects(:new).with(n).returns mock('io', :close) }
|
|
255
|
+
Dir.stubs(:foreach).with('/proc/self/fd') { raise Errno::ENOENT }
|
|
237
256
|
|
|
238
257
|
Puppet::Util.safe_posix_fork
|
|
239
258
|
end
|