puppet 6.11.1-x64-mingw32 → 6.16.0-x64-mingw32
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
@@ -211,4 +211,21 @@ describe "puppet module search" do
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|
214
|
+
|
215
|
+
it "should include a deprecation warning" do
|
216
|
+
stub_request(:get, "https://forgeapi.puppet.com/v3/modules?query=puppetlabs-apache").to_return(status: 200, body: [answers: [], result: :success])
|
217
|
+
|
218
|
+
subject.search("puppetlabs-apache")
|
219
|
+
|
220
|
+
expect(@logs).to include(an_object_having_attributes(level: :warning, message: /This action has been deprecated. Please use the Puppet Forge to search for modules./))
|
221
|
+
end
|
222
|
+
|
223
|
+
it "omits the warning when deprecations are disabled" do
|
224
|
+
stub_request(:get, "https://forgeapi.puppet.com/v3/modules?query=puppetlabs-apache").to_return(status: 200, body: [answers: [], result: :success])
|
225
|
+
|
226
|
+
Puppet[:disable_warnings] = 'deprecations'
|
227
|
+
subject.search("puppetlabs-apache")
|
228
|
+
|
229
|
+
expect(@logs).not_to include(an_object_having_attributes(level: :warning))
|
230
|
+
end
|
214
231
|
end
|
@@ -10,9 +10,10 @@ describe Puppet::Face[:plugin, :current] do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context "download" do
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
around do |example|
|
14
|
+
Puppet.override(server_agent_version: "5.3.4") do
|
15
|
+
example.run
|
16
|
+
end
|
16
17
|
end
|
17
18
|
|
18
19
|
it "downloads plugins, external facts, and locales" do
|
@@ -61,9 +62,10 @@ describe Puppet::Face[:plugin, :current] do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
context "download when server_agent_version is 5.3.3" do
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
around do |example|
|
66
|
+
Puppet.override(server_agent_version: "5.3.3") do
|
67
|
+
example.run
|
68
|
+
end
|
67
69
|
end
|
68
70
|
|
69
71
|
it "downloads plugins, and external facts, but not locales" do
|
@@ -87,10 +89,10 @@ describe Puppet::Face[:plugin, :current] do
|
|
87
89
|
end
|
88
90
|
|
89
91
|
context "download when server_agent_version is blank" do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
around do |example|
|
93
|
+
Puppet.override(server_agent_version: "") do
|
94
|
+
example.run
|
95
|
+
end
|
94
96
|
end
|
95
97
|
|
96
98
|
it "downloads plugins, and external facts, but not locales" do
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Puppet::FileSystem::Uniquefile do
|
4
|
+
include PuppetSpec::Files
|
5
|
+
|
4
6
|
it "makes the name of the file available" do
|
5
7
|
Puppet::FileSystem::Uniquefile.open_tmp('foo') do |file|
|
6
8
|
expect(file.path).to match(/foo/)
|
@@ -73,6 +75,15 @@ describe Puppet::FileSystem::Uniquefile do
|
|
73
75
|
Puppet::FileSystem::Uniquefile.open_tmp('foo') { |tmp| }
|
74
76
|
end
|
75
77
|
|
78
|
+
it "reports when a parent directory does not exist" do
|
79
|
+
dir = tmpdir('uniquefile')
|
80
|
+
lock = File.join(dir, 'path', 'to', 'lock')
|
81
|
+
|
82
|
+
expect {
|
83
|
+
Puppet::FileSystem::Uniquefile.open_tmp(lock) { |tmp| }
|
84
|
+
}.to raise_error(Errno::ENOENT, %r{No such file or directory - A directory component in .* does not exist or is a dangling symbolic link})
|
85
|
+
end
|
86
|
+
|
76
87
|
context "Ruby 1.9.3 Tempfile tests" do
|
77
88
|
# the remaining tests in this file are ported directly from the ruby 1.9.3 source,
|
78
89
|
# since most of this file was ported from there
|
@@ -970,6 +970,16 @@ describe "Puppet::FileSystem" do
|
|
970
970
|
mode = Puppet::FileSystem.stat(dest).mode
|
971
971
|
expect(mode & 07777).to eq(0400)
|
972
972
|
end
|
973
|
+
|
974
|
+
it 'preserves file ownership' do
|
975
|
+
allow(Puppet::FileSystem).to receive(:lstat)
|
976
|
+
.with(Puppet::FileSystem.pathname(dest))
|
977
|
+
.and_return(double(uid: 1, gid: 2))
|
978
|
+
|
979
|
+
expect(FileUtils).to receive(:chown).with(1, 2, /#{dest}/)
|
980
|
+
|
981
|
+
Puppet::FileSystem.replace_file(dest, 0644) { |f| f.write(content) }
|
982
|
+
end
|
973
983
|
end
|
974
984
|
|
975
985
|
context 'on windows', if: Puppet::Util::Platform.windows? do
|
@@ -988,7 +998,7 @@ describe "Puppet::FileSystem" do
|
|
988
998
|
it 'rejects unsupported modes' do
|
989
999
|
expect {
|
990
1000
|
Puppet::FileSystem.replace_file(dest, 0755) { |_| }
|
991
|
-
}.to raise_error(ArgumentError, /Only modes 0644, 0640 and
|
1001
|
+
}.to raise_error(ArgumentError, /Only modes 0644, 0640, 0660, and 0440 are allowed/)
|
992
1002
|
end
|
993
1003
|
end
|
994
1004
|
end
|
@@ -1065,12 +1075,26 @@ describe "Puppet::FileSystem" do
|
|
1065
1075
|
end
|
1066
1076
|
end
|
1067
1077
|
|
1068
|
-
it 'applies
|
1078
|
+
it 'applies 0644 mode' do
|
1069
1079
|
Puppet::FileSystem.replace_file(dest, 0644) { |f| f.write(content) }
|
1070
1080
|
|
1071
1081
|
expects_public_file(dest)
|
1072
1082
|
end
|
1073
1083
|
|
1084
|
+
[0660, 0640, 0600, 0440].each do |mode|
|
1085
|
+
it "applies #{mode} mode" do
|
1086
|
+
Puppet::FileSystem.replace_file(dest, mode) { |f| f.write(content) }
|
1087
|
+
current_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name)
|
1088
|
+
sd = Puppet::Util::Windows::Security.get_security_descriptor(dest)
|
1089
|
+
|
1090
|
+
expect(sd.dacl).to contain_exactly(
|
1091
|
+
an_object_having_attributes(sid: Puppet::Util::Windows::SID::LocalSystem, mask: 0x1f01ff),
|
1092
|
+
an_object_having_attributes(sid: Puppet::Util::Windows::SID::BuiltinAdministrators, mask: 0x1f01ff),
|
1093
|
+
an_object_having_attributes(sid: current_sid, mask: 0x1f01ff),
|
1094
|
+
)
|
1095
|
+
end
|
1096
|
+
end
|
1097
|
+
|
1074
1098
|
it 'raises Errno::EACCES if access is denied' do
|
1075
1099
|
allow(Puppet::Util::Windows::Security).to receive(:get_security_descriptor).and_raise(Puppet::Util::Windows::Error.new('access denied', 5))
|
1076
1100
|
|
@@ -41,7 +41,7 @@ Could not connect to http://fake.com:1111
|
|
41
41
|
|
42
42
|
describe 'ResponseError' do
|
43
43
|
subject { Puppet::Forge::Errors::ResponseError }
|
44
|
-
let(:response) { double(:body => '{}', :code => '404', :
|
44
|
+
let(:response) { double(:body => '{}', :code => '404', :reason => "not found") }
|
45
45
|
|
46
46
|
context 'without message' do
|
47
47
|
let(:exception) { subject.new(:uri => 'http://fake.com:1111', :response => response, :input => 'user/module') }
|
@@ -10,9 +10,8 @@ describe Puppet::Forge do
|
|
10
10
|
ENV['HTTP_PROXY'] = nil
|
11
11
|
end
|
12
12
|
|
13
|
-
let(:host) { 'fake.com' }
|
14
|
-
let(:forge) { Puppet::Forge.new(
|
15
|
-
# creates a repository like Puppet::Forge::Repository.new('http://fake.com', USER_AGENT)
|
13
|
+
let(:host) { 'http://fake.com' }
|
14
|
+
let(:forge) { Puppet::Forge.new(host) }
|
16
15
|
|
17
16
|
# different UTF-8 widths
|
18
17
|
# 1-byte A
|
@@ -22,49 +21,37 @@ describe Puppet::Forge do
|
|
22
21
|
let (:mixed_utf8_query_param) { "foo + A\u06FF\u16A0\u{2070E}" } # Aۿᚠ
|
23
22
|
let (:mixed_utf8_query_param_encoded) { "foo%20%2B%20A%DB%BF%E1%9A%A0%F0%A0%9C%8E"}
|
24
23
|
let (:empty_json) { '{ "results": [], "pagination" : { "next" : null } }' }
|
25
|
-
let (:ok_response) { double('response', :code => '200', :body => empty_json) }
|
26
24
|
|
27
25
|
describe "making a" do
|
28
26
|
before :each do
|
29
|
-
|
27
|
+
Puppet[:http_proxy_host] = "proxy"
|
28
|
+
Puppet[:http_proxy_port] = 1234
|
30
29
|
end
|
31
30
|
|
32
31
|
context "search request" do
|
33
32
|
it "includes any defined module_groups, ensuring to only encode them once in the URI" do
|
34
33
|
Puppet[:module_groups] = 'base+pe'
|
35
|
-
|
36
|
-
|
37
|
-
performs_an_http_request(ok_response) do |http|
|
38
|
-
encoded_uri = "/v3/modules?query=#{mixed_utf8_query_param_encoded}&module_groups=base%20pe"
|
39
|
-
expect(http).to receive(:request).with(have_attributes(path: encoded_uri))
|
40
|
-
end
|
34
|
+
encoded_uri = "#{host}/v3/modules?query=#{mixed_utf8_query_param_encoded}&module_groups=base%20pe"
|
35
|
+
stub_request(:get, encoded_uri).to_return(status: 200, body: empty_json)
|
41
36
|
|
42
37
|
forge.search(mixed_utf8_query_param)
|
43
38
|
end
|
44
39
|
|
45
40
|
it "single encodes the search term in the URI" do
|
46
|
-
|
47
|
-
|
48
|
-
encoded_uri = "/v3/modules?query=#{mixed_utf8_query_param_encoded}"
|
49
|
-
expect(http).to receive(:request).with(have_attributes(path: encoded_uri))
|
50
|
-
end
|
41
|
+
encoded_uri = "#{host}/v3/modules?query=#{mixed_utf8_query_param_encoded}"
|
42
|
+
stub_request(:get, encoded_uri).to_return(status: 200, body: empty_json)
|
51
43
|
|
52
44
|
forge.search(mixed_utf8_query_param)
|
53
45
|
end
|
54
46
|
end
|
55
47
|
|
56
48
|
context "fetch request" do
|
57
|
-
|
58
49
|
it "includes any defined module_groups, ensuring to only encode them once in the URI" do
|
59
50
|
Puppet[:module_groups] = 'base+pe'
|
60
51
|
module_name = 'puppetlabs-acl'
|
61
52
|
exclusions = "readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at"
|
62
|
-
|
63
|
-
|
64
|
-
performs_an_http_request(ok_response) do |http|
|
65
|
-
encoded_uri = "/v3/releases?module=#{module_name}&sort_by=version&exclude_fields=#{exclusions}&module_groups=base%20pe"
|
66
|
-
expect(http).to receive(:request).with(have_attributes(path: encoded_uri))
|
67
|
-
end
|
53
|
+
encoded_uri = "#{host}/v3/releases?module=#{module_name}&sort_by=version&exclude_fields=#{exclusions}&module_groups=base%20pe"
|
54
|
+
stub_request(:get, encoded_uri).to_return(status: 200, body: empty_json)
|
68
55
|
|
69
56
|
forge.fetch(module_name)
|
70
57
|
end
|
@@ -72,40 +59,11 @@ describe Puppet::Forge do
|
|
72
59
|
it "single encodes the module name term in the URI" do
|
73
60
|
module_name = "puppetlabs-#{mixed_utf8_query_param}"
|
74
61
|
exclusions = "readme%2Cchangelog%2Clicense%2Curi%2Cmodule%2Ctags%2Csupported%2Cfile_size%2Cdownloads%2Ccreated_at%2Cupdated_at%2Cdeleted_at"
|
75
|
-
|
76
|
-
|
77
|
-
performs_an_http_request(ok_response) do |http|
|
78
|
-
encoded_uri = "/v3/releases?module=puppetlabs-#{mixed_utf8_query_param_encoded}&sort_by=version&exclude_fields=#{exclusions}"
|
79
|
-
expect(http).to receive(:request).with(have_attributes(path: encoded_uri))
|
80
|
-
end
|
62
|
+
encoded_uri = "#{host}/v3/releases?module=puppetlabs-#{mixed_utf8_query_param_encoded}&sort_by=version&exclude_fields=#{exclusions}"
|
63
|
+
stub_request(:get, encoded_uri).to_return(status: 200, body: empty_json)
|
81
64
|
|
82
65
|
forge.fetch(module_name)
|
83
66
|
end
|
84
67
|
end
|
85
|
-
|
86
|
-
def performs_an_http_request(result = nil, &block)
|
87
|
-
proxy_args = ["proxy", 1234, nil, nil]
|
88
|
-
mock_proxy(80, proxy_args, result, &block)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def proxy_settings_of(host, port)
|
93
|
-
Puppet[:http_proxy_host] = host
|
94
|
-
Puppet[:http_proxy_port] = port
|
95
|
-
end
|
96
|
-
|
97
|
-
def mock_proxy(port, proxy_args, result, &block)
|
98
|
-
http = double("http client")
|
99
|
-
proxy = double("http proxy")
|
100
|
-
|
101
|
-
expect(Net::HTTP).to receive(:new).with(host, port, *proxy_args).and_return(proxy)
|
102
|
-
|
103
|
-
expect(proxy).to receive(:open_timeout=)
|
104
|
-
expect(proxy).to receive(:read_timeout=)
|
105
|
-
|
106
|
-
expect(proxy).to receive(:start).and_yield(http).and_return(result)
|
107
|
-
yield http
|
108
|
-
|
109
|
-
proxy
|
110
68
|
end
|
111
69
|
end
|
@@ -3,8 +3,11 @@ require 'spec_helper'
|
|
3
3
|
require 'puppet/forge'
|
4
4
|
require 'net/http'
|
5
5
|
require 'puppet/module_tool'
|
6
|
+
require 'puppet_spec/files'
|
6
7
|
|
7
8
|
describe Puppet::Forge::ModuleRelease do
|
9
|
+
include PuppetSpec::Files
|
10
|
+
|
8
11
|
let(:agent) { "Test/1.0" }
|
9
12
|
let(:repository) { Puppet::Forge::Repository.new('http://fake.com', agent) }
|
10
13
|
let(:ssl_repository) { Puppet::Forge::Repository.new('https://fake.com', agent) }
|
@@ -27,6 +30,8 @@ describe Puppet::Forge::ModuleRelease do
|
|
27
30
|
|
28
31
|
let(:mock_dir) { '/tmp' }
|
29
32
|
|
33
|
+
let(:destination) { tmpfile('forge_module_release') }
|
34
|
+
|
30
35
|
shared_examples 'a module release' do
|
31
36
|
def mock_digest_file_with_md5(md5)
|
32
37
|
allow(Digest::MD5).to receive(:file).and_return(double(:hexdigest => md5))
|
@@ -40,16 +45,24 @@ describe Puppet::Forge::ModuleRelease do
|
|
40
45
|
end
|
41
46
|
|
42
47
|
describe '#download' do
|
43
|
-
it 'should
|
44
|
-
|
45
|
-
expect(ssl_repository).to receive(:make_http_request).with("/#{api_version}/files/#{module_full_name_versioned}.tar.gz", mock_file).and_return(double(:body => '{}', :code => '200'))
|
48
|
+
it 'should download a file' do
|
49
|
+
stub_request(:get, "https://fake.com/#{api_version}/files/#{module_full_name_versioned}.tar.gz").to_return(status: 200, body: '{}')
|
46
50
|
|
47
|
-
|
51
|
+
File.open(destination, 'wb') do |fh|
|
52
|
+
release.send(:download, "/#{api_version}/files/#{module_full_name_versioned}.tar.gz", fh)
|
53
|
+
end
|
54
|
+
|
55
|
+
expect(File.read(destination)).to eq("{}")
|
48
56
|
end
|
49
57
|
|
50
58
|
it 'should raise a response error when it receives an error from forge' do
|
51
|
-
|
52
|
-
|
59
|
+
stub_request(:get, "https://fake.com/some/path").to_return(
|
60
|
+
status: [500, 'server error'],
|
61
|
+
body: '{"error":"invalid module"}'
|
62
|
+
)
|
63
|
+
expect {
|
64
|
+
release.send(:download, "/some/path", StringIO.new)
|
65
|
+
}.to raise_error Puppet::Forge::Errors::ResponseError
|
53
66
|
end
|
54
67
|
end
|
55
68
|
|
@@ -13,7 +13,6 @@ describe Puppet::Forge::Repository do
|
|
13
13
|
end
|
14
14
|
let(:agent) { "Test/1.0" }
|
15
15
|
let(:repository) { Puppet::Forge::Repository.new('http://fake.com', agent) }
|
16
|
-
let(:ssl_repository) { Puppet::Forge::Repository.new('https://fake.com', agent) }
|
17
16
|
|
18
17
|
it "retrieve accesses the cache" do
|
19
18
|
path = '/module/foo.tar.gz'
|
@@ -34,215 +33,122 @@ describe Puppet::Forge::Repository do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
describe "making a request" do
|
37
|
-
|
38
|
-
proxy_settings_of("proxy", 1234)
|
39
|
-
end
|
36
|
+
let(:uri) { "http://fake.com/the_path" }
|
40
37
|
|
41
|
-
it "returns the
|
42
|
-
|
38
|
+
it "returns the response object from the request" do
|
39
|
+
stub_request(:get, uri)
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
41
|
+
expect(repository.make_http_request("/the_path")).to be_a_kind_of(Puppet::HTTP::Response)
|
42
|
+
end
|
47
43
|
|
48
|
-
|
44
|
+
it "requires path to have a leading slash" do
|
45
|
+
expect {
|
46
|
+
repository.make_http_request("the_path")
|
47
|
+
}.to raise_error(ArgumentError, 'Path must start with forward slash')
|
49
48
|
end
|
50
49
|
|
51
50
|
it "merges forge URI and path specified" do
|
52
|
-
|
53
|
-
|
54
|
-
performs_an_http_request result do |http|
|
55
|
-
expect(http).to receive(:request).with(have_attributes(path: "/test/the_path/"))
|
56
|
-
end
|
51
|
+
stub_request(:get, "http://fake.com/test/the_path/")
|
57
52
|
|
58
53
|
repository = Puppet::Forge::Repository.new('http://fake.com/test', agent)
|
59
|
-
|
54
|
+
repository.make_http_request("/the_path/")
|
60
55
|
end
|
61
56
|
|
62
57
|
it "handles trailing slashes when merging URI and path" do
|
63
|
-
|
64
|
-
|
65
|
-
performs_an_http_request result do |http|
|
66
|
-
expect(http).to receive(:request).with(have_attributes(path: "/test/the_path"))
|
67
|
-
end
|
58
|
+
stub_request(:get, "http://fake.com/test/the_path")
|
68
59
|
|
69
60
|
repository = Puppet::Forge::Repository.new('http://fake.com/test/', agent)
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'returns the result object from a request with ssl' do
|
74
|
-
result = "#{Object.new}"
|
75
|
-
performs_an_https_request result do |http|
|
76
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path"))
|
77
|
-
end
|
78
|
-
|
79
|
-
expect(ssl_repository.make_http_request("the_path")).to eq(result)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'return a valid exception when there is an SSL verification problem' do
|
83
|
-
performs_an_https_request "#{Object.new}" do |http|
|
84
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path")).and_raise(OpenSSL::SSL::SSLError.new("certificate verify failed"))
|
85
|
-
end
|
86
|
-
|
87
|
-
expect { ssl_repository.make_http_request("the_path") }.to raise_error Puppet::Forge::Errors::SSLVerifyError, 'Unable to verify the SSL certificate at https://fake.com'
|
61
|
+
repository.make_http_request("/the_path")
|
88
62
|
end
|
89
63
|
|
90
64
|
it 'return a valid exception when there is a communication problem' do
|
91
|
-
|
92
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path")).and_raise(SocketError)
|
93
|
-
end
|
65
|
+
stub_request(:get, uri).to_raise(SocketError.new('getaddrinfo: Name or service not known'))
|
94
66
|
|
95
|
-
expect {
|
96
|
-
|
97
|
-
|
67
|
+
expect {
|
68
|
+
repository.make_http_request("/the_path")
|
69
|
+
}.to raise_error(Puppet::Forge::Errors::CommunicationError,
|
70
|
+
%r{Unable to connect to the server at http://fake.com. Detail: Request to http://fake.com/the_path failed after .* seconds: getaddrinfo: Name or service not known.})
|
98
71
|
end
|
99
72
|
|
100
73
|
it "sets the user agent for the request" do
|
101
|
-
|
102
|
-
|
103
|
-
|
74
|
+
stub_request(:get, uri).with do |request|
|
75
|
+
expect(request.headers['User-Agent']).to match(/#{agent} #{Regexp.escape(Puppet[:http_user_agent])}/)
|
76
|
+
end
|
104
77
|
|
105
|
-
|
106
|
-
expect(request['User-Agent']).to match(/\bPuppet\b/)
|
107
|
-
expect(request['User-Agent']).to match(/\bRuby\b/)
|
78
|
+
repository.make_http_request("/the_path")
|
108
79
|
end
|
109
80
|
|
110
|
-
it "
|
81
|
+
it "does not set Authorization header by default" do
|
111
82
|
allow(Puppet.features).to receive(:pe_license?).and_return(false)
|
112
83
|
Puppet[:forge_authorization] = nil
|
113
|
-
request = repository.get_request_object("the_path")
|
114
|
-
expect(request['Authorization']).to eq(nil)
|
115
|
-
end
|
116
84
|
|
117
|
-
|
118
|
-
|
119
|
-
Puppet[:forge_authorization] = token
|
120
|
-
request = repository.get_request_object("the_path")
|
121
|
-
expect(request['Authorization']).to eq(token)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "encodes the received URI" do
|
125
|
-
unescaped_uri = "héllo world !! ç à"
|
126
|
-
performs_an_http_request do |http|
|
127
|
-
expect(http).to receive(:request).with(have_attributes(path: Puppet::Util.uri_encode(unescaped_uri)))
|
85
|
+
stub_request(:get, uri).with do |request|
|
86
|
+
expect(request.headers).to_not include('Authorization')
|
128
87
|
end
|
129
88
|
|
130
|
-
repository.make_http_request(
|
89
|
+
repository.make_http_request("/the_path")
|
131
90
|
end
|
132
91
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
92
|
+
it "sets Authorization header from config" do
|
93
|
+
token = 'bearer some token'
|
94
|
+
Puppet[:forge_authorization] = token
|
137
95
|
|
138
|
-
|
139
|
-
proxy_args = ["proxy", 1234, nil, nil]
|
140
|
-
proxy = mock_proxy(443, proxy_args, result, &block)
|
141
|
-
expect(proxy).to receive(:use_ssl=).with(true)
|
142
|
-
expect(proxy).to receive(:cert_store=)
|
143
|
-
expect(proxy).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
|
144
|
-
end
|
145
|
-
end
|
96
|
+
stub_request(:get, uri).with(headers: {'Authorization' => token})
|
146
97
|
|
147
|
-
|
148
|
-
before :each do
|
149
|
-
authenticated_proxy_settings_of("proxy", 1234, 'user1', 'password')
|
98
|
+
repository.make_http_request("/the_path")
|
150
99
|
end
|
151
100
|
|
152
|
-
it "
|
153
|
-
|
101
|
+
it "sets Authorization header from PE license" do
|
102
|
+
allow(Puppet.features).to receive(:pe_license?).and_return(true)
|
103
|
+
stub_const("PELicense", double(load_license_key: double(authorization_token: "opensesame")))
|
154
104
|
|
155
|
-
|
156
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path"))
|
157
|
-
end
|
105
|
+
stub_request(:get, uri).with(headers: {'Authorization' => "opensesame"})
|
158
106
|
|
159
|
-
|
107
|
+
repository.make_http_request("/the_path")
|
160
108
|
end
|
161
109
|
|
162
|
-
it
|
163
|
-
|
164
|
-
performs_an_authenticated_https_request result do |http|
|
165
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path"))
|
166
|
-
end
|
110
|
+
it "sets basic authentication if there isn't forge authorization or PE license" do
|
111
|
+
stub_request(:get, uri).with(basic_auth: ['user1', 'password'])
|
167
112
|
|
168
|
-
|
113
|
+
repository = Puppet::Forge::Repository.new('http://user1:password@fake.com', agent)
|
114
|
+
repository.make_http_request("/the_path")
|
169
115
|
end
|
170
116
|
|
171
|
-
it
|
172
|
-
|
173
|
-
|
174
|
-
|
117
|
+
it "omits basic authentication if there is a forge authorization" do
|
118
|
+
token = 'bearer some token'
|
119
|
+
Puppet[:forge_authorization] = token
|
120
|
+
stub_request(:get, uri).with(headers: {'Authorization' => token})
|
175
121
|
|
176
|
-
|
122
|
+
repository = Puppet::Forge::Repository.new('http://user1:password@fake.com', agent)
|
123
|
+
repository.make_http_request("/the_path")
|
177
124
|
end
|
178
125
|
|
179
|
-
it
|
180
|
-
|
181
|
-
expect(http).to receive(:request).with(have_attributes(path: "the_path")).and_raise(SocketError)
|
182
|
-
end
|
126
|
+
it "encodes the URI path" do
|
127
|
+
stub_request(:get, "http://fake.com/h%C3%A9llo%20world%20!!%20%C3%A7%20%C3%A0")
|
183
128
|
|
184
|
-
|
185
|
-
to raise_error Puppet::Forge::Errors::CommunicationError,
|
186
|
-
'Unable to connect to the server at http://fake.com. Detail: SocketError.'
|
129
|
+
repository.make_http_request("/héllo world !! ç à")
|
187
130
|
end
|
188
131
|
|
189
|
-
it "
|
190
|
-
|
132
|
+
it "connects via proxy" do
|
133
|
+
Puppet[:http_proxy_host] = 'proxy'
|
134
|
+
Puppet[:http_proxy_port] = 1234
|
191
135
|
|
192
|
-
|
136
|
+
stub_request(:get, uri)
|
137
|
+
expect(Net::HTTP).to receive(:new).with(anything, anything, 'proxy', 1234, nil, nil).and_call_original
|
193
138
|
|
194
|
-
|
195
|
-
expect(request['User-Agent']).to match(/\bPuppet\b/)
|
196
|
-
expect(request['User-Agent']).to match(/\bRuby\b/)
|
139
|
+
repository.make_http_request("/the_path")
|
197
140
|
end
|
198
141
|
|
199
|
-
it "
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
142
|
+
it "connects via authenticating proxy" do
|
143
|
+
Puppet[:http_proxy_host] = 'proxy'
|
144
|
+
Puppet[:http_proxy_port] = 1234
|
145
|
+
Puppet[:http_proxy_user] = 'user1'
|
146
|
+
Puppet[:http_proxy_password] = 'password'
|
204
147
|
|
205
|
-
|
206
|
-
|
148
|
+
stub_request(:get, uri)
|
149
|
+
expect(Net::HTTP).to receive(:new).with(anything, anything, 'proxy', 1234, "user1", "password").and_call_original
|
207
150
|
|
208
|
-
|
209
|
-
proxy_args = ["proxy", 1234, 'user1', 'password']
|
210
|
-
mock_proxy(80, proxy_args, result, &block)
|
151
|
+
repository.make_http_request("/the_path")
|
211
152
|
end
|
212
|
-
|
213
|
-
def performs_an_authenticated_https_request(result = nil, &block)
|
214
|
-
proxy_args = ["proxy", 1234, 'user1', 'password']
|
215
|
-
proxy = mock_proxy(443, proxy_args, result, &block)
|
216
|
-
expect(proxy).to receive(:use_ssl=).with(true)
|
217
|
-
expect(proxy).to receive(:cert_store=)
|
218
|
-
expect(proxy).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
def proxy_settings_of(host, port)
|
223
|
-
Puppet[:http_proxy_host] = host
|
224
|
-
Puppet[:http_proxy_port] = port
|
225
|
-
end
|
226
|
-
|
227
|
-
def authenticated_proxy_settings_of(host, port, user, password)
|
228
|
-
Puppet[:http_proxy_host] = host
|
229
|
-
Puppet[:http_proxy_port] = port
|
230
|
-
Puppet[:http_proxy_user] = user
|
231
|
-
Puppet[:http_proxy_password] = password
|
232
|
-
end
|
233
|
-
|
234
|
-
def mock_proxy(port, proxy_args, result, &block)
|
235
|
-
http = double("http client")
|
236
|
-
proxy = double("http proxy")
|
237
|
-
|
238
|
-
expect(Net::HTTP).to receive(:new).with("fake.com", port, *proxy_args).and_return(proxy)
|
239
|
-
|
240
|
-
expect(proxy).to receive(:open_timeout=)
|
241
|
-
expect(proxy).to receive(:read_timeout=)
|
242
|
-
|
243
|
-
expect(proxy).to receive(:start).and_yield(http).and_return(result)
|
244
|
-
yield http
|
245
|
-
|
246
|
-
proxy
|
247
153
|
end
|
248
154
|
end
|