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
|
@@ -3,80 +3,80 @@ require 'spec_helper'
|
|
|
3
3
|
|
|
4
4
|
require 'puppet/network/authconfig'
|
|
5
5
|
|
|
6
|
-
describe Puppet::Network::
|
|
6
|
+
describe Puppet::Network::DefaultAuthProvider do
|
|
7
7
|
before :each do
|
|
8
8
|
Puppet::FileSystem.stubs(:stat).returns stub('stat', :ctime => :now)
|
|
9
9
|
Time.stubs(:now).returns Time.now
|
|
10
10
|
|
|
11
|
-
Puppet::Network::
|
|
12
|
-
# FIXME @
|
|
11
|
+
Puppet::Network::DefaultAuthProvider.any_instance.stubs(:exists?).returns(true)
|
|
12
|
+
# FIXME @authprovider = Puppet::Network::DefaultAuthProvider.new("dummy")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe "when initializing" do
|
|
16
16
|
it "inserts default ACLs after setting initial rights" do
|
|
17
|
-
Puppet::Network::
|
|
18
|
-
Puppet::Network::
|
|
17
|
+
Puppet::Network::DefaultAuthProvider.any_instance.expects(:insert_default_acl)
|
|
18
|
+
Puppet::Network::DefaultAuthProvider.new
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
describe "when defining an acl with mk_acl" do
|
|
23
23
|
before :each do
|
|
24
|
-
Puppet::Network::
|
|
25
|
-
@
|
|
24
|
+
Puppet::Network::DefaultAuthProvider.any_instance.stubs(:insert_default_acl)
|
|
25
|
+
@authprovider = Puppet::Network::DefaultAuthProvider.new
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "should create a new right for each default acl" do
|
|
29
|
-
@
|
|
30
|
-
expect(@
|
|
29
|
+
@authprovider.mk_acl(:acl => '/')
|
|
30
|
+
expect(@authprovider.rights['/']).to be
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "allows everyone for each default right" do
|
|
34
|
-
@
|
|
35
|
-
expect(@
|
|
34
|
+
@authprovider.mk_acl(:acl => '/')
|
|
35
|
+
expect(@authprovider.rights['/']).to be_globalallow
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "accepts an argument to restrict the method" do
|
|
39
|
-
@
|
|
40
|
-
expect(@
|
|
39
|
+
@authprovider.mk_acl(:acl => '/', :method => :find)
|
|
40
|
+
expect(@authprovider.rights['/'].methods).to eq([:find])
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "creates rights with authentication set to true by default" do
|
|
44
|
-
@
|
|
45
|
-
expect(@
|
|
44
|
+
@authprovider.mk_acl(:acl => '/')
|
|
45
|
+
expect(@authprovider.rights['/'].authentication).to be_truthy
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "accepts an argument to set the authentication requirement" do
|
|
49
|
-
@
|
|
50
|
-
expect(@
|
|
49
|
+
@authprovider.mk_acl(:acl => '/', :authenticated => :any)
|
|
50
|
+
expect(@authprovider.rights['/'].authentication).to be_falsey
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
describe "when adding default ACLs" do
|
|
55
55
|
before :each do
|
|
56
|
-
Puppet::Network::
|
|
57
|
-
@
|
|
58
|
-
Puppet::Network::
|
|
56
|
+
Puppet::Network::DefaultAuthProvider.any_instance.stubs(:insert_default_acl)
|
|
57
|
+
@authprovider = Puppet::Network::DefaultAuthProvider.new
|
|
58
|
+
Puppet::Network::DefaultAuthProvider.any_instance.unstub(:insert_default_acl)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
Puppet::Network::
|
|
61
|
+
Puppet::Network::DefaultAuthProvider::default_acl.each do |acl|
|
|
62
62
|
it "should create a default right for #{acl[:acl]}" do
|
|
63
|
-
@
|
|
64
|
-
@
|
|
65
|
-
@
|
|
63
|
+
@authprovider.stubs(:mk_acl)
|
|
64
|
+
@authprovider.expects(:mk_acl).with(acl)
|
|
65
|
+
@authprovider.insert_default_acl
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "should log at info loglevel" do
|
|
70
70
|
Puppet.expects(:info).at_least_once
|
|
71
|
-
@
|
|
71
|
+
@authprovider.insert_default_acl
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "creates an empty catch-all rule for '/' for any authentication request state" do
|
|
75
|
-
@
|
|
75
|
+
@authprovider.stubs(:mk_acl)
|
|
76
76
|
|
|
77
|
-
@
|
|
78
|
-
expect(@
|
|
79
|
-
expect(@
|
|
77
|
+
@authprovider.insert_default_acl
|
|
78
|
+
expect(@authprovider.rights['/']).to be_empty
|
|
79
|
+
expect(@authprovider.rights['/'].authentication).to be_falsey
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it '(CVE-2013-2275) allows report submission only for the node matching the certname by default' do
|
|
@@ -86,9 +86,9 @@ describe Puppet::Network::AuthConfig do
|
|
|
86
86
|
:allow => '$1',
|
|
87
87
|
:authenticated => true
|
|
88
88
|
}
|
|
89
|
-
@
|
|
90
|
-
@
|
|
91
|
-
@
|
|
89
|
+
@authprovider.stubs(:mk_acl)
|
|
90
|
+
@authprovider.expects(:mk_acl).with(acl)
|
|
91
|
+
@authprovider.insert_default_acl
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
@@ -107,3 +107,33 @@ describe Puppet::Network::AuthConfig do
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
|
+
|
|
111
|
+
describe Puppet::Network::AuthConfig do
|
|
112
|
+
after :each do
|
|
113
|
+
Puppet::Network::AuthConfig.authprovider_class = nil
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
class TestAuthProvider
|
|
117
|
+
def initialize(rights=nil); end
|
|
118
|
+
def check_authorization(method, path, params); end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "instantiates authprovider_class with rights" do
|
|
122
|
+
Puppet::Network::AuthConfig.authprovider_class = TestAuthProvider
|
|
123
|
+
rights = Puppet::Network::Rights.new
|
|
124
|
+
TestAuthProvider.expects(:new).with(rights)
|
|
125
|
+
described_class.new(rights)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "delegates authorization check to authprovider_class" do
|
|
129
|
+
Puppet::Network::AuthConfig.authprovider_class = TestAuthProvider
|
|
130
|
+
TestAuthProvider.any_instance.expects(:check_authorization).with(:save, '/path/to/resource', {})
|
|
131
|
+
described_class.new.check_authorization(:save, '/path/to/resource', {})
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "uses DefaultAuthProvider by default" do
|
|
135
|
+
Puppet::Network::AuthConfig.authprovider_class = nil
|
|
136
|
+
Puppet::Network::DefaultAuthProvider.any_instance.expects(:check_authorization).with(:save, '/path/to/resource', {})
|
|
137
|
+
described_class.new.check_authorization(:save, '/path/to/resource', {})
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env ruby
|
|
2
2
|
require 'spec_helper'
|
|
3
|
+
require 'puppet/network/http'
|
|
4
|
+
require 'puppet/network/http/api/indirected_routes'
|
|
3
5
|
require 'puppet/network/authorization'
|
|
4
6
|
|
|
5
7
|
describe Puppet::Network::Authorization do
|
|
@@ -9,7 +11,7 @@ describe Puppet::Network::Authorization do
|
|
|
9
11
|
|
|
10
12
|
subject { AuthTest.new }
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
context "when creating an authconfig object" do
|
|
13
15
|
before :each do
|
|
14
16
|
# Other tests may have created an authconfig, so we have to undo that.
|
|
15
17
|
@orig_auth_config = Puppet::Network::AuthConfigLoader.instance_variable_get(:@auth_config)
|
|
@@ -26,9 +28,35 @@ describe Puppet::Network::Authorization do
|
|
|
26
28
|
|
|
27
29
|
it "creates default ACL entries if no file has been read" do
|
|
28
30
|
Puppet::Network::AuthConfigParser.expects(:new_from_file).raises Errno::ENOENT
|
|
29
|
-
Puppet::Network::
|
|
31
|
+
Puppet::Network::DefaultAuthProvider.any_instance.expects(:insert_default_acl)
|
|
30
32
|
|
|
31
33
|
subject.authconfig
|
|
32
34
|
end
|
|
33
35
|
end
|
|
36
|
+
|
|
37
|
+
class TestAuthConfig
|
|
38
|
+
def check_authorization(method, path, params); end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class TestAuthConfigLoader
|
|
42
|
+
def self.authconfig
|
|
43
|
+
TestAuthConfig.new
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "when checking authorization" do
|
|
48
|
+
after :each do
|
|
49
|
+
Puppet::Network::Authorization.authconfigloader_class = nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "delegates to the authconfig object" do
|
|
53
|
+
Puppet::Network::Authorization.authconfigloader_class =
|
|
54
|
+
TestAuthConfigLoader
|
|
55
|
+
TestAuthConfig.any_instance.expects(:check_authorization).with(
|
|
56
|
+
:save, '/mypath', {:param1 => "value1"}).returns("yay, it worked!")
|
|
57
|
+
expect(subject.check_authorization(
|
|
58
|
+
:save, '/mypath',
|
|
59
|
+
{:param1 => "value1"})).to eq("yay, it worked!")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
34
62
|
end
|
|
@@ -180,7 +180,7 @@ describe Puppet::Network::AuthStore::Declaration do
|
|
|
180
180
|
].each { |invalid_ip|
|
|
181
181
|
describe "when the pattern is an invalid IPv6 address such as #{invalid_ip}" do
|
|
182
182
|
it "should raise an exception" do
|
|
183
|
-
expect { Puppet::Network::AuthStore::Declaration.new(:allow,invalid_ip) }.to raise_error
|
|
183
|
+
expect { Puppet::Network::AuthStore::Declaration.new(:allow,invalid_ip) }.to raise_error(Puppet::AuthStoreError, /Invalid pattern/)
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
}
|
|
@@ -173,7 +173,7 @@ describe "http compression" do
|
|
|
173
173
|
it "should raise the error the second time" do
|
|
174
174
|
@inflater.stubs(:inflate).raises(Zlib::DataError.new("not a zlib stream"))
|
|
175
175
|
Zlib::Inflate.expects(:new).with.returns(@inflater)
|
|
176
|
-
expect { @adapter.uncompress("chunk") }.to raise_error
|
|
176
|
+
expect { @adapter.uncompress("chunk") }.to raise_error(Zlib::DataError, /not a zlib stream/)
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
it "should finish the stream on close" do
|
|
@@ -42,31 +42,18 @@ describe Puppet::Network::HTTP::Connection do
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
context "when
|
|
46
|
-
let (:host) { "
|
|
45
|
+
context "when handling requests", :vcr do
|
|
46
|
+
let (:host) { "my-server" }
|
|
47
47
|
let (:port) { 8140 }
|
|
48
48
|
let (:subject) { Puppet::Network::HTTP::Connection.new(host, port, :use_ssl => false, :verify => Puppet::SSL::Validator.no_validator) }
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# This stubbing relies a bit more on knowledge of the internals of Net::HTTP
|
|
54
|
-
# than I would prefer, but it works on ruby 1.8.7 and 1.9.3, and it seems
|
|
55
|
-
# valuable enough to have tests for blocks that this is probably warranted.
|
|
56
|
-
socket = stub_everything("socket")
|
|
57
|
-
TCPSocket.stubs(:open).returns(socket)
|
|
58
|
-
|
|
59
|
-
Net::HTTP::Post.any_instance.stubs(:exec).returns("")
|
|
60
|
-
Net::HTTP::Head.any_instance.stubs(:exec).returns("")
|
|
61
|
-
Net::HTTP::Get.any_instance.stubs(:exec).returns("")
|
|
62
|
-
Net::HTTPResponse.stubs(:read_new).returns(httpok)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
[:request_get, :request_head, :request_post].each do |method|
|
|
50
|
+
{ :request_get => {},
|
|
51
|
+
:request_head => {},
|
|
52
|
+
:request_post => "param: value" }.each do |method,body|
|
|
66
53
|
context "##{method}" do
|
|
67
54
|
it "should yield to the block" do
|
|
68
55
|
block_executed = false
|
|
69
|
-
subject.send(method, "/foo",
|
|
56
|
+
subject.send(method, "/foo", body) do |response|
|
|
70
57
|
block_executed = true
|
|
71
58
|
end
|
|
72
59
|
expect(block_executed).to eq(true)
|
|
@@ -118,6 +105,14 @@ describe Puppet::Network::HTTP::Connection do
|
|
|
118
105
|
let (:host) { "my_server" }
|
|
119
106
|
let (:port) { 8140 }
|
|
120
107
|
|
|
108
|
+
before :all do
|
|
109
|
+
WebMock.disable!
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
after :all do
|
|
113
|
+
WebMock.enable!
|
|
114
|
+
end
|
|
115
|
+
|
|
121
116
|
it "should provide a useful error message when one is available and certificate validation fails", :unless => Puppet.features.microsoft_windows? do
|
|
122
117
|
connection = Puppet::Network::HTTP::Connection.new(
|
|
123
118
|
host, port,
|
|
@@ -131,11 +131,6 @@ describe Puppet::Network::HTTP::Handler do
|
|
|
131
131
|
handler.process(request, response)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
it "should raise an error if the request is formatted in an unknown format" do
|
|
135
|
-
handler.stubs(:content_type_header).returns "unknown format"
|
|
136
|
-
expect { handler.request_format(request) }.to raise_error
|
|
137
|
-
end
|
|
138
|
-
|
|
139
134
|
it "should still find the correct format if content type contains charset information" do
|
|
140
135
|
request = Puppet::Network::HTTP::Request.new({ 'content-type' => "text/plain; charset=UTF-8" },
|
|
141
136
|
{}, 'GET', '/', nil)
|
|
@@ -29,7 +29,7 @@ describe Puppet::Network::Rights do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "should throw an error if type can't be determined" do
|
|
32
|
-
expect { @right.newright("name") }.to raise_error
|
|
32
|
+
expect { @right.newright("name") }.to raise_error(ArgumentError, /Unknown right type/)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
describe "when creating new path ACLs" do
|
|
@@ -40,7 +40,7 @@ describe Puppet::Network::Rights do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should throw an error if the acl uri path is not absolute" do
|
|
43
|
-
expect { @right.newright("name")}.to raise_error
|
|
43
|
+
expect { @right.newright("name")}.to raise_error(ArgumentError, /Unknown right type/)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should create a new ACL with the correct path" do
|
|
@@ -351,7 +351,7 @@ describe Puppet::Network::Rights do
|
|
|
351
351
|
it "should raise an error if the method is already filtered" do
|
|
352
352
|
@acl.restrict_method(:save)
|
|
353
353
|
|
|
354
|
-
expect { @acl.restrict_method(:save) }.to raise_error
|
|
354
|
+
expect { @acl.restrict_method(:save) }.to raise_error(ArgumentError, /'save' is already in the '\/path'/)
|
|
355
355
|
end
|
|
356
356
|
|
|
357
357
|
it "should allow setting an environment filters" do
|
data/spec/unit/node_spec.rb
CHANGED
|
@@ -88,6 +88,33 @@ describe Puppet::Node do
|
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
describe "when serializing using yaml" do
|
|
92
|
+
before do
|
|
93
|
+
@node = Puppet::Node.new("mynode")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "a node can roundtrip" do
|
|
97
|
+
expect(YAML.load(@node.to_yaml).name).to eql("mynode")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "limits the serialization of environment to be just the name" do
|
|
101
|
+
# it is something like 138 when serializing everything in a default environment
|
|
102
|
+
expect(@node.to_yaml.size).to be < 70
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe "when serializing using yaml and values classes and parameters are missing in deserialized hash" do
|
|
107
|
+
it "a node can roundtrip" do
|
|
108
|
+
@node = Puppet::Node.from_data_hash({'name' => "mynode"})
|
|
109
|
+
expect(YAML.load(@node.to_yaml).name).to eql("mynode")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "errors if name is nil" do
|
|
113
|
+
expect { Puppet::Node.from_data_hash({ })}.to raise_error(ArgumentError, /No name provided in serialized data/)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
|
|
91
118
|
describe "when converting to json" do
|
|
92
119
|
before do
|
|
93
120
|
@node = Puppet::Node.new("mynode")
|
|
@@ -93,7 +93,7 @@ describe Puppet::Parser::AST::HostName do
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "should raise an error if hostname is not valid" do
|
|
96
|
-
expect { Puppet::Parser::AST::HostName.new( :value => "not a hostname!" ) }.to raise_error
|
|
96
|
+
expect { Puppet::Parser::AST::HostName.new( :value => "not a hostname!" ) }.to raise_error(Puppet::DevError, /'not a hostname!' is not a valid hostname/)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should not raise an error if hostname is a regex" do
|
|
@@ -49,6 +49,10 @@ class CompilerTestResource
|
|
|
49
49
|
def line
|
|
50
50
|
"42"
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
def resource_type
|
|
54
|
+
self.class
|
|
55
|
+
end
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
describe Puppet::Parser::Compiler do
|
|
@@ -112,6 +116,7 @@ describe Puppet::Parser::Compiler do
|
|
|
112
116
|
it "should set its node attribute" do
|
|
113
117
|
expect(@compiler.node).to equal(@node)
|
|
114
118
|
end
|
|
119
|
+
|
|
115
120
|
it "should detect when ast nodes are absent" do
|
|
116
121
|
expect(@compiler.ast_nodes?).to be_falsey
|
|
117
122
|
end
|
|
@@ -141,11 +146,90 @@ describe Puppet::Parser::Compiler do
|
|
|
141
146
|
expect(compiler.classlist).to match_array(['foo', 'bar'])
|
|
142
147
|
end
|
|
143
148
|
|
|
149
|
+
it "should return a catalog with the specified code_id" do
|
|
150
|
+
node = Puppet::Node.new("mynode")
|
|
151
|
+
code_id = 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe'
|
|
152
|
+
compiler = Puppet::Parser::Compiler.new(node, :code_id => code_id)
|
|
153
|
+
|
|
154
|
+
expect(compiler.catalog.code_id).to eq(code_id)
|
|
155
|
+
end
|
|
156
|
+
|
|
144
157
|
it "should add a 'main' stage to the catalog" do
|
|
145
158
|
expect(@compiler.catalog.resource(:stage, :main)).to be_instance_of(Puppet::Parser::Resource)
|
|
146
159
|
end
|
|
147
160
|
end
|
|
148
161
|
|
|
162
|
+
describe "sanitize_node" do
|
|
163
|
+
it "should delete trusted from parameters" do
|
|
164
|
+
node = Puppet::Node.new("mynode")
|
|
165
|
+
node.parameters['trusted'] = { :a => 42 }
|
|
166
|
+
node.parameters['preserve_me'] = 'other stuff'
|
|
167
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
168
|
+
sanitized = compiler.node
|
|
169
|
+
expect(sanitized.parameters['trusted']).to eq(nil)
|
|
170
|
+
expect(sanitized.parameters['preserve_me']).to eq('other stuff')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should not report trusted_data if trusted is false" do
|
|
174
|
+
node = Puppet::Node.new("mynode")
|
|
175
|
+
node.parameters['trusted'] = false
|
|
176
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
177
|
+
sanitized = compiler.node
|
|
178
|
+
expect(sanitized.trusted_data).to_not eq(false)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "should not report trusted_data if trusted is not a hash" do
|
|
182
|
+
node = Puppet::Node.new("mynode")
|
|
183
|
+
node.parameters['trusted'] = 'not a hash'
|
|
184
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
185
|
+
sanitized = compiler.node
|
|
186
|
+
expect(sanitized.trusted_data).to_not eq('not a hash')
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it "should not report trusted_data if trusted hash doesn't include known keys" do
|
|
190
|
+
node = Puppet::Node.new("mynode")
|
|
191
|
+
node.parameters['trusted'] = { :a => 42 }
|
|
192
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
193
|
+
sanitized = compiler.node
|
|
194
|
+
expect(sanitized.trusted_data).to_not eq({ :a => 42 })
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "should report 'trusted' parameters as trusted_data but as inauthentic if running as non-root" do
|
|
198
|
+
node = Puppet::Node.new("mynode")
|
|
199
|
+
node.parameters['trusted'] = { 'authenticated' => true,
|
|
200
|
+
'certname' => 'foo',
|
|
201
|
+
'extensions' => 'things' }
|
|
202
|
+
|
|
203
|
+
Puppet.features.stubs(:root?).returns(false)
|
|
204
|
+
|
|
205
|
+
Puppet.ignore(:trusted_information)
|
|
206
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
207
|
+
Puppet.restore(:trusted_information)
|
|
208
|
+
|
|
209
|
+
sanitized = compiler.node
|
|
210
|
+
expect(sanitized.trusted_data).to eq({ 'authenticated' => false,
|
|
211
|
+
'certname' => 'foo',
|
|
212
|
+
'extensions' => 'things' })
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it "should prefer trusted_data in the node above other plausible sources" do
|
|
216
|
+
node = Puppet::Node.new("mynode")
|
|
217
|
+
node.trusted_data = { 'authenticated' => true,
|
|
218
|
+
'certname' => 'the real deal',
|
|
219
|
+
'extensions' => 'things' }
|
|
220
|
+
|
|
221
|
+
node.parameters['trusted'] = { 'authenticated' => true,
|
|
222
|
+
'certname' => 'not me',
|
|
223
|
+
'extensions' => 'things' }
|
|
224
|
+
|
|
225
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
|
226
|
+
sanitized = compiler.node
|
|
227
|
+
expect(sanitized.trusted_data).to eq({ 'authenticated' => true,
|
|
228
|
+
'certname' => 'the real deal',
|
|
229
|
+
'extensions' => 'things' })
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
149
233
|
describe "when managing scopes" do
|
|
150
234
|
|
|
151
235
|
it "should create a top scope" do
|
|
@@ -629,7 +713,7 @@ describe Puppet::Parser::Compiler do
|
|
|
629
713
|
@node.classes = klass
|
|
630
714
|
klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'a' => nil, 'b' => nil})
|
|
631
715
|
@compiler.topscope.known_resource_types.add klass
|
|
632
|
-
expect { @compiler.compile }.to raise_error(Puppet::
|
|
716
|
+
expect { @compiler.compile }.to raise_error(Puppet::PreformattedError, /Class\[Foo\]: expects a value for parameter 'b'/)
|
|
633
717
|
end
|
|
634
718
|
|
|
635
719
|
it "should fail if invalid parameters are passed" do
|
|
@@ -637,7 +721,7 @@ describe Puppet::Parser::Compiler do
|
|
|
637
721
|
@node.classes = klass
|
|
638
722
|
klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {})
|
|
639
723
|
@compiler.topscope.known_resource_types.add klass
|
|
640
|
-
expect { @compiler.compile }.to raise_error(Puppet::
|
|
724
|
+
expect { @compiler.compile }.to raise_error(Puppet::PreformattedError, /Class\[Foo\]: has no parameter named '3'/)
|
|
641
725
|
end
|
|
642
726
|
|
|
643
727
|
it "should ensure class is in catalog without params" do
|
|
@@ -103,7 +103,7 @@ describe 'function for dynamically creating resources' do
|
|
|
103
103
|
|
|
104
104
|
create_resources('foocreateresource', {'blah'=>{}})
|
|
105
105
|
MANIFEST
|
|
106
|
-
}.to raise_error(Puppet::Error,
|
|
106
|
+
}.to raise_error(Puppet::Error, /Foocreateresource\[blah\]: expects a value for parameter 'one' on node foonode/)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it 'should be able to add multiple defines' do
|
|
@@ -105,9 +105,9 @@ describe Puppet::Parser::Resource do
|
|
|
105
105
|
@arguments = {:scope => @scope}
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
it "should fail unless
|
|
108
|
+
it "should fail unless hash is specified" do
|
|
109
109
|
expect {
|
|
110
|
-
Puppet::Parser::Resource.new('file', '/my/file')
|
|
110
|
+
Puppet::Parser::Resource.new('file', '/my/file', nil)
|
|
111
111
|
}.to raise_error(ArgumentError, /Resources require a hash as last argument/)
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -531,24 +531,6 @@ describe Puppet::Parser::Resource do
|
|
|
531
531
|
end
|
|
532
532
|
end
|
|
533
533
|
|
|
534
|
-
describe "when validating" do
|
|
535
|
-
it "should check each parameter" do
|
|
536
|
-
resource = Puppet::Parser::Resource.new :foo, "bar", :scope => @scope, :source => stub("source")
|
|
537
|
-
resource[:one] = :two
|
|
538
|
-
resource[:three] = :four
|
|
539
|
-
resource.expects(:validate_parameter).with(:one)
|
|
540
|
-
resource.expects(:validate_parameter).with(:three)
|
|
541
|
-
resource.send(:validate)
|
|
542
|
-
end
|
|
543
|
-
|
|
544
|
-
it "should raise a parse error when there's a failure" do
|
|
545
|
-
resource = Puppet::Parser::Resource.new :foo, "bar", :scope => @scope, :source => stub("source")
|
|
546
|
-
resource[:one] = :two
|
|
547
|
-
resource.expects(:validate_parameter).with(:one).raises ArgumentError
|
|
548
|
-
expect { resource.send(:validate) }.to raise_error(Puppet::ParseError)
|
|
549
|
-
end
|
|
550
|
-
end
|
|
551
|
-
|
|
552
534
|
describe "when setting parameters" do
|
|
553
535
|
before do
|
|
554
536
|
@source = newclass "foobar"
|
|
@@ -16,7 +16,7 @@ describe 'BinderConfig' do
|
|
|
16
16
|
expect(config.layering_config[0]['name']).to be == 'site'
|
|
17
17
|
expect(config.layering_config[0]['include']).to be == ['confdir:/default?optional']
|
|
18
18
|
expect(config.layering_config[1]['name']).to be == 'modules'
|
|
19
|
-
expect(config.layering_config[1]['include']).to be == ['module:/*::default']
|
|
19
|
+
expect(config.layering_config[1]['include']).to be == ['module:/*::default', 'module:/*::metadata']
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it 'should load binder_config.yaml if it exists in confdir)' do
|
|
@@ -594,11 +594,11 @@ describe 'Injector' do
|
|
|
594
594
|
it "should fail attempts to append, perform uniq or flatten on type incompatible multibind hash" do
|
|
595
595
|
hash_of_integer = type_factory.hash_of(type_factory.integer())
|
|
596
596
|
ids = ["ducks1", "ducks2", "ducks3"]
|
|
597
|
-
mb = bindings.multibind(ids[0]).type(hash_of_integer
|
|
597
|
+
mb = bindings.multibind(ids[0]).type(hash_of_integer).name('broken_family0')
|
|
598
598
|
mb.producer_options(:conflict_resolution => :append)
|
|
599
|
-
mb = bindings.multibind(ids[1]).type(hash_of_integer
|
|
599
|
+
mb = bindings.multibind(ids[1]).type(hash_of_integer).name('broken_family1')
|
|
600
600
|
mb.producer_options(:flatten => :true)
|
|
601
|
-
mb = bindings.multibind(ids[2]).type(hash_of_integer
|
|
601
|
+
mb = bindings.multibind(ids[2]).type(hash_of_integer).name('broken_family2')
|
|
602
602
|
mb.producer_options(:uniq => :true)
|
|
603
603
|
|
|
604
604
|
injector = injector(binder.new(factory.layered_bindings(test_layer_with_bindings(bindings.model))))
|
|
@@ -208,13 +208,11 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl/AccessOperator' do
|
|
|
208
208
|
|
|
209
209
|
it 'produces a size constrained Array when the last two arguments specify this' do
|
|
210
210
|
expr = fqr('Array')[fqr('String'), 1]
|
|
211
|
-
expected_t = types.array_of(String)
|
|
212
|
-
types.constrain_size(expected_t, 1, :default)
|
|
211
|
+
expected_t = types.array_of(String, types.range(1, :default))
|
|
213
212
|
expect(evaluate(expr)).to be_the_type(expected_t)
|
|
214
213
|
|
|
215
214
|
expr = fqr('Array')[fqr('String'), 1, 2]
|
|
216
|
-
expected_t = types.array_of(String)
|
|
217
|
-
types.constrain_size(expected_t, 1, 2)
|
|
215
|
+
expected_t = types.array_of(String, types.range(1, 2))
|
|
218
216
|
expect(evaluate(expr)).to be_the_type(expected_t)
|
|
219
217
|
end
|
|
220
218
|
|
|
@@ -227,11 +225,11 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl/AccessOperator' do
|
|
|
227
225
|
#
|
|
228
226
|
it 'produces a Tuple[String] from the expression Tuple[String]' do
|
|
229
227
|
expr = fqr('Tuple')[fqr('String')]
|
|
230
|
-
expect(evaluate(expr)).to be_the_type(types.tuple(String))
|
|
228
|
+
expect(evaluate(expr)).to be_the_type(types.tuple([String]))
|
|
231
229
|
|
|
232
230
|
# arguments are flattened
|
|
233
231
|
expr = fqr('Tuple')[[fqr('String')]]
|
|
234
|
-
expect(evaluate(expr)).to be_the_type(types.tuple(String))
|
|
232
|
+
expect(evaluate(expr)).to be_the_type(types.tuple([String]))
|
|
235
233
|
end
|
|
236
234
|
|
|
237
235
|
it "Tuple parameterization gives an error if parameter is not a type" do
|
|
@@ -241,13 +239,11 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl/AccessOperator' do
|
|
|
241
239
|
|
|
242
240
|
it 'produces a varargs Tuple when the last two arguments specify size constraint' do
|
|
243
241
|
expr = fqr('Tuple')[fqr('String'), 1]
|
|
244
|
-
expected_t = types.tuple(String)
|
|
245
|
-
types.constrain_size(expected_t, 1, :default)
|
|
242
|
+
expected_t = types.tuple([String], types.range(1, :default))
|
|
246
243
|
expect(evaluate(expr)).to be_the_type(expected_t)
|
|
247
244
|
|
|
248
245
|
expr = fqr('Tuple')[fqr('String'), 1, 2]
|
|
249
|
-
expected_t = types.tuple(String)
|
|
250
|
-
types.constrain_size(expected_t, 1, 2)
|
|
246
|
+
expected_t = types.tuple([String], types.range(1, 2))
|
|
251
247
|
expect(evaluate(expr)).to be_the_type(expected_t)
|
|
252
248
|
end
|
|
253
249
|
|
|
@@ -416,7 +412,13 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl/AccessOperator' do
|
|
|
416
412
|
it 'produces a NotUndef instance with String type when given a literal String' do
|
|
417
413
|
type_expr = fqr('NotUndef')[literal('hey')]
|
|
418
414
|
tf = Puppet::Pops::Types::TypeFactory
|
|
419
|
-
expect(evaluate(type_expr)).to
|
|
415
|
+
expect(evaluate(type_expr)).to be_the_type(tf.not_undef(tf.string(nil, 'hey')))
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
it 'Produces Optional instance with String type when using a String argument' do
|
|
419
|
+
type_expr = fqr('Optional')[literal('hey')]
|
|
420
|
+
tf = Puppet::Pops::Types::TypeFactory
|
|
421
|
+
expect(evaluate(type_expr)).to be_the_type(tf.optional(tf.string(nil, 'hey')))
|
|
420
422
|
end
|
|
421
423
|
|
|
422
424
|
# Type Type
|
|
@@ -31,8 +31,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it 'should evaluator types to types' do
|
|
34
|
-
array_type = Puppet::Pops::Types::PArrayType
|
|
35
|
-
array_type.element_type = Puppet::Pops::Types::PDataType.new()
|
|
34
|
+
array_type = Puppet::Pops::Types::PArrayType::DATA
|
|
36
35
|
expect(evaluate(fqr('Array'))).to eq(array_type)
|
|
37
36
|
end
|
|
38
37
|
end
|