puppet 6.4.5-universal-darwin → 6.5.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 +10 -10
- data/Gemfile +6 -6
- data/Gemfile.lock +46 -52
- data/ext/build_defaults.yaml +0 -1
- data/ext/project_data.yaml +3 -3
- data/ext/regexp_nodes/regexp_nodes.rb +4 -4
- data/ext/solaris/smf/puppet.xml +0 -2
- data/ext/windows/eventlog/Rakefile +32 -0
- data/ext/windows/eventlog/puppetres.dll +0 -0
- data/ext/windows/eventlog/puppetres.mc +18 -0
- data/ext/windows/service/daemon.rb +8 -38
- data/install.rb +24 -6
- data/lib/puppet.rb +3 -1
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +11 -34
- data/lib/puppet/application/apply.rb +6 -6
- data/lib/puppet/application/describe.rb +9 -3
- data/lib/puppet/application/device.rb +4 -14
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/lookup.rb +2 -2
- data/lib/puppet/application/resource.rb +4 -4
- data/lib/puppet/application/script.rb +2 -2
- data/lib/puppet/application/ssl.rb +10 -9
- data/lib/puppet/configurer.rb +30 -86
- data/lib/puppet/configurer/downloader.rb +6 -2
- data/lib/puppet/defaults.rb +50 -44
- data/lib/puppet/error.rb +14 -9
- data/lib/puppet/face/catalog.rb +20 -1
- data/lib/puppet/face/config.rb +48 -10
- data/lib/puppet/face/facts.rb +1 -1
- data/lib/puppet/face/help.rb +1 -1
- data/lib/puppet/face/module/list.rb +5 -5
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +1 -1
- data/lib/puppet/face/parser.rb +48 -9
- data/lib/puppet/face/plugin.rb +2 -9
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system.rb +12 -2
- data/lib/puppet/file_system/file_impl.rb +6 -3
- data/lib/puppet/file_system/memory_file.rb +1 -1
- data/lib/puppet/file_system/posix.rb +2 -3
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/functions.rb +2 -1
- data/lib/puppet/functions/camelcase.rb +2 -2
- data/lib/puppet/functions/epp.rb +4 -4
- data/lib/puppet/functions/find_file.rb +9 -9
- data/lib/puppet/functions/inline_epp.rb +5 -5
- data/lib/puppet/functions/regsubst.rb +6 -8
- data/lib/puppet/gettext/module_translations.rb +1 -1
- data/lib/puppet/graph/rb_tree_map.rb +2 -2
- data/lib/puppet/graph/simple_graph.rb +3 -4
- data/lib/puppet/indirector/catalog/compiler.rb +5 -11
- data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
- data/lib/puppet/indirector/hiera.rb +0 -2
- data/lib/puppet/indirector/resource/ral.rb +3 -1
- data/lib/puppet/indirector/resource/validator.rb +1 -1
- data/lib/puppet/interface.rb +1 -2
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/metatype/manager.rb +1 -1
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/module/task.rb +4 -20
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
- data/lib/puppet/module_tool/metadata.rb +1 -1
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
- data/lib/puppet/module_tool/tar/mini.rb +2 -12
- data/lib/puppet/network/http/api/indirected_routes.rb +11 -12
- data/lib/puppet/network/http/connection.rb +12 -10
- data/lib/puppet/network/http/factory.rb +11 -1
- data/lib/puppet/network/http/pool.rb +0 -2
- data/lib/puppet/network/http/site.rb +1 -1
- data/lib/puppet/network/resolver.rb +2 -2
- data/lib/puppet/node/environment.rb +2 -4
- data/lib/puppet/pal/pal_impl.rb +2 -2
- data/lib/puppet/parser/ast.rb +1 -1
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/functions.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +3 -3
- data/lib/puppet/parser/functions/fail.rb +8 -1
- data/lib/puppet/parser/functions/inline_epp.rb +5 -5
- data/lib/puppet/parser/scope.rb +7 -8
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +2 -3
- data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
- data/lib/puppet/pops/loader/null_loader.rb +60 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -4
- data/lib/puppet/pops/loader/task_instantiator.rb +0 -4
- data/lib/puppet/pops/loaders.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +0 -1
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/merge_strategy.rb +18 -22
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/pn_parser.rb +16 -17
- data/lib/puppet/pops/puppet_stack.rb +49 -51
- data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
- data/lib/puppet/pops/types/string_converter.rb +10 -10
- data/lib/puppet/pops/types/types.rb +6 -5
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/property/ensure.rb +1 -1
- data/lib/puppet/provider/exec.rb +2 -6
- data/lib/puppet/provider/file/posix.rb +0 -5
- data/lib/puppet/provider/nameservice.rb +3 -10
- data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
- data/lib/puppet/provider/nameservice/pw.rb +2 -2
- data/lib/puppet/provider/package.rb +0 -2
- data/lib/puppet/provider/package/apt.rb +1 -5
- data/lib/puppet/provider/package/dnf.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +18 -34
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +13 -37
- data/lib/puppet/provider/package/portage.rb +4 -4
- data/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +18 -56
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +5 -9
- data/lib/puppet/provider/package_targetable.rb +4 -7
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +9 -9
- data/lib/puppet/provider/service/launchd.rb +5 -20
- data/lib/puppet/provider/service/openbsd.rb +1 -1
- data/lib/puppet/provider/service/rcng.rb +2 -2
- data/lib/puppet/provider/service/runit.rb +8 -2
- data/lib/puppet/provider/service/systemd.rb +19 -14
- data/lib/puppet/provider/service/windows.rb +0 -8
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +3 -12
- data/lib/puppet/provider/user/user_role_add.rb +1 -5
- data/lib/puppet/provider/user/useradd.rb +20 -45
- data/lib/puppet/provider/user/windows_adsi.rb +5 -4
- data/lib/puppet/reference/configuration.rb +3 -3
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/metaparameter.rb +3 -1
- data/lib/puppet/reference/providers.rb +3 -1
- data/lib/puppet/reference/type.rb +9 -3
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +1 -18
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/rest/routes.rb +30 -17
- data/lib/puppet/settings.rb +3 -43
- data/lib/puppet/settings/environment_conf.rb +0 -1
- data/lib/puppet/ssl/certificate_request.rb +12 -2
- data/lib/puppet/ssl/host.rb +2 -2
- data/lib/puppet/ssl/oids.rb +1 -1
- data/lib/puppet/ssl/ssl_provider.rb +11 -5
- data/lib/puppet/ssl/state_machine.rb +102 -98
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/transaction.rb +11 -33
- data/lib/puppet/transaction/report.rb +1 -1
- data/lib/puppet/type.rb +4 -2
- data/lib/puppet/type/exec.rb +17 -23
- data/lib/puppet/type/file.rb +39 -11
- data/lib/puppet/type/file/data_sync.rb +1 -5
- data/lib/puppet/type/group.rb +2 -4
- data/lib/puppet/type/notify.rb +3 -4
- data/lib/puppet/type/package.rb +3 -20
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/service.rb +3 -8
- data/lib/puppet/type/user.rb +2 -4
- data/lib/puppet/util.rb +29 -39
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/execution.rb +3 -4
- data/lib/puppet/util/http_proxy.rb +19 -27
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/log/destinations.rb +2 -2
- data/lib/puppet/util/logging.rb +20 -32
- data/lib/puppet/util/metric.rb +2 -2
- data/lib/puppet/util/monkey_patches.rb +33 -0
- data/lib/puppet/util/pidlock.rb +2 -3
- data/lib/puppet/util/provider_features.rb +4 -2
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +2 -8
- data/lib/puppet/util/skip_tags.rb +4 -0
- data/lib/puppet/util/windows/adsi.rb +18 -48
- data/lib/puppet/util/windows/process.rb +8 -8
- data/lib/puppet/util/windows/registry.rb +5 -7
- data/lib/puppet/util/windows/security.rb +0 -2
- data/lib/puppet/util/windows/service.rb +4 -149
- data/lib/puppet/util/windows/sid.rb +0 -1
- data/lib/puppet/vendor.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet/x509/cert_provider.rb +81 -24
- data/locales/puppet.pot +462 -482
- data/man/man5/puppet.conf.5 +43 -44
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +3 -3
- data/man/man8/puppet-catalog.8 +31 -3
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- 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 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- 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 +1 -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 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +3 -3
- data/spec/fixtures/ssl/127.0.0.1-key.pem +56 -56
- data/spec/fixtures/ssl/127.0.0.1.pem +27 -27
- data/spec/fixtures/ssl/bad-basic-constraints.pem +32 -32
- data/spec/fixtures/ssl/bad-int-basic-constraints.pem +30 -30
- data/spec/fixtures/ssl/ca.pem +30 -30
- data/spec/fixtures/ssl/crl.pem +15 -15
- data/spec/fixtures/ssl/ec-key.pem +18 -0
- data/spec/fixtures/ssl/ec.pem +40 -0
- data/spec/fixtures/ssl/encrypted-ec-key.pem +21 -0
- data/spec/fixtures/ssl/encrypted-key.pem +57 -57
- data/spec/fixtures/ssl/intermediate-agent-crl.pem +16 -16
- data/spec/fixtures/ssl/intermediate-agent.pem +33 -33
- data/spec/fixtures/ssl/intermediate-crl.pem +17 -17
- data/spec/fixtures/ssl/intermediate.pem +31 -31
- data/spec/fixtures/ssl/pluto-key.pem +56 -56
- data/spec/fixtures/ssl/pluto.pem +28 -28
- data/spec/fixtures/ssl/request-key.pem +56 -56
- data/spec/fixtures/ssl/request.pem +24 -24
- data/spec/fixtures/ssl/revoked-key.pem +56 -56
- data/spec/fixtures/ssl/revoked.pem +25 -25
- data/spec/fixtures/ssl/signed-key.pem +56 -56
- data/spec/fixtures/ssl/signed.pem +25 -25
- data/spec/fixtures/ssl/tampered-cert.pem +27 -27
- data/spec/fixtures/ssl/tampered-csr.pem +24 -24
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/func_with_syntax_error.rb +9 -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/configurer_spec.rb +0 -52
- data/spec/integration/provider/service/init_spec.rb +1 -0
- data/spec/integration/provider/service/systemd_spec.rb +5 -8
- data/spec/integration/type/file_spec.rb +38 -28
- data/spec/integration/util/execution_spec.rb +0 -27
- data/spec/lib/puppet/certificate_factory.rb +2 -2
- data/spec/lib/puppet/test_ca.rb +17 -4
- data/spec/lib/puppet_spec/fixtures.rb +4 -0
- data/spec/spec_helper.rb +0 -28
- data/spec/unit/application/agent_spec.rb +34 -67
- data/spec/unit/application/device_spec.rb +1 -27
- data/spec/unit/application/ssl_spec.rb +60 -35
- data/spec/unit/configurer_spec.rb +399 -395
- data/spec/unit/defaults_spec.rb +4 -4
- data/spec/unit/face/facts_spec.rb +0 -9
- data/spec/unit/face/parser_spec.rb +69 -22
- data/spec/unit/face/plugin_spec.rb +0 -8
- data/spec/unit/file_system_spec.rb +30 -1
- data/spec/unit/forge/forge_spec.rb +3 -1
- data/spec/unit/forge/repository_spec.rb +3 -1
- data/spec/unit/indirector/catalog/compiler_spec.rb +5 -62
- data/spec/unit/indirector/resource/ral_spec.rb +4 -4
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/network/http/api/indirected_routes_spec.rb +10 -25
- data/spec/unit/network/http/connection_spec.rb +145 -119
- data/spec/unit/network/http/factory_spec.rb +5 -27
- data/spec/unit/parser/scope_spec.rb +0 -10
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +3 -8
- data/spec/unit/pops/loaders/loaders_spec.rb +4 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +0 -37
- data/spec/unit/pops/types/types_spec.rb +27 -0
- data/spec/unit/provider/exec_spec.rb +0 -209
- data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
- data/spec/unit/provider/package/dnf_spec.rb +0 -7
- data/spec/unit/provider/package/dpkg_spec.rb +80 -240
- data/spec/unit/provider/package/pip_spec.rb +8 -61
- data/spec/unit/provider/package/portage_spec.rb +4 -4
- data/spec/unit/provider/package/rpm_spec.rb +16 -150
- data/spec/unit/provider/package/yum_spec.rb +0 -7
- data/spec/unit/provider/service/daemontools_spec.rb +0 -24
- data/spec/unit/provider/service/launchd_spec.rb +0 -28
- data/spec/unit/provider/service/runit_spec.rb +0 -24
- data/spec/unit/provider/service/systemd_spec.rb +25 -39
- data/spec/unit/provider/service/windows_spec.rb +0 -20
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/pw_spec.rb +0 -37
- data/spec/unit/provider/user/useradd_spec.rb +0 -88
- data/spec/unit/resource_spec.rb +1 -26
- data/spec/unit/ssl/host_spec.rb +5 -0
- data/spec/unit/ssl/ssl_provider_spec.rb +36 -11
- data/spec/unit/ssl/state_machine_spec.rb +233 -158
- data/spec/unit/transaction_spec.rb +0 -64
- data/spec/unit/type/exec_spec.rb +12 -15
- data/spec/unit/type/file/content_spec.rb +3 -9
- data/spec/unit/type/file/source_spec.rb +4 -4
- data/spec/unit/type/file_spec.rb +15 -11
- data/spec/unit/type/package_spec.rb +0 -5
- data/spec/unit/type/schedule_spec.rb +1 -3
- data/spec/unit/type/service_spec.rb +0 -16
- data/spec/unit/util/execution_spec.rb +0 -16
- data/spec/unit/util/http_proxy_spec.rb +21 -151
- data/spec/unit/util/ldap/manager_spec.rb +0 -15
- data/spec/unit/util/log/destinations_spec.rb +3 -7
- data/spec/unit/util/log_spec.rb +138 -0
- data/spec/unit/util/logging_spec.rb +0 -200
- data/spec/unit/util/pidlock_spec.rb +0 -26
- data/spec/unit/util/skip_tags_spec.rb +14 -0
- data/spec/unit/util/windows/adsi_spec.rb +0 -51
- data/spec/unit/util/windows/service_spec.rb +0 -9
- data/spec/unit/util_spec.rb +10 -0
- data/spec/unit/x509/cert_provider_spec.rb +82 -43
- data/tasks/generate_cert_fixtures.rake +13 -1
- data/tasks/manpages.rake +0 -1
- metadata +26 -20
- data/ext/cert_inspector +0 -140
- data/ext/envpuppet +0 -139
- data/ext/envpuppet.bat +0 -14
- data/ext/puppet-test +0 -476
- data/ext/pure_ruby_dsl/dsl_test.rb +0 -7
- data/ext/upload_facts.rb +0 -119
- data/lib/puppet/provider/package/dnfmodule.rb +0 -87
- data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +0 -11
- data/spec/integration/type/notify_spec.rb +0 -46
- data/spec/unit/provider/package/dnfmodule_spec.rb +0 -186
- data/spec/unit/provider/package_targetable_spec.rb +0 -60
@@ -4,11 +4,10 @@ require 'puppet_spec/validators'
|
|
4
4
|
require 'puppet/test_ca'
|
5
5
|
|
6
6
|
describe Puppet::Network::HTTP::Connection do
|
7
|
-
let (:host) { "me
|
8
|
-
let (:port) {
|
9
|
-
let (:url) { "https://#{host}:#{port}/foo" }
|
10
|
-
|
7
|
+
let (:host) { "me" }
|
8
|
+
let (:port) { 54321 }
|
11
9
|
subject { Puppet::Network::HTTP::Connection.new(host, port, :verify => Puppet::SSL::Validator.no_validator) }
|
10
|
+
let (:httpok) { Net::HTTPOK.new('1.1', 200, '') }
|
12
11
|
|
13
12
|
context "when providing HTTP connections" do
|
14
13
|
context "when initializing http instances" do
|
@@ -69,48 +68,68 @@ describe Puppet::Network::HTTP::Connection do
|
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
|
-
context "when handling requests" do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
71
|
+
context "when handling requests", :vcr do
|
72
|
+
let (:host) { "my-server" }
|
73
|
+
let (:port) { 8140 }
|
74
|
+
let (:subject) { Puppet::Network::HTTP::Connection.new(host, port, :use_ssl => false, :verify => Puppet::SSL::Validator.no_validator) }
|
75
|
+
|
76
|
+
{ :request_get => {},
|
77
|
+
:request_head => {},
|
78
|
+
:request_post => "param: value" }.each do |method,body|
|
79
|
+
context "##{method}" do
|
80
|
+
it "should yield to the block" do
|
81
|
+
allow_any_instance_of(Net::HTTP).to receive(method) do |_, *_, &block|
|
82
|
+
block.call()
|
83
|
+
httpok
|
84
|
+
end
|
85
|
+
|
86
|
+
block_executed = false
|
87
|
+
subject.send(method, "/foo", body) do |response|
|
88
|
+
block_executed = true
|
89
|
+
end
|
90
|
+
expect(block_executed).to eq(true)
|
91
|
+
end
|
92
|
+
end
|
79
93
|
end
|
94
|
+
end
|
80
95
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
context "when response is a redirect" do
|
97
|
+
let (:site) { Puppet::Network::HTTP::Site.new('http', 'my_server', 8140) }
|
98
|
+
let (:other_site) { Puppet::Network::HTTP::Site.new('http', 'redirected', 9292) }
|
99
|
+
let (:other_path) { "other-path" }
|
100
|
+
let (:verify) { Puppet::SSL::Validator.no_validator }
|
101
|
+
let (:subject) { Puppet::Network::HTTP::Connection.new(site.host, site.port, :use_ssl => false, :verify => verify) }
|
102
|
+
let (:httpredirection) do
|
103
|
+
response = Net::HTTPFound.new('1.1', 302, 'Moved Temporarily')
|
104
|
+
response['location'] = "#{other_site.addr}/#{other_path}"
|
105
|
+
allow(response).to receive(:read_body).and_return("This resource has moved")
|
106
|
+
response
|
87
107
|
end
|
88
108
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
expect { |b|
|
93
|
-
subject.request_post('/foo', "param: value", &b)
|
94
|
-
}.to yield_with_args(Net::HTTPResponse)
|
109
|
+
def create_connection(site, options)
|
110
|
+
options[:use_ssl] = site.use_ssl?
|
111
|
+
Puppet::Network::HTTP::Connection.new(site.host, site.port, options)
|
95
112
|
end
|
96
|
-
end
|
97
113
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
options[:verify] = Puppet::SSL::Validator.no_validator
|
102
|
-
Puppet::Network::HTTP::Connection.new(host, port, options)
|
103
|
-
end
|
114
|
+
it "should redirect to the final resource location" do
|
115
|
+
http = double('http')
|
116
|
+
allow(http).to receive(:request).and_return(httpredirection, httpok)
|
104
117
|
|
105
|
-
|
106
|
-
|
118
|
+
pool = Puppet.lookup(:http_pool)
|
119
|
+
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http).ordered
|
120
|
+
expect(pool).to receive(:with_connection).with(other_site, anything).and_yield(http).ordered
|
121
|
+
|
122
|
+
conn = create_connection(site, :verify => verify)
|
123
|
+
conn.get('/foo')
|
107
124
|
end
|
108
125
|
|
109
|
-
|
110
|
-
|
111
|
-
|
126
|
+
def expects_redirection(conn, &block)
|
127
|
+
http = double('http')
|
128
|
+
allow(http).to receive(:request).and_return(httpredirection)
|
112
129
|
|
113
|
-
|
130
|
+
pool = Puppet.lookup(:http_pool)
|
131
|
+
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
132
|
+
pool
|
114
133
|
end
|
115
134
|
|
116
135
|
def expects_limit_exceeded(conn)
|
@@ -119,157 +138,164 @@ describe Puppet::Network::HTTP::Connection do
|
|
119
138
|
}.to raise_error(Puppet::Network::HTTP::RedirectionLimitExceededException)
|
120
139
|
end
|
121
140
|
|
122
|
-
it "should not
|
123
|
-
|
141
|
+
it "should not redirect when the limit is 0" do
|
142
|
+
conn = create_connection(site, :verify => verify, :redirect_limit => 0)
|
143
|
+
|
144
|
+
pool = expects_redirection(conn)
|
145
|
+
expect(pool).not_to receive(:with_connection).with(other_site, anything)
|
124
146
|
|
125
|
-
conn = create_connection(:redirect_limit => 0)
|
126
147
|
expects_limit_exceeded(conn)
|
127
148
|
end
|
128
149
|
|
129
|
-
it "should
|
130
|
-
|
131
|
-
|
150
|
+
it "should redirect only once" do
|
151
|
+
conn = create_connection(site, :verify => verify, :redirect_limit => 1)
|
152
|
+
|
153
|
+
pool = expects_redirection(conn)
|
154
|
+
expect(pool).to receive(:with_connection).with(other_site, anything).once
|
132
155
|
|
133
|
-
conn = create_connection(:redirect_limit => 1)
|
134
156
|
expects_limit_exceeded(conn)
|
135
157
|
end
|
136
158
|
|
137
159
|
it "should raise an exception when the redirect limit is exceeded" do
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
160
|
+
conn = create_connection(site, :verify => verify, :redirect_limit => 3)
|
161
|
+
|
162
|
+
pool = expects_redirection(conn)
|
163
|
+
expect(pool).to receive(:with_connection).with(other_site, anything).exactly(3).times
|
142
164
|
|
143
|
-
conn = create_connection(:redirect_limit => 3)
|
144
165
|
expects_limit_exceeded(conn)
|
145
166
|
end
|
146
167
|
end
|
147
168
|
|
148
169
|
context "when response indicates an overloaded server" do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
170
|
+
let(:http) { double('http') }
|
171
|
+
let(:site) { Puppet::Network::HTTP::Site.new('http', 'my_server', 8140) }
|
172
|
+
let(:verify) { Puppet::SSL::Validator.no_validator }
|
173
|
+
let(:httpunavailable) { Net::HTTPServiceUnavailable.new('1.1', 503, 'Service Unavailable') }
|
174
|
+
|
175
|
+
subject { Puppet::Network::HTTP::Connection.new(site.host, site.port, :use_ssl => false, :verify => verify) }
|
176
|
+
|
177
|
+
context "when parsing Retry-After headers" do
|
178
|
+
# Private method. Create a reference that can be called by tests.
|
179
|
+
let(:header_parser) { subject.method(:parse_retry_after_header) }
|
180
|
+
|
181
|
+
it "returns 0 when parsing a RFC 2822 date that has passed" do
|
182
|
+
test_date = 'Wed, 13 Apr 2005 15:18:05 GMT'
|
183
|
+
|
184
|
+
expect(header_parser.call(test_date)).to eq(0)
|
185
|
+
end
|
153
186
|
end
|
154
187
|
|
155
188
|
it "should return a 503 response if Retry-After is not set" do
|
156
|
-
|
189
|
+
allow(http).to receive(:request).and_return(httpunavailable)
|
190
|
+
|
191
|
+
pool = Puppet.lookup(:http_pool)
|
192
|
+
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
157
193
|
|
158
194
|
result = subject.get('/foo')
|
159
|
-
|
195
|
+
|
196
|
+
expect(result.code).to eq(503)
|
160
197
|
end
|
161
198
|
|
162
199
|
it "should return a 503 response if Retry-After is not convertible to an Integer or RFC 2822 Date" do
|
163
|
-
|
200
|
+
httpunavailable['Retry-After'] = 'foo'
|
201
|
+
allow(http).to receive(:request).and_return(httpunavailable)
|
202
|
+
|
203
|
+
pool = Puppet.lookup(:http_pool)
|
204
|
+
expect(pool).to receive(:with_connection).with(site, anything).and_yield(http)
|
164
205
|
|
165
206
|
result = subject.get('/foo')
|
166
|
-
|
207
|
+
|
208
|
+
expect(result.code).to eq(503)
|
167
209
|
end
|
168
210
|
|
169
211
|
it "should sleep and retry if Retry-After is an Integer" do
|
170
|
-
|
212
|
+
httpunavailable['Retry-After'] = '42'
|
213
|
+
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
214
|
+
|
215
|
+
pool = Puppet.lookup(:http_pool)
|
216
|
+
expect(pool).to receive(:with_connection).with(site, anything).twice.and_yield(http)
|
171
217
|
|
172
218
|
expect(::Kernel).to receive(:sleep).with(42)
|
173
219
|
|
174
220
|
result = subject.get('/foo')
|
175
|
-
|
221
|
+
|
222
|
+
expect(result.code).to eq(200)
|
176
223
|
end
|
177
224
|
|
178
225
|
it "should sleep and retry if Retry-After is an RFC 2822 Date" do
|
179
|
-
|
226
|
+
httpunavailable['Retry-After'] = 'Wed, 13 Apr 2005 15:18:05 GMT'
|
227
|
+
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
180
228
|
|
181
229
|
now = DateTime.new(2005, 4, 13, 8, 17, 5, '-07:00')
|
182
230
|
allow(DateTime).to receive(:now).and_return(now)
|
183
231
|
|
232
|
+
pool = Puppet.lookup(:http_pool)
|
233
|
+
expect(pool).to receive(:with_connection).with(site, anything).twice.and_yield(http)
|
234
|
+
|
184
235
|
expect(::Kernel).to receive(:sleep).with(60)
|
185
236
|
|
186
237
|
result = subject.get('/foo')
|
187
|
-
|
238
|
+
|
239
|
+
expect(result.code).to eq(200)
|
188
240
|
end
|
189
241
|
|
190
242
|
it "should sleep for no more than the Puppet runinterval" do
|
191
|
-
|
243
|
+
httpunavailable['Retry-After'] = '60'
|
244
|
+
allow(http).to receive(:request).and_return(httpunavailable, httpok)
|
192
245
|
Puppet[:runinterval] = 30
|
193
246
|
|
194
|
-
|
247
|
+
pool = Puppet.lookup(:http_pool)
|
248
|
+
expect(pool).to receive(:with_connection).with(site, anything).twice.and_yield(http)
|
195
249
|
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should sleep for 0 seconds if the RFC 2822 date has past" do
|
200
|
-
retry_after('Wed, 13 Apr 2005 15:18:05 GMT')
|
201
|
-
|
202
|
-
expect(::Kernel).to receive(:sleep).with(0)
|
250
|
+
expect(::Kernel).to receive(:sleep).with(30)
|
203
251
|
|
204
252
|
subject.get('/foo')
|
205
253
|
end
|
206
254
|
end
|
207
255
|
|
208
|
-
|
209
|
-
|
210
|
-
let(:creds) { [ 'user', 'password'] }
|
256
|
+
it "allows setting basic auth on get requests" do
|
257
|
+
expect_request_with_basic_auth
|
211
258
|
|
212
|
-
|
213
|
-
|
259
|
+
subject.get('/path', nil, :basic_auth => { :user => 'user', :password => 'password' })
|
260
|
+
end
|
214
261
|
|
215
|
-
|
216
|
-
|
262
|
+
it "allows setting basic auth on post requests" do
|
263
|
+
expect_request_with_basic_auth
|
217
264
|
|
218
|
-
|
219
|
-
|
265
|
+
subject.post('/path', 'data', nil, :basic_auth => { :user => 'user', :password => 'password' })
|
266
|
+
end
|
220
267
|
|
221
|
-
|
222
|
-
|
268
|
+
it "allows setting basic auth on head requests" do
|
269
|
+
expect_request_with_basic_auth
|
223
270
|
|
224
|
-
|
225
|
-
|
271
|
+
subject.head('/path', nil, :basic_auth => { :user => 'user', :password => 'password' })
|
272
|
+
end
|
226
273
|
|
227
|
-
|
228
|
-
|
274
|
+
it "allows setting basic auth on delete requests" do
|
275
|
+
expect_request_with_basic_auth
|
229
276
|
|
230
|
-
|
231
|
-
|
277
|
+
subject.delete('/path', nil, :basic_auth => { :user => 'user', :password => 'password' })
|
278
|
+
end
|
232
279
|
|
233
|
-
|
234
|
-
|
280
|
+
it "allows setting basic auth on put requests" do
|
281
|
+
expect_request_with_basic_auth
|
235
282
|
|
236
|
-
|
237
|
-
|
283
|
+
subject.put('/path', 'data', nil, :basic_auth => { :user => 'user', :password => 'password' })
|
284
|
+
end
|
238
285
|
|
239
|
-
|
240
|
-
|
286
|
+
def expect_request_with_basic_auth
|
287
|
+
expect_any_instance_of(Net::HTTP).to receive(:request) do |_, request|
|
288
|
+
expect(request['authorization']).to match(/^Basic/)
|
289
|
+
end.and_return(httpok)
|
241
290
|
end
|
242
291
|
|
243
292
|
it "sets HTTP User-Agent header" do
|
244
293
|
puppet_ua = "Puppet/#{Puppet.version} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
|
245
|
-
stub_request(:get, url).with(headers: { 'User-Agent' => puppet_ua })
|
246
294
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
describe 'connection request errors' do
|
251
|
-
it "logs and raises generic http errors" do
|
252
|
-
generic_error = Net::HTTPError.new('generic error', double("response"))
|
253
|
-
stub_request(:get, url).to_raise(generic_error)
|
295
|
+
expect_any_instance_of(Net::HTTP).to receive(:request) do |_, request|
|
296
|
+
expect(request['User-Agent']).to eq(puppet_ua)
|
297
|
+
end.and_return(httpok)
|
254
298
|
|
255
|
-
|
256
|
-
expect { subject.get('/foo') }.to raise_error(generic_error)
|
257
|
-
end
|
258
|
-
|
259
|
-
it "logs and raises timeout errors" do
|
260
|
-
timeout_error = Timeout::Error.new
|
261
|
-
stub_request(:get, url).to_raise(timeout_error)
|
262
|
-
|
263
|
-
expect(Puppet).to receive(:log_exception).with(anything, /^.*timed out after .* seconds$/)
|
264
|
-
expect { subject.get('/foo') }.to raise_error(timeout_error)
|
265
|
-
end
|
266
|
-
|
267
|
-
it "logs and raises eof errors" do
|
268
|
-
eof_error = EOFError
|
269
|
-
stub_request(:get, url).to_raise(eof_error)
|
270
|
-
|
271
|
-
expect(Puppet).to receive(:log_exception).with(anything, /^.*interrupted after .* seconds$/)
|
272
|
-
expect { subject.get('/foo') }.to raise_error(eof_error)
|
273
|
-
end
|
299
|
+
subject.get('/path')
|
274
300
|
end
|
275
301
|
end
|
@@ -43,11 +43,10 @@ describe Puppet::Network::HTTP::Factory do
|
|
43
43
|
context "proxy settings" do
|
44
44
|
let(:proxy_host) { 'myhost' }
|
45
45
|
let(:proxy_port) { 432 }
|
46
|
-
let(:proxy_user) { 'mo' }
|
47
|
-
let(:proxy_pass) { 'password' }
|
48
46
|
|
49
|
-
it "should not set a proxy if the
|
47
|
+
it "should not set a proxy if the value is 'none'" do
|
50
48
|
Puppet[:http_proxy_host] = 'none'
|
49
|
+
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
51
50
|
conn = create_connection(site)
|
52
51
|
|
53
52
|
expect(conn.proxy_address).to be_nil
|
@@ -56,18 +55,7 @@ describe Puppet::Network::HTTP::Factory do
|
|
56
55
|
it 'should not set a proxy if a no_proxy env var matches the destination' do
|
57
56
|
Puppet[:http_proxy_host] = proxy_host
|
58
57
|
Puppet[:http_proxy_port] = proxy_port
|
59
|
-
Puppet::Util.
|
60
|
-
conn = create_connection(site)
|
61
|
-
|
62
|
-
expect(conn.proxy_address).to be_nil
|
63
|
-
expect(conn.proxy_port).to be_nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should not set a proxy if the no_proxy setting matches the destination' do
|
68
|
-
Puppet[:http_proxy_host] = proxy_host
|
69
|
-
Puppet[:http_proxy_port] = proxy_port
|
70
|
-
Puppet[:no_proxy] = site.host
|
58
|
+
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(true)
|
71
59
|
conn = create_connection(site)
|
72
60
|
|
73
61
|
expect(conn.proxy_address).to be_nil
|
@@ -76,6 +64,7 @@ describe Puppet::Network::HTTP::Factory do
|
|
76
64
|
|
77
65
|
it 'sets proxy_address' do
|
78
66
|
Puppet[:http_proxy_host] = proxy_host
|
67
|
+
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
79
68
|
conn = create_connection(site)
|
80
69
|
|
81
70
|
expect(conn.proxy_address).to eq(proxy_host)
|
@@ -84,22 +73,11 @@ describe Puppet::Network::HTTP::Factory do
|
|
84
73
|
it 'sets proxy address and port' do
|
85
74
|
Puppet[:http_proxy_host] = proxy_host
|
86
75
|
Puppet[:http_proxy_port] = proxy_port
|
76
|
+
expect(Puppet::Util::HttpProxy).to receive(:no_proxy?).and_return(false)
|
87
77
|
conn = create_connection(site)
|
88
78
|
|
89
79
|
expect(conn.proxy_port).to eq(proxy_port)
|
90
80
|
end
|
91
|
-
|
92
|
-
it 'sets proxy user and password' do
|
93
|
-
Puppet[:http_proxy_host] = proxy_host
|
94
|
-
Puppet[:http_proxy_port] = proxy_port
|
95
|
-
Puppet[:http_proxy_user] = proxy_user
|
96
|
-
Puppet[:http_proxy_password] = proxy_pass
|
97
|
-
|
98
|
-
conn = create_connection(site)
|
99
|
-
|
100
|
-
expect(conn.proxy_user).to eq(proxy_user)
|
101
|
-
expect(conn.proxy_pass).to eq(proxy_pass)
|
102
|
-
end
|
103
81
|
end
|
104
82
|
|
105
83
|
context 'socket timeouts' do
|
@@ -680,15 +680,5 @@ describe Puppet::Parser::Scope do
|
|
680
680
|
@scope.setvar("orange", :undef)
|
681
681
|
expect(@scope.to_hash).to eq({'pear' => :green, 'apple' => :red })
|
682
682
|
end
|
683
|
-
|
684
|
-
it "should not delete values that are :undef in inner scope when include_undef is true" do
|
685
|
-
@scope.new_ephemeral true
|
686
|
-
@scope.setvar("orange", :tangerine)
|
687
|
-
@scope.setvar("pear", :green)
|
688
|
-
@scope.new_ephemeral true
|
689
|
-
@scope.setvar("apple", :red)
|
690
|
-
@scope.setvar("orange", :undef)
|
691
|
-
expect(@scope.to_hash(true, true)).to eq({'pear' => :green, 'apple' => :red, 'orange' => :undef })
|
692
|
-
end
|
693
683
|
end
|
694
684
|
end
|
@@ -478,26 +478,21 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
478
478
|
}.each do |source, coerced_val|
|
479
479
|
it "should warn about numeric coercion in '#{source}' when strict = warning" do
|
480
480
|
Puppet[:strict] = :warning
|
481
|
-
expect(Puppet::Pops::Evaluator::Runtime3Support::EvaluationError).not_to receive(:new)
|
482
481
|
collect_notices(source)
|
483
482
|
expect(warnings).to include(/The string '#{coerced_val}' was automatically coerced to the numerical value #{coerced_val}/)
|
484
483
|
end
|
485
484
|
|
486
485
|
it "should not warn about numeric coercion in '#{source}' if strict = off" do
|
487
486
|
Puppet[:strict] = :off
|
488
|
-
expect(Puppet::Pops::Evaluator::Runtime3Support::EvaluationError).not_to receive(:new)
|
489
487
|
collect_notices(source)
|
490
488
|
expect(warnings).to_not include(/The string '#{coerced_val}' was automatically coerced to the numerical value #{coerced_val}/)
|
491
489
|
end
|
492
490
|
|
493
491
|
it "should error when finding numeric coercion in '#{source}' if strict = error" do
|
494
492
|
Puppet[:strict] = :error
|
495
|
-
expect {
|
496
|
-
|
497
|
-
|
498
|
-
expect(error.message).to match(/The string '#{coerced_val}' was automatically coerced to the numerical value #{coerced_val}/)
|
499
|
-
expect(error.backtrace.first).to match(/runtime3_support\.rb.+optionally_fail/)
|
500
|
-
}
|
493
|
+
expect { parser.evaluate_string(scope, source, __FILE__) }.to raise_error(
|
494
|
+
/The string '#{coerced_val}' was automatically coerced to the numerical value #{coerced_val}/
|
495
|
+
)
|
501
496
|
end
|
502
497
|
end
|
503
498
|
|