puppet 6.11.1-universal-darwin → 6.16.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CODEOWNERS +3 -8
- data/CONTRIBUTING.md +7 -13
- data/Gemfile +1 -0
- data/Gemfile.lock +39 -36
- data/README.md +17 -24
- data/ext/build_defaults.yaml +1 -0
- data/ext/project_data.yaml +1 -1
- data/ext/windows/service/daemon.rb +25 -20
- data/lib/puppet.rb +52 -13
- data/lib/puppet/agent.rb +20 -14
- data/lib/puppet/application/agent.rb +12 -14
- data/lib/puppet/application/describe.rb +7 -5
- data/lib/puppet/application/device.rb +2 -2
- data/lib/puppet/application/filebucket.rb +19 -15
- data/lib/puppet/application/plugin.rb +1 -0
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/application/ssl.rb +4 -4
- data/lib/puppet/concurrent.rb +2 -0
- data/lib/puppet/concurrent/lock.rb +16 -0
- data/lib/puppet/concurrent/synchronized.rb +15 -0
- data/lib/puppet/concurrent/thread_local_singleton.rb +14 -0
- data/lib/puppet/configurer.rb +85 -83
- data/lib/puppet/configurer/plugin_handler.rb +10 -1
- data/lib/puppet/context/trusted_information.rb +14 -8
- data/lib/puppet/daemon.rb +13 -27
- data/lib/puppet/defaults.rb +158 -40
- data/lib/puppet/environments.rb +30 -20
- data/lib/puppet/error.rb +9 -1
- data/lib/puppet/face/facts.rb +8 -5
- data/lib/puppet/face/help.rb +29 -3
- data/lib/puppet/face/module/search.rb +5 -0
- data/lib/puppet/face/plugin.rb +2 -2
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system/file_impl.rb +13 -9
- data/lib/puppet/file_system/memory_file.rb +6 -0
- data/lib/puppet/file_system/memory_impl.rb +13 -0
- data/lib/puppet/file_system/uniquefile.rb +4 -0
- data/lib/puppet/file_system/windows.rb +7 -10
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/forge/errors.rb +2 -2
- data/lib/puppet/forge/repository.rb +31 -86
- data/lib/puppet/functions/call.rb +1 -1
- data/lib/puppet/functions/camelcase.rb +2 -2
- data/lib/puppet/functions/epp.rb +4 -4
- data/lib/puppet/functions/eyaml_lookup_key.rb +13 -8
- data/lib/puppet/functions/filter.rb +1 -0
- data/lib/puppet/functions/find_file.rb +9 -9
- data/lib/puppet/functions/find_template.rb +63 -0
- data/lib/puppet/functions/inline_epp.rb +5 -5
- data/lib/puppet/functions/reduce.rb +2 -4
- data/lib/puppet/http.rb +7 -0
- data/lib/puppet/http/client.rb +341 -54
- data/lib/puppet/http/errors.rb +2 -0
- data/lib/puppet/http/external_client.rb +90 -0
- data/lib/puppet/http/redirector.rb +34 -0
- data/lib/puppet/http/resolver.rb +57 -1
- data/lib/puppet/http/resolver/server_list.rb +98 -0
- data/lib/puppet/http/resolver/settings.rb +23 -2
- data/lib/puppet/http/resolver/srv.rb +36 -4
- data/lib/puppet/http/response.rb +68 -1
- data/lib/puppet/http/retry_after_handler.rb +39 -0
- data/lib/puppet/http/service.rb +179 -3
- data/lib/puppet/http/service/ca.rb +84 -21
- data/lib/puppet/http/service/compiler.rb +319 -0
- data/lib/puppet/http/service/file_server.rb +206 -0
- data/lib/puppet/http/service/report.rb +66 -0
- data/lib/puppet/http/session.rb +106 -31
- data/lib/puppet/indirector/catalog/compiler.rb +10 -0
- data/lib/puppet/indirector/catalog/rest.rb +34 -0
- data/lib/puppet/indirector/facts/rest.rb +42 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
- data/lib/puppet/indirector/file_content/http.rb +5 -0
- data/lib/puppet/indirector/file_content/rest.rb +30 -0
- data/lib/puppet/indirector/file_metadata/http.rb +4 -4
- data/lib/puppet/indirector/file_metadata/rest.rb +52 -0
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/node/rest.rb +24 -0
- data/lib/puppet/indirector/report/rest.rb +19 -0
- data/lib/puppet/indirector/report/yaml.rb +23 -0
- data/lib/puppet/indirector/rest.rb +12 -0
- data/lib/puppet/indirector/status/rest.rb +18 -0
- data/lib/puppet/loaders.rb +6 -0
- data/lib/puppet/metatype/manager.rb +80 -80
- data/lib/puppet/network/http/base_pool.rb +19 -1
- data/lib/puppet/network/http/compression.rb +7 -0
- data/lib/puppet/network/http/connection.rb +6 -0
- data/lib/puppet/network/http/connection_adapter.rb +182 -0
- data/lib/puppet/network/http/nocache_pool.rb +2 -0
- data/lib/puppet/network/http/pool.rb +13 -6
- data/lib/puppet/network/http_pool.rb +2 -1
- data/lib/puppet/node/environment.rb +24 -8
- data/lib/puppet/pal/catalog_compiler.rb +5 -0
- data/lib/puppet/pal/pal_impl.rb +9 -29
- data/lib/puppet/parser/ast/pops_bridge.rb +6 -11
- data/lib/puppet/parser/compiler.rb +42 -32
- data/lib/puppet/parser/functions.rb +18 -13
- data/lib/puppet/parser/functions/epp.rb +3 -3
- data/lib/puppet/parser/functions/filter.rb +1 -0
- data/lib/puppet/parser/functions/inline_epp.rb +5 -5
- data/lib/puppet/pops/evaluator/access_operator.rb +2 -2
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -1
- data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +12 -3
- data/lib/puppet/pops/loaders.rb +7 -5
- data/lib/puppet/pops/lookup/invocation.rb +10 -3
- data/lib/puppet/pops/model/pn_transformer.rb +5 -9
- data/lib/puppet/pops/parser/evaluating_parser.rb +8 -11
- data/lib/puppet/pops/serialization/json_path.rb +3 -3
- data/lib/puppet/pops/time/timespan.rb +3 -5
- data/lib/puppet/pops/types/p_object_type_extension.rb +10 -0
- data/lib/puppet/pops/types/string_converter.rb +6 -9
- data/lib/puppet/pops/types/type_calculator.rb +30 -10
- data/lib/puppet/pops/types/type_formatter.rb +9 -11
- data/lib/puppet/pops/types/type_parser.rb +3 -3
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/tasks_checker.rb +5 -1
- data/lib/puppet/provider/aix_object.rb +4 -2
- data/lib/puppet/provider/group/aix.rb +1 -0
- data/lib/puppet/provider/group/groupadd.rb +57 -24
- data/lib/puppet/provider/group/windows_adsi.rb +3 -3
- data/lib/puppet/provider/package/aix.rb +17 -2
- data/lib/puppet/provider/package/apt.rb +78 -4
- data/lib/puppet/provider/package/dnfmodule.rb +69 -15
- data/lib/puppet/provider/package/dpkg.rb +14 -7
- data/lib/puppet/provider/package/fink.rb +20 -3
- data/lib/puppet/provider/package/gem.rb +41 -7
- data/lib/puppet/provider/package/openbsd.rb +13 -1
- data/lib/puppet/provider/package/pacman.rb +2 -5
- data/lib/puppet/provider/package/pip.rb +143 -48
- data/lib/puppet/provider/package/pip3.rb +0 -2
- data/lib/puppet/provider/package/pkg.rb +18 -5
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgng.rb +16 -4
- data/lib/puppet/provider/package/portage.rb +5 -5
- data/lib/puppet/provider/package/puppet_gem.rb +6 -2
- data/lib/puppet/provider/package/rpm.rb +6 -213
- data/lib/puppet/provider/package/yum.rb +108 -24
- data/lib/puppet/provider/package/zypper.rb +59 -1
- data/lib/puppet/provider/package_targetable.rb +5 -4
- data/lib/puppet/provider/service/systemd.rb +23 -5
- data/lib/puppet/provider/user/aix.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +30 -5
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +11 -8
- data/lib/puppet/reports/http.rb +13 -9
- data/lib/puppet/reports/store.rb +1 -1
- data/lib/puppet/resource/type_collection.rb +20 -16
- data/lib/puppet/runtime.rb +32 -1
- data/lib/puppet/settings.rb +4 -0
- data/lib/puppet/settings/http_extra_headers_setting.rb +25 -0
- data/lib/puppet/ssl.rb +1 -0
- data/lib/puppet/ssl/certificate.rb +2 -1
- data/lib/puppet/ssl/host.rb +4 -4
- data/lib/puppet/ssl/oids.rb +1 -0
- data/lib/puppet/ssl/ssl_provider.rb +20 -0
- data/lib/puppet/ssl/state_machine.rb +81 -35
- data/lib/puppet/ssl/verifier_adapter.rb +9 -1
- data/lib/puppet/test/test_helper.rb +7 -1
- data/lib/puppet/transaction.rb +33 -11
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/transaction/resource_harness.rb +1 -1
- data/lib/puppet/type.rb +7 -2
- data/lib/puppet/type/file.rb +13 -0
- data/lib/puppet/type/file/data_sync.rb +5 -1
- data/lib/puppet/type/file/source.rb +49 -58
- data/lib/puppet/type/group.rb +5 -4
- data/lib/puppet/type/package.rb +102 -10
- data/lib/puppet/type/service.rb +6 -8
- data/lib/puppet/type/user.rb +6 -30
- data/lib/puppet/util.rb +34 -11
- data/lib/puppet/util/at_fork.rb +1 -1
- data/lib/puppet/util/autoload.rb +4 -18
- data/lib/puppet/util/instance_loader.rb +14 -10
- data/lib/puppet/util/log/destinations.rb +2 -11
- data/lib/puppet/util/logging.rb +30 -18
- data/lib/puppet/util/package/version/debian.rb +175 -0
- data/lib/puppet/util/package/version/gem.rb +15 -0
- data/lib/puppet/util/package/version/pip.rb +167 -0
- data/lib/puppet/util/package/version/range.rb +53 -0
- data/lib/puppet/util/package/version/range/eq.rb +14 -0
- data/lib/puppet/util/package/version/range/gt.rb +14 -0
- data/lib/puppet/util/package/version/range/gt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/lt.rb +14 -0
- data/lib/puppet/util/package/version/range/lt_eq.rb +14 -0
- data/lib/puppet/util/package/version/range/min_max.rb +21 -0
- data/lib/puppet/util/package/version/range/simple.rb +11 -0
- data/lib/puppet/util/package/version/rpm.rb +73 -0
- data/lib/puppet/util/pidlock.rb +36 -10
- data/lib/puppet/util/platform.rb +5 -0
- data/lib/puppet/util/plist.rb +6 -0
- data/lib/puppet/util/rpm_compare.rb +193 -0
- data/lib/puppet/util/storage.rb +0 -1
- data/lib/puppet/util/windows/adsi.rb +50 -20
- data/lib/puppet/util/windows/process.rb +15 -14
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/util/windows/sid.rb +3 -3
- data/lib/puppet/util/yaml.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet/x509/cert_provider.rb +9 -5
- data/locales/puppet.pot +640 -521
- data/man/man5/puppet.conf.5 +88 -9
- data/man/man8/puppet-agent.8 +6 -6
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +2 -2
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +17 -2
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +6 -3
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +4 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +2 -2
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +48 -0
- data/spec/fixtures/ssl/unknown-ca-key.pem +67 -0
- data/spec/fixtures/ssl/unknown-ca.pem +59 -0
- data/spec/fixtures/unit/forge/bacula.json +76 -0
- data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list.txt} +8 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +2 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-subscription-manager.txt +9 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-search-uninstalled.out +13 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +9 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +1 -102
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +1 -106
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +1 -106
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +1 -102
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +1 -98
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +1 -102
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +1 -102
- data/spec/integration/application/agent_spec.rb +394 -0
- data/spec/integration/application/apply_spec.rb +132 -3
- data/spec/integration/application/filebucket_spec.rb +190 -0
- data/spec/integration/application/plugin_spec.rb +73 -0
- data/spec/integration/configurer_spec.rb +26 -7
- data/spec/integration/http/client_spec.rb +154 -0
- data/spec/integration/indirector/facts/facter_spec.rb +4 -0
- data/spec/integration/indirector/report/yaml.rb +83 -0
- data/spec/integration/module_tool/forge_spec.rb +51 -0
- data/spec/integration/network/http_pool_spec.rb +76 -20
- data/spec/integration/node/environment_spec.rb +15 -0
- data/spec/integration/util/windows/adsi_spec.rb +6 -1
- data/spec/lib/puppet/test_ca.rb +2 -2
- data/spec/lib/puppet_spec/https.rb +20 -9
- data/spec/lib/puppet_spec/puppetserver.rb +119 -0
- data/spec/shared_contexts/https.rb +29 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/unit/agent_spec.rb +80 -26
- data/spec/unit/application/agent_spec.rb +9 -5
- data/spec/unit/application/apply_spec.rb +2 -12
- data/spec/unit/application/describe_spec.rb +88 -50
- data/spec/unit/application/device_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +22 -2
- data/spec/unit/application/resource_spec.rb +2 -2
- data/spec/unit/concurrent/lock_spec.rb +29 -0
- data/spec/unit/configurer/fact_handler_spec.rb +0 -4
- data/spec/unit/configurer/plugin_handler_spec.rb +36 -19
- data/spec/unit/configurer_spec.rb +400 -406
- data/spec/unit/context/trusted_information_spec.rb +17 -0
- data/spec/unit/daemon_spec.rb +5 -64
- data/spec/unit/defaults_spec.rb +38 -4
- data/spec/unit/environments_spec.rb +65 -28
- data/spec/unit/face/facts_spec.rb +24 -20
- data/spec/unit/face/module/search_spec.rb +17 -0
- data/spec/unit/face/plugin_spec.rb +12 -10
- data/spec/unit/file_system/uniquefile_spec.rb +11 -0
- data/spec/unit/file_system_spec.rb +26 -2
- data/spec/unit/forge/errors_spec.rb +1 -1
- data/spec/unit/forge/forge_spec.rb +12 -54
- data/spec/unit/forge/module_release_spec.rb +19 -6
- data/spec/unit/forge/repository_spec.rb +63 -157
- data/spec/unit/forge_spec.rb +46 -116
- data/spec/unit/functions/find_template_spec.rb +69 -0
- data/spec/unit/functions/lookup_spec.rb +13 -0
- data/spec/unit/http/client_spec.rb +395 -27
- data/spec/unit/http/external_client_spec.rb +201 -0
- data/spec/unit/http/resolver_spec.rb +81 -12
- data/spec/unit/http/response_spec.rb +69 -0
- data/spec/unit/http/service/ca_spec.rb +100 -7
- data/spec/unit/http/service/compiler_spec.rb +627 -0
- data/spec/unit/http/service/file_server_spec.rb +308 -0
- data/spec/unit/http/service/report_spec.rb +118 -0
- data/spec/unit/http/service_spec.rb +117 -4
- data/spec/unit/http/session_spec.rb +237 -19
- data/spec/unit/indirector/catalog/compiler_spec.rb +47 -29
- data/spec/unit/indirector/catalog/rest_spec.rb +59 -2
- data/spec/unit/indirector/facts/rest_spec.rb +79 -24
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
- data/spec/unit/indirector/file_content/rest_spec.rb +53 -2
- data/spec/unit/indirector/file_metadata/http_spec.rb +167 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +110 -2
- data/spec/unit/indirector/node/rest_spec.rb +57 -2
- data/spec/unit/indirector/report/rest_spec.rb +58 -51
- data/spec/unit/indirector/resource/ral_spec.rb +7 -8
- data/spec/unit/indirector/rest_spec.rb +13 -0
- data/spec/unit/indirector/status/rest_spec.rb +43 -2
- data/spec/unit/network/http/connection_spec.rb +549 -176
- data/spec/unit/network/http/nocache_pool_spec.rb +25 -3
- data/spec/unit/network/http/pool_spec.rb +89 -11
- data/spec/unit/network/http_pool_spec.rb +63 -57
- data/spec/unit/network/http_spec.rb +1 -1
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/node/facts_spec.rb +2 -1
- data/spec/unit/node_spec.rb +7 -4
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +6 -1
- data/spec/unit/pops/validator/validator_spec.rb +7 -2
- data/spec/unit/provider/aix_object_spec.rb +16 -2
- data/spec/unit/provider/group/groupadd_spec.rb +181 -56
- data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
- data/spec/unit/provider/package/aix_spec.rb +29 -0
- data/spec/unit/provider/package/apt_spec.rb +43 -2
- data/spec/unit/provider/package/aptitude_spec.rb +1 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +76 -15
- data/spec/unit/provider/package/dpkg_spec.rb +28 -6
- data/spec/unit/provider/package/gem_spec.rb +40 -0
- data/spec/unit/provider/package/openbsd_spec.rb +17 -0
- data/spec/unit/provider/package/pacman_spec.rb +6 -21
- data/spec/unit/provider/package/pip_spec.rb +68 -19
- data/spec/unit/provider/package/pkg_spec.rb +15 -1
- data/spec/unit/provider/package/pkgdmg_spec.rb +1 -1
- data/spec/unit/provider/package/pkgng_spec.rb +38 -0
- data/spec/unit/provider/package/portage_spec.rb +9 -4
- data/spec/unit/provider/package/puppet_gem_spec.rb +8 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -212
- data/spec/unit/provider/package/yum_spec.rb +292 -0
- data/spec/unit/provider/package/zypper_spec.rb +84 -0
- data/spec/unit/provider/package_targetable_spec.rb +60 -0
- data/spec/unit/provider/service/init_spec.rb +1 -0
- data/spec/unit/provider/service/openbsd_spec.rb +9 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -0
- data/spec/unit/provider/service/redhat_spec.rb +9 -0
- data/spec/unit/provider/service/systemd_spec.rb +92 -12
- data/spec/unit/provider/user/directoryservice_spec.rb +41 -0
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/useradd_spec.rb +21 -8
- data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
- data/spec/unit/puppet_pal_2pec.rb +0 -26
- data/spec/unit/puppet_pal_catalog_spec.rb +46 -0
- data/spec/unit/puppet_spec.rb +47 -0
- data/spec/unit/reports/http_spec.rb +70 -52
- data/spec/unit/settings/autosign_setting_spec.rb +1 -1
- data/spec/unit/settings/http_extra_headers_spec.rb +64 -0
- data/spec/unit/ssl/certificate_spec.rb +7 -0
- data/spec/unit/ssl/host_spec.rb +4 -2
- data/spec/unit/ssl/oids_spec.rb +1 -0
- data/spec/unit/ssl/ssl_provider_spec.rb +71 -0
- data/spec/unit/ssl/state_machine_spec.rb +99 -13
- data/spec/unit/transaction/persistence_spec.rb +1 -10
- data/spec/unit/transaction/report_spec.rb +4 -0
- data/spec/unit/transaction_spec.rb +45 -1
- data/spec/unit/type/file/content_spec.rb +9 -3
- data/spec/unit/type/file/ensure_spec.rb +1 -2
- data/spec/unit/type/file/source_spec.rb +86 -35
- data/spec/unit/type/package_spec.rb +8 -0
- data/spec/unit/type/service_spec.rb +9 -8
- data/spec/unit/type/user_spec.rb +1 -2
- data/spec/unit/util/at_fork_spec.rb +3 -2
- data/spec/unit/util/autoload_spec.rb +2 -1
- data/spec/unit/util/log/destinations_spec.rb +1 -29
- data/spec/unit/util/log_spec.rb +0 -138
- data/spec/unit/util/logging_spec.rb +200 -0
- data/spec/unit/util/package/version/debian_spec.rb +83 -0
- data/spec/unit/util/package/version/pip_spec.rb +464 -0
- data/spec/unit/util/package/version/range_spec.rb +175 -0
- data/spec/unit/util/package/version/rpm_spec.rb +121 -0
- data/spec/unit/util/pidlock_spec.rb +112 -42
- data/spec/unit/util/plist_spec.rb +20 -0
- data/spec/unit/util/rpm_compare_spec.rb +196 -0
- data/spec/unit/util/storage_spec.rb +1 -8
- data/spec/unit/util/windows/adsi_spec.rb +55 -4
- data/spec/unit/util/windows/sid_spec.rb +2 -2
- data/spec/unit/x509/cert_provider_spec.rb +24 -4
- data/tasks/generate_cert_fixtures.rake +15 -1
- data/tasks/manpages.rake +6 -35
- metadata +92 -12
- data/COMMITTERS.md +0 -244
- data/spec/integration/faces/plugin_spec.rb +0 -61
- data/spec/lib/puppet_spec/validators.rb +0 -37
data/spec/unit/ssl/oids_spec.rb
CHANGED
@@ -33,6 +33,7 @@ describe Puppet::SSL::Oids do
|
|
33
33
|
'pp_cloudplatform' => '1.3.6.1.4.1.34380.1.1.23',
|
34
34
|
'pp_apptier' => '1.3.6.1.4.1.34380.1.1.24',
|
35
35
|
'pp_hostname' => '1.3.6.1.4.1.34380.1.1.25',
|
36
|
+
'pp_owner' => '1.3.6.1.4.1.34380.1.1.26',
|
36
37
|
'ppPrivCertExt' => '1.3.6.1.4.1.34380.1.2',
|
37
38
|
'ppAuthCertExt' => '1.3.6.1.4.1.34380.1.3',
|
38
39
|
'pp_authorization' => '1.3.6.1.4.1.34380.1.3.1',
|
@@ -73,6 +73,67 @@ describe Puppet::SSL::SSLProvider do
|
|
73
73
|
sslctx.verify_peer = false
|
74
74
|
}.to raise_error(/can't modify frozen/)
|
75
75
|
end
|
76
|
+
|
77
|
+
it 'verifies peer' do
|
78
|
+
sslctx = subject.create_root_context(config)
|
79
|
+
expect(sslctx.verify_peer).to eq(true)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when creating a system ssl context' do
|
84
|
+
it 'accepts empty list of CA certs' do
|
85
|
+
sslctx = subject.create_system_context(cacerts: [])
|
86
|
+
expect(sslctx.cacerts).to eq([])
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'accepts valid root certs' do
|
90
|
+
certs = [cert_fixture('ca.pem')]
|
91
|
+
sslctx = subject.create_system_context(cacerts: certs)
|
92
|
+
expect(sslctx.cacerts).to eq(certs)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'accepts valid intermediate certs' do
|
96
|
+
certs = [cert_fixture('ca.pem'), cert_fixture('intermediate.pem')]
|
97
|
+
sslctx = subject.create_system_context(cacerts: certs)
|
98
|
+
expect(sslctx.cacerts).to eq(certs)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'accepts expired CA certs' do
|
102
|
+
expired = [cert_fixture('ca.pem'), cert_fixture('intermediate.pem')]
|
103
|
+
expired.each { |x509| x509.not_after = Time.at(0) }
|
104
|
+
|
105
|
+
sslctx = subject.create_system_context(cacerts: expired)
|
106
|
+
expect(sslctx.cacerts).to eq(expired)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'raises if the frozen context is modified' do
|
110
|
+
sslctx = subject.create_system_context(cacerts: [])
|
111
|
+
expect {
|
112
|
+
sslctx.verify_peer = false
|
113
|
+
}.to raise_error(/can't modify frozen/)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'trusts system ca store' do
|
117
|
+
expect_any_instance_of(OpenSSL::X509::Store).to receive(:set_default_paths)
|
118
|
+
|
119
|
+
subject.create_system_context(cacerts: [])
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'verifies peer' do
|
123
|
+
sslctx = subject.create_system_context(cacerts: [])
|
124
|
+
expect(sslctx.verify_peer).to eq(true)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'disable revocation' do
|
128
|
+
sslctx = subject.create_system_context(cacerts: [])
|
129
|
+
expect(sslctx.revocation).to eq(false)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'sets client cert and private key to nil' do
|
133
|
+
sslctx = subject.create_system_context(cacerts: [])
|
134
|
+
expect(sslctx.client_cert).to be_nil
|
135
|
+
expect(sslctx.private_key).to be_nil
|
136
|
+
end
|
76
137
|
end
|
77
138
|
|
78
139
|
context 'when creating an ssl context with crls' do
|
@@ -99,6 +160,11 @@ describe Puppet::SSL::SSLProvider do
|
|
99
160
|
sslctx = subject.create_root_context(config.merge(crls: expired))
|
100
161
|
expect(sslctx.crls).to eq(expired)
|
101
162
|
end
|
163
|
+
|
164
|
+
it 'verifies peer' do
|
165
|
+
sslctx = subject.create_root_context(config)
|
166
|
+
expect(sslctx.verify_peer).to eq(true)
|
167
|
+
end
|
102
168
|
end
|
103
169
|
|
104
170
|
context 'when creating an ssl context with client certs' do
|
@@ -345,6 +411,11 @@ describe Puppet::SSL::SSLProvider do
|
|
345
411
|
sslctx.verify_peer = false
|
346
412
|
}.to raise_error(/can't modify frozen/)
|
347
413
|
end
|
414
|
+
|
415
|
+
it 'verifies peer' do
|
416
|
+
sslctx = subject.create_context(config)
|
417
|
+
expect(sslctx.verify_peer).to eq(true)
|
418
|
+
end
|
348
419
|
end
|
349
420
|
|
350
421
|
context 'when loading an ssl context' do
|
@@ -197,7 +197,7 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
context 'when locking' do
|
200
|
-
let(:lockfile) {
|
200
|
+
let(:lockfile) { Puppet::Util::Pidlock.new(Puppet[:ssl_lockfile]) }
|
201
201
|
let(:machine) { described_class.new(cert_provider: cert_provider, ssl_provider: ssl_provider, lockfile: lockfile) }
|
202
202
|
|
203
203
|
# lockfile is deleted before `ensure_ca_certificates` returns, so
|
@@ -210,7 +210,7 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'locks the file prior to running the state machine and unlocks when done' do
|
213
|
-
expect(lockfile).to receive(:lock).
|
213
|
+
expect(lockfile).to receive(:lock).and_call_original.ordered
|
214
214
|
expect(cert_provider).to receive(:load_cacerts).and_return(cacerts).ordered
|
215
215
|
expect(cert_provider).to receive(:load_crls).and_return(crls).ordered
|
216
216
|
expect(lockfile).to receive(:unlock).ordered
|
@@ -228,13 +228,6 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
228
228
|
expect(File).to_not be_exist(Puppet[:ssl_lockfile])
|
229
229
|
end
|
230
230
|
|
231
|
-
it 'raises an exception when locking fails' do
|
232
|
-
allow(lockfile).to receive(:lock).and_return(false)
|
233
|
-
expect {
|
234
|
-
machine.ensure_ca_certificates
|
235
|
-
}.to raise_error(Puppet::Error, /Another puppet instance is already running; exiting/)
|
236
|
-
end
|
237
|
-
|
238
231
|
it 'acquires an empty lockfile' do
|
239
232
|
Puppet::FileSystem.touch(Puppet[:ssl_lockfile])
|
240
233
|
|
@@ -262,6 +255,57 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
262
255
|
machine = described_class.new(cert_provider: cert_provider, ssl_provider: ssl_provider)
|
263
256
|
machine.ensure_ca_certificates
|
264
257
|
end
|
258
|
+
|
259
|
+
context 'and another puppet process is running' do
|
260
|
+
let(:now) { Time.now }
|
261
|
+
let(:future) { now + (5 * 60)} # 5 mins in the future
|
262
|
+
|
263
|
+
before :each do
|
264
|
+
allow(lockfile).to receive(:lock).and_return(false)
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'raises a puppet exception' do
|
268
|
+
expect {
|
269
|
+
machine.ensure_ca_certificates
|
270
|
+
}.to raise_error(Puppet::Error, /Another puppet instance is already running and the waitforlock setting is set to 0; exiting/)
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'sleeps and retries successfully' do
|
274
|
+
machine = described_class.new(lockfile: lockfile, cert_provider: cert_provider, waitforlock: 1, maxwaitforlock: 10)
|
275
|
+
allow(cert_provider).to receive(:load_cacerts).and_return(cacerts)
|
276
|
+
allow(cert_provider).to receive(:load_crls).and_return(crls)
|
277
|
+
allow(Time).to receive(:now).and_return(now, future)
|
278
|
+
|
279
|
+
expect(Kernel).to receive(:sleep).with(1)
|
280
|
+
expect(Puppet).to receive(:info).with("Another puppet instance is already running; waiting for it to finish")
|
281
|
+
expect(Puppet).to receive(:info).with("Will try again in 1 seconds.")
|
282
|
+
|
283
|
+
allow(lockfile).to receive(:lock).and_return(false, true)
|
284
|
+
|
285
|
+
expect(machine.ensure_ca_certificates).to be_an_instance_of(Puppet::SSL::SSLContext)
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'sleeps and retries unsuccessfully until the deadline is exceeded' do
|
289
|
+
machine = described_class.new(lockfile: lockfile, waitforlock: 1, maxwaitforlock: 10)
|
290
|
+
allow(Time).to receive(:now).and_return(now, future)
|
291
|
+
|
292
|
+
expect(Kernel).to receive(:sleep).with(1)
|
293
|
+
expect(Puppet).to receive(:info).with("Another puppet instance is already running; waiting for it to finish")
|
294
|
+
expect(Puppet).to receive(:info).with("Will try again in 1 seconds.")
|
295
|
+
|
296
|
+
allow(lockfile).to receive(:lock).and_return(false)
|
297
|
+
expect {
|
298
|
+
machine.ensure_ca_certificates
|
299
|
+
}.to raise_error(Puppet::Error, /Another puppet instance is already running and the maxwaitforlock timeout has been exceeded; exiting/)
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'defaults the waitlock deadline to 60 seconds' do
|
303
|
+
allow(Time).to receive(:now).and_return(now)
|
304
|
+
|
305
|
+
machine = described_class.new
|
306
|
+
expect(machine.waitlock_deadline).to eq(now.to_i + 60)
|
307
|
+
end
|
308
|
+
end
|
265
309
|
end
|
266
310
|
|
267
311
|
context 'NeedCACerts' do
|
@@ -837,7 +881,7 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
837
881
|
}.to output(/Exiting now because the waitforcert setting is set to 0./).to_stdout
|
838
882
|
end
|
839
883
|
|
840
|
-
it 'sleeps and transitions to
|
884
|
+
it 'sleeps and transitions to NeedLock' do
|
841
885
|
machine = described_class.new(waitforcert: 15)
|
842
886
|
|
843
887
|
state = Puppet::SSL::StateMachine::Wait.new(machine)
|
@@ -845,10 +889,10 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
845
889
|
|
846
890
|
expect(Puppet).to receive(:info).with(/Will try again in 15 seconds./)
|
847
891
|
|
848
|
-
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::
|
892
|
+
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::NeedLock)
|
849
893
|
end
|
850
894
|
|
851
|
-
it 'sleeps and transitions to
|
895
|
+
it 'sleeps and transitions to NeedLock when maxwaitforcert is set' do
|
852
896
|
machine = described_class.new(waitforcert: 15, maxwaitforcert: 30)
|
853
897
|
|
854
898
|
state = Puppet::SSL::StateMachine::Wait.new(machine)
|
@@ -856,7 +900,7 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
856
900
|
|
857
901
|
expect(Puppet).to receive(:info).with(/Will try again in 15 seconds./)
|
858
902
|
|
859
|
-
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::
|
903
|
+
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::NeedLock)
|
860
904
|
end
|
861
905
|
|
862
906
|
it 'waits indefinitely by default' do
|
@@ -877,6 +921,48 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
|
|
877
921
|
}.to exit_with(1)
|
878
922
|
}.to output(/Couldn't fetch certificate from CA server; you might still need to sign this agent's certificate \(.*\). Exiting now because the maxwaitforcert timeout has been exceeded./).to_stdout
|
879
923
|
end
|
924
|
+
|
925
|
+
it 'closes the pool before sleeping' do
|
926
|
+
machine = described_class.new(waitforcert: 15)
|
927
|
+
|
928
|
+
state = Puppet::SSL::StateMachine::Wait.new(machine)
|
929
|
+
expect(Puppet.runtime[:http].pool).to receive(:close).and_call_original
|
930
|
+
expect(Kernel).to receive(:sleep).with(15).ordered
|
931
|
+
|
932
|
+
state.next_state
|
933
|
+
end
|
934
|
+
|
935
|
+
it 'releases the lock while sleeping' do
|
936
|
+
lockfile = Puppet::Util::Pidlock.new(Puppet[:ssl_lockfile])
|
937
|
+
machine = described_class.new(lockfile: lockfile)
|
938
|
+
state = Puppet::SSL::StateMachine::Wait.new(machine)
|
939
|
+
|
940
|
+
# pidlock should be unlocked while sleeping
|
941
|
+
allow(Kernel).to receive(:sleep) do
|
942
|
+
expect(lockfile).to_not be_locked
|
943
|
+
end
|
944
|
+
|
945
|
+
# lock before running the state
|
946
|
+
lockfile.lock
|
947
|
+
state.next_state
|
948
|
+
end
|
949
|
+
end
|
950
|
+
|
951
|
+
context 'in state NeedLock' do
|
952
|
+
let(:ssl_context) { Puppet::SSL::SSLContext.new(cacerts: []) }
|
953
|
+
let(:lockfile) { Puppet::Util::Pidlock.new(Puppet[:ssl_lockfile]) }
|
954
|
+
let(:machine) { described_class.new(lockfile: lockfile) }
|
955
|
+
let(:state) { Puppet::SSL::StateMachine::NeedLock.new(machine) }
|
956
|
+
|
957
|
+
it 'acquires the lock and transitions to NeedCACerts' do
|
958
|
+
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::NeedCACerts)
|
959
|
+
expect(lockfile).to be_locked
|
960
|
+
end
|
961
|
+
|
962
|
+
it 'transitions to LockFailure if it fails to acquire the lock' do
|
963
|
+
expect(lockfile).to receive(:lock).and_return(false)
|
964
|
+
expect(state.next_state).to be_an_instance_of(Puppet::SSL::StateMachine::LockFailure)
|
965
|
+
end
|
880
966
|
end
|
881
967
|
end
|
882
968
|
end
|
@@ -146,16 +146,7 @@ describe Puppet::Transaction::Persistence do
|
|
146
146
|
Dir.mkdir(Puppet[:transactionstorefile])
|
147
147
|
persistence = Puppet::Transaction::Persistence.new
|
148
148
|
|
149
|
-
|
150
|
-
expect do
|
151
|
-
persistence.save
|
152
|
-
end.to raise_error do |error|
|
153
|
-
expect(error).to be_a(Puppet::Util::Windows::Error)
|
154
|
-
expect(error.code).to eq(5) # ERROR_ACCESS_DENIED
|
155
|
-
end
|
156
|
-
else
|
157
|
-
expect { persistence.save }.to raise_error(Errno::EISDIR, /Is a directory/)
|
158
|
-
end
|
149
|
+
expect { persistence.save }.to raise_error(Errno::EISDIR, /Is a directory/)
|
159
150
|
|
160
151
|
Dir.rmdir(Puppet[:transactionstorefile])
|
161
152
|
end
|
@@ -39,6 +39,10 @@ describe Puppet::Transaction::Report do
|
|
39
39
|
expect(Puppet::Transaction::Report.new('cv', 'env', 'tid', 'some job id').job_id).to eq('some job id')
|
40
40
|
end
|
41
41
|
|
42
|
+
it "should take a 'start_time' as an argument" do
|
43
|
+
expect(Puppet::Transaction::Report.new('cv', 'env', 'tid', 'some job id', 'my start time').time).to eq('my start time')
|
44
|
+
end
|
45
|
+
|
42
46
|
it "should be able to set configuration_version" do
|
43
47
|
report = Puppet::Transaction::Report.new
|
44
48
|
report.configuration_version = "some version"
|
@@ -3,7 +3,6 @@ require 'matchers/include_in_order'
|
|
3
3
|
require 'puppet_spec/compiler'
|
4
4
|
|
5
5
|
require 'puppet/transaction'
|
6
|
-
require 'puppet/type/notify'
|
7
6
|
require 'fileutils'
|
8
7
|
|
9
8
|
describe Puppet::Transaction do
|
@@ -967,6 +966,51 @@ describe Puppet::Transaction do
|
|
967
966
|
expect(times_send_log_with_skipping_called).to eq(3)
|
968
967
|
end
|
969
968
|
end
|
969
|
+
|
970
|
+
describe "failed dependency is depended on multiple times" do
|
971
|
+
it "notifies and warns the failed class dependency once" do
|
972
|
+
Puppet.settings[:merge_dependency_warnings] = true
|
973
|
+
|
974
|
+
command_string = File.expand_path('/my/command')
|
975
|
+
allow(Puppet::Util::Execution).to receive(:execute).with([command_string]).and_raise(Puppet::ExecutionFailure, "Failed")
|
976
|
+
|
977
|
+
# Exec['exec1'] is outside of a class, so it's warning is not subject to being coalesced.
|
978
|
+
times_send_log_with_skipping_called = 0
|
979
|
+
allow_any_instance_of(Puppet::Type::Exec).to receive(:send_log) {times_send_log_with_skipping_called += 1; nil}.with(:warning, "Skipping because of failed dependencies")
|
980
|
+
|
981
|
+
# Class['declared_class'] depends upon Class['required_class'] which contains a resource with a failure.
|
982
|
+
times_send_log_with_class_dependency_called = 0
|
983
|
+
allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_dependency_called += 1; nil}.with(:notice, "Class dependency Exec[exec2] has failures: true")
|
984
|
+
times_send_log_with_class_skipping_called = 0
|
985
|
+
allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_skipping_called += 1; nil}.with(:warning, "Skipping resources in class because of failed class dependencies")
|
986
|
+
|
987
|
+
apply_compiled_manifest(<<-MANIFEST)
|
988
|
+
class required_class {
|
989
|
+
exec { 'exec2':
|
990
|
+
command => '#{command_string}'
|
991
|
+
}
|
992
|
+
}
|
993
|
+
class declared_class {
|
994
|
+
require required_class
|
995
|
+
exec { 'exec3':
|
996
|
+
command => '#{command_string}'
|
997
|
+
}
|
998
|
+
exec { 'exec4':
|
999
|
+
command => '#{command_string}'
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
exec { 'exec1':
|
1003
|
+
command => '#{command_string}',
|
1004
|
+
require => Exec['exec2']
|
1005
|
+
}
|
1006
|
+
include declared_class
|
1007
|
+
MANIFEST
|
1008
|
+
|
1009
|
+
expect(times_send_log_with_skipping_called).to eq(1)
|
1010
|
+
expect(times_send_log_with_class_dependency_called).to eq(1)
|
1011
|
+
expect(times_send_log_with_class_skipping_called).to eq(1)
|
1012
|
+
end
|
1013
|
+
end
|
970
1014
|
end
|
971
1015
|
|
972
1016
|
describe Puppet::Transaction, " when determining tags" do
|
@@ -200,15 +200,21 @@ describe Puppet::Type.type(:file).attrclass(:content), :uses_checksums => true d
|
|
200
200
|
end
|
201
201
|
|
202
202
|
it "prints the diff" do
|
203
|
-
expect(content).to receive(:diff).and_return("my diff")
|
204
|
-
expect(content).to receive(:debug).with("\nmy diff")
|
203
|
+
expect(content).to receive(:diff).and_return("my diff")
|
204
|
+
expect(content).to receive(:debug).with("\nmy diff")
|
205
|
+
expect(content).not_to be_safe_insync("other content")
|
206
|
+
end
|
207
|
+
|
208
|
+
it "prints binary file notice if diff is not valid encoding" do
|
209
|
+
expect(content).to receive(:diff).and_return("\xc7\xd1\xfc\x84")
|
210
|
+
expect(content).to receive(:debug).with(/\nBinary files #{filename} and .* differ/)
|
205
211
|
expect(content).not_to be_safe_insync("other content")
|
206
212
|
end
|
207
213
|
|
208
214
|
it "redacts the diff when the property is sensitive" do
|
209
215
|
content.sensitive = true
|
210
216
|
expect(content).not_to receive(:diff)
|
211
|
-
expect(content).to receive(:debug).with("[diff redacted]")
|
217
|
+
expect(content).to receive(:debug).with("[diff redacted]")
|
212
218
|
expect(content).not_to be_safe_insync("other content")
|
213
219
|
end
|
214
220
|
end
|
@@ -533,20 +533,54 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
|
|
533
533
|
describe "when writing" do
|
534
534
|
describe "as puppet apply" do
|
535
535
|
let(:source_content) { "source file content\r\n"*10 }
|
536
|
+
let(:modulepath) { File.join(Puppet[:environmentpath], 'testing', 'modules') }
|
537
|
+
let(:env) { Puppet::Node::Environment.create(:testing, [modulepath]) }
|
538
|
+
let(:catalog) { Puppet::Resource::Catalog.new(:test, env) }
|
539
|
+
|
536
540
|
before do
|
537
541
|
Puppet[:default_file_terminus] = "file_server"
|
538
|
-
resource[:source] = file_containing('apply', source_content)
|
539
542
|
end
|
540
543
|
|
541
544
|
it "should copy content from the source to the file" do
|
545
|
+
resource = Puppet::Type.type(:file).new(path: filename, catalog: catalog, source: file_containing('apply', source_content))
|
542
546
|
source = resource.parameter(:source)
|
543
547
|
resource.write(source)
|
544
548
|
|
545
549
|
expect(Puppet::FileSystem.binread(filename)).to eq(source_content)
|
546
550
|
end
|
547
551
|
|
552
|
+
it 'should use the in-process fileserver if source starts with puppet:///' do
|
553
|
+
path = File.join(modulepath, 'mymodule', 'files', 'path')
|
554
|
+
Puppet::FileSystem.dir_mkpath(path)
|
555
|
+
File.open(path, 'wb') { |f| f.write(source_content) }
|
556
|
+
resource = Puppet::Type.type(:file).new(path: filename, catalog: catalog, source: 'puppet:///modules/mymodule/path')
|
557
|
+
|
558
|
+
source = resource.parameter(:source)
|
559
|
+
resource.write(source)
|
560
|
+
|
561
|
+
expect(Puppet::FileSystem.binread(filename)).to eq(source_content)
|
562
|
+
end
|
563
|
+
|
564
|
+
it 'follows symlinks when retrieving content from the in-process fileserver' do
|
565
|
+
# create a 'link' that points to 'target' in the 'mymodule' module
|
566
|
+
link = File.join(modulepath, 'mymodule', 'files', 'link')
|
567
|
+
target = File.join(modulepath, 'mymodule', 'files', 'target')
|
568
|
+
Puppet::FileSystem.dir_mkpath(target)
|
569
|
+
File.open(target, 'wb') { |f| f.write(source_content) }
|
570
|
+
Puppet::FileSystem.symlink(target, link)
|
571
|
+
resource = Puppet::Type.type(:file).new(path: filename, catalog: catalog, source: 'puppet:///modules/mymodule/link')
|
572
|
+
|
573
|
+
source = resource.parameter(:source)
|
574
|
+
resource.write(source)
|
575
|
+
|
576
|
+
# 'filename' should be a file containing the contents of the followed link
|
577
|
+
expect(Puppet::FileSystem.binread(filename)).to eq(source_content)
|
578
|
+
end
|
579
|
+
|
548
580
|
with_digest_algorithms do
|
549
581
|
it "should return the checksum computed" do
|
582
|
+
resource = Puppet::Type.type(:file).new(path: filename, catalog: catalog, source: file_containing('apply', source_content))
|
583
|
+
|
550
584
|
File.open(filename, 'wb') do |file|
|
551
585
|
source = resource.parameter(:source)
|
552
586
|
resource[:checksum] = digest_algorithm
|
@@ -583,53 +617,73 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
|
|
583
617
|
|
584
618
|
describe 'from remote source' do
|
585
619
|
let(:source_content) { "source file content\n"*10 }
|
586
|
-
let(:source) {
|
587
|
-
|
588
|
-
|
620
|
+
let(:source) {
|
621
|
+
attr = resource.newattr(:source)
|
622
|
+
attr.metadata = metadata
|
623
|
+
attr
|
624
|
+
}
|
625
|
+
let(:metadata) {
|
626
|
+
Puppet::FileServing::Metadata.new(
|
627
|
+
'/modules/:module/foo',
|
628
|
+
{
|
629
|
+
'type' => 'file',
|
630
|
+
'source' => 'puppet:///modules/:module/foo'
|
631
|
+
}
|
632
|
+
)
|
633
|
+
}
|
589
634
|
|
590
635
|
before do
|
591
636
|
resource[:backup] = false
|
592
|
-
|
593
|
-
expectation = receive(:read_body)
|
594
|
-
source_content.lines.each { |line| expectation = expectation.and_yield(line) }
|
595
|
-
allow(response).to expectation
|
596
|
-
allow(conn).to receive(:request_get).and_yield(response)
|
597
637
|
end
|
598
638
|
|
599
639
|
it 'should use an explicit fileserver if source starts with puppet://' do
|
600
|
-
|
601
|
-
|
602
|
-
|
640
|
+
metadata.source = "puppet://somehostname:8140/modules/:module/foo"
|
641
|
+
|
642
|
+
stub_request(:get, %r{https://somehostname:8140/puppet/v3/file_content/modules/:module/foo})
|
643
|
+
.to_return(status: 200, body: metadata.to_json, headers: { 'Content-Type' => 'application/json' })
|
603
644
|
|
604
645
|
resource.write(source)
|
605
646
|
end
|
606
647
|
|
607
648
|
it 'should use the default fileserver if source starts with puppet:///' do
|
608
|
-
|
609
|
-
|
610
|
-
expect(Puppet::Network::HttpPool).to receive(:connection).with(Puppet[:server], 8140, anything).and_return(conn)
|
649
|
+
stub_request(:get, %r{https://#{Puppet[:server]}:8140/puppet/v3/file_content/modules/:module/foo})
|
650
|
+
.to_return(status: 200, body: metadata.to_json, headers: { 'Content-Type' => 'application/json' })
|
611
651
|
|
612
652
|
resource.write(source)
|
613
653
|
end
|
614
654
|
|
615
655
|
it 'should percent encode reserved characters' do
|
616
|
-
|
617
|
-
allow(Puppet::Network::HttpPool).to receive(:connection).and_return(conn)
|
618
|
-
allow(source).to receive(:metadata).and_return(double('metadata', :source => 'puppet:///test/foo bar', :ftype => 'file', :content_uri => nil))
|
656
|
+
metadata.source = 'puppet:///modules/:module/foo bar'
|
619
657
|
|
620
|
-
|
658
|
+
stub_request(:get, %r{/puppet/v3/file_content/modules/:module/foo%20bar})
|
659
|
+
.to_return(status: 200, body: metadata.to_json, headers: { 'Content-Type' => 'application/json' })
|
621
660
|
|
622
661
|
resource.write(source)
|
623
662
|
end
|
624
663
|
|
625
664
|
it 'should request binary content' do
|
626
|
-
|
627
|
-
|
628
|
-
|
665
|
+
stub_request(:get, %r{/puppet/v3/file_content/modules/:module/foo}) do |request|
|
666
|
+
expect(request.headers).to include({'Accept' => 'application/octet-stream'})
|
667
|
+
end.to_return(status: 200, body: '', headers: { 'Content-Type' => 'application/octet-stream' })
|
629
668
|
|
630
|
-
|
631
|
-
|
632
|
-
|
669
|
+
resource.write(source)
|
670
|
+
end
|
671
|
+
|
672
|
+
it "should request file content from the catalog's environment" do
|
673
|
+
Puppet[:environment] = 'doesntexist'
|
674
|
+
|
675
|
+
stub_request(:get, %r{/puppet/v3/file_content})
|
676
|
+
.with(query: hash_including("environment" => "myenv"))
|
677
|
+
.to_return(status: 200, body: '', headers: { 'Content-Type' => 'application/octet-stream' })
|
678
|
+
|
679
|
+
resource.write(source)
|
680
|
+
end
|
681
|
+
|
682
|
+
it 'should request static file content' do
|
683
|
+
metadata.content_uri = "puppet://#{Puppet[:server]}:8140/path/to/file"
|
684
|
+
|
685
|
+
stub_request(:get, %r{/puppet/v3/static_file_content/path/to/file})
|
686
|
+
.to_return(status: 200, body: '', headers: { 'Content-Type' => 'application/octet-stream' })
|
633
687
|
|
634
688
|
resource.write(source)
|
635
689
|
end
|
@@ -639,26 +693,23 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
|
|
639
693
|
File.open(filename, 'w') {|f| f.write "initial file content"}
|
640
694
|
end
|
641
695
|
|
642
|
-
before(:each) do
|
643
|
-
allow(Puppet::Network::HttpPool).to receive(:connection).and_return(conn)
|
644
|
-
allow(source).to receive(:metadata).and_return(double('metadata', :source => 'puppet:///test/foo', :ftype => 'file', :content_uri => nil))
|
645
|
-
end
|
646
|
-
|
647
696
|
it 'should not write anything if source is not found' do
|
648
|
-
|
697
|
+
stub_request(:get, %r{/puppet/v3/file_content/modules/:module/foo}).to_return(status: 404)
|
649
698
|
|
650
|
-
expect { resource.write(source) }.to raise_error(Net::HTTPError, /404
|
699
|
+
expect { resource.write(source) }.to raise_error(Net::HTTPError, /Error 404 on SERVER:/)
|
651
700
|
expect(File.read(filename)).to eq('initial file content')
|
652
701
|
end
|
653
702
|
|
654
703
|
it 'should raise an HTTP error in case of server error' do
|
655
|
-
|
704
|
+
stub_request(:get, %r{/puppet/v3/file_content/modules/:module/foo}).to_return(status: 500)
|
656
705
|
|
657
|
-
expect { resource.write(source) }.to raise_error(Net::HTTPError, /500/)
|
706
|
+
expect { resource.write(source) }.to raise_error(Net::HTTPError, /Error 500 on SERVER/)
|
658
707
|
end
|
659
708
|
|
660
709
|
context 'and the request was successful' do
|
661
|
-
before
|
710
|
+
before do
|
711
|
+
stub_request(:get, %r{/puppet/v3/file_content/modules/:module/foo}).to_return(status: 200, body: source_content)
|
712
|
+
end
|
662
713
|
|
663
714
|
it 'should write the contents to the file' do
|
664
715
|
resource.write(source)
|