puppet 6.14.0-x86-mingw32 → 6.15.0-x86-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/Gemfile.lock +15 -15
- data/ext/windows/service/daemon.rb +3 -3
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -10
- data/lib/puppet/application/agent.rb +2 -1
- data/lib/puppet/application/filebucket.rb +5 -14
- data/lib/puppet/application/ssl.rb +2 -2
- data/lib/puppet/configurer.rb +7 -3
- data/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/lib/puppet/defaults.rb +22 -2
- data/lib/puppet/environments.rb +4 -5
- data/lib/puppet/face/plugin.rb +1 -1
- data/lib/puppet/file_system/file_impl.rb +13 -9
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/functions/call.rb +1 -1
- data/lib/puppet/functions/reduce.rb +2 -4
- data/lib/puppet/http.rb +2 -0
- data/lib/puppet/http/client.rb +191 -52
- data/lib/puppet/http/external_client.rb +96 -0
- data/lib/puppet/http/redirector.rb +34 -0
- data/lib/puppet/http/resolver.rb +46 -3
- data/lib/puppet/http/resolver/server_list.rb +75 -15
- data/lib/puppet/http/resolver/settings.rb +22 -2
- data/lib/puppet/http/resolver/srv.rb +28 -2
- data/lib/puppet/http/response.rb +63 -1
- data/lib/puppet/http/retry_after_handler.rb +39 -0
- data/lib/puppet/http/service.rb +67 -1
- data/lib/puppet/http/service/ca.rb +71 -9
- data/lib/puppet/http/service/compiler.rb +213 -11
- data/lib/puppet/http/service/file_server.rb +105 -4
- data/lib/puppet/http/service/report.rb +36 -3
- data/lib/puppet/http/session.rb +59 -8
- data/lib/puppet/indirector/catalog/rest.rb +2 -1
- data/lib/puppet/indirector/facts/rest.rb +2 -1
- data/lib/puppet/indirector/file_bucket_file/rest.rb +48 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +4 -2
- data/lib/puppet/indirector/node/rest.rb +2 -1
- data/lib/puppet/indirector/report/yaml.rb +23 -0
- data/lib/puppet/indirector/status/rest.rb +2 -1
- data/lib/puppet/metatype/manager.rb +80 -80
- data/lib/puppet/network/http/base_pool.rb +6 -1
- data/lib/puppet/network/http/pool.rb +2 -4
- data/lib/puppet/network/http_pool.rb +1 -0
- data/lib/puppet/node/environment.rb +11 -1
- data/lib/puppet/pal/pal_impl.rb +1 -29
- data/lib/puppet/parser/compiler.rb +14 -7
- data/lib/puppet/parser/functions.rb +18 -13
- data/lib/puppet/pops/loaders.rb +7 -5
- data/lib/puppet/provider/group/windows_adsi.rb +3 -3
- data/lib/puppet/provider/package/apt.rb +61 -1
- data/lib/puppet/provider/package/dnfmodule.rb +39 -12
- data/lib/puppet/provider/package/gem.rb +41 -7
- data/lib/puppet/provider/package/pacman.rb +2 -5
- data/lib/puppet/provider/package/pip.rb +105 -33
- data/lib/puppet/provider/package/pip3.rb +0 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgng.rb +16 -4
- 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 +92 -19
- data/lib/puppet/provider/service/systemd.rb +2 -1
- data/lib/puppet/reports/http.rb +13 -11
- data/lib/puppet/resource/type_collection.rb +20 -16
- data/lib/puppet/ssl.rb +1 -0
- data/lib/puppet/ssl/host.rb +4 -4
- data/lib/puppet/ssl/oids.rb +1 -0
- data/lib/puppet/ssl/state_machine.rb +50 -33
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +6 -1
- data/lib/puppet/type/file/source.rb +4 -2
- data/lib/puppet/type/package.rb +25 -2
- data/lib/puppet/type/user.rb +0 -19
- data/lib/puppet/util/at_fork.rb +1 -1
- data/lib/puppet/util/autoload.rb +3 -0
- data/lib/puppet/util/instance_loader.rb +14 -10
- 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 +50 -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 +13 -7
- data/lib/puppet/util/platform.rb +5 -0
- data/lib/puppet/util/rpm_compare.rb +193 -0
- data/lib/puppet/util/windows/adsi.rb +2 -2
- 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/version.rb +1 -1
- data/locales/puppet.pot +207 -201
- data/man/man5/puppet.conf.5 +11 -3
- data/man/man8/puppet-agent.8 +1 -1
- 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 +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 +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/provider/package/dnfmodule/{dnf-module-list-installed.txt → dnf-module-list-enabled.txt} +2 -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/service/systemd/list_unit_files_services +9 -0
- data/spec/integration/application/agent_spec.rb +329 -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 +50 -0
- data/spec/integration/http/client_spec.rb +34 -40
- data/spec/integration/indirector/report/yaml.rb +83 -0
- data/spec/integration/module_tool/forge_spec.rb +2 -15
- data/spec/integration/network/http_pool_spec.rb +11 -19
- data/spec/integration/node/environment_spec.rb +15 -0
- data/spec/integration/util/windows/adsi_spec.rb +1 -1
- data/spec/lib/puppet/test_ca.rb +2 -2
- data/spec/lib/puppet_spec/https.rb +10 -7
- data/spec/lib/puppet_spec/puppetserver.rb +119 -0
- data/spec/shared_contexts/https.rb +29 -0
- data/spec/unit/agent_spec.rb +33 -25
- data/spec/unit/application/agent_spec.rb +5 -1
- data/spec/unit/application/device_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +22 -2
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +24 -1
- data/spec/unit/environments_spec.rb +8 -0
- data/spec/unit/file_system_spec.rb +10 -0
- data/spec/unit/http/client_spec.rb +105 -46
- data/spec/unit/http/external_client_spec.rb +201 -0
- data/spec/unit/http/resolver_spec.rb +20 -0
- data/spec/unit/http/service/ca_spec.rb +25 -2
- data/spec/unit/http/service/compiler_spec.rb +184 -6
- data/spec/unit/http/service/file_server_spec.rb +35 -3
- data/spec/unit/http/service/report_spec.rb +3 -1
- data/spec/unit/http/service_spec.rb +3 -3
- data/spec/unit/http/session_spec.rb +56 -7
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +82 -2
- data/spec/unit/network/http/pool_spec.rb +3 -3
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +43 -10
- data/spec/unit/provider/package/apt_spec.rb +30 -0
- data/spec/unit/provider/package/dnfmodule_spec.rb +33 -14
- data/spec/unit/provider/package/gem_spec.rb +40 -0
- data/spec/unit/provider/package/pacman_spec.rb +6 -21
- data/spec/unit/provider/package/pip_spec.rb +26 -3
- 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/puppet_gem_spec.rb +8 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -212
- data/spec/unit/provider/package/yum_spec.rb +235 -1
- data/spec/unit/provider/service/systemd_spec.rb +10 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +3 -3
- data/spec/unit/puppet_pal_2pec.rb +0 -29
- data/spec/unit/reports/http_spec.rb +70 -52
- data/spec/unit/ssl/host_spec.rb +4 -2
- data/spec/unit/ssl/oids_spec.rb +1 -0
- data/spec/unit/ssl/state_machine_spec.rb +38 -6
- data/spec/unit/transaction/report_spec.rb +4 -0
- data/spec/unit/util/at_fork_spec.rb +2 -2
- 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 +154 -0
- data/spec/unit/util/package/version/rpm_spec.rb +121 -0
- data/spec/unit/util/pidlock_spec.rb +83 -47
- data/spec/unit/util/rpm_compare_spec.rb +196 -0
- data/spec/unit/util/windows/adsi_spec.rb +4 -4
- data/spec/unit/util/windows/sid_spec.rb +2 -2
- data/tasks/generate_cert_fixtures.rake +15 -1
- metadata +51 -6
- data/spec/integration/faces/plugin_spec.rb +0 -63
@@ -63,10 +63,19 @@ describe Puppet::HTTP::Service::FileServer do
|
|
63
63
|
status: 200, body: filemetadata.render, headers: { 'Content-Type' => 'application/json' }
|
64
64
|
)
|
65
65
|
|
66
|
-
metadata = subject.get_file_metadata(path: request_path, environment: environment)
|
66
|
+
_, metadata = subject.get_file_metadata(path: request_path, environment: environment)
|
67
67
|
expect(metadata.path).to eq(path)
|
68
68
|
end
|
69
69
|
|
70
|
+
it 'returns the request response' do
|
71
|
+
stub_request(:get, url).to_return(
|
72
|
+
status: 200, body: filemetadata.render, headers: { 'Content-Type' => 'application/json' }
|
73
|
+
)
|
74
|
+
|
75
|
+
resp, _ = subject.get_file_metadata(path: request_path, environment: environment)
|
76
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
77
|
+
end
|
78
|
+
|
70
79
|
it 'raises a protocol error if the Content-Type header is missing from the response' do
|
71
80
|
stub_request(:get, url).to_return(status: 200, body: '', headers: {})
|
72
81
|
|
@@ -136,10 +145,19 @@ describe Puppet::HTTP::Service::FileServer do
|
|
136
145
|
status: 200, body: formatter.render_multiple(filemetadatas), headers: { 'Content-Type' => 'application/json' }
|
137
146
|
)
|
138
147
|
|
139
|
-
metadatas = subject.get_file_metadatas(path: request_path, environment: environment)
|
148
|
+
_, metadatas = subject.get_file_metadatas(path: request_path, environment: environment)
|
140
149
|
expect(metadatas.first.path).to eq(path)
|
141
150
|
end
|
142
151
|
|
152
|
+
it 'returns the request response' do
|
153
|
+
stub_request(:get, url).to_return(
|
154
|
+
status: 200, body: formatter.render_multiple(filemetadatas), headers: { 'Content-Type' => 'application/json' }
|
155
|
+
)
|
156
|
+
|
157
|
+
resp, _ = subject.get_file_metadatas(path: request_path, environment: environment)
|
158
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
159
|
+
end
|
160
|
+
|
143
161
|
it 'automatically converts an array of parameters to the stringified query' do
|
144
162
|
url = "https://www.example.com/puppet/v3/file_metadatas/:mount/#{path}?checksum_type=md5&environment=testing&ignore=CVS&ignore=.git&ignore=.hg&links=manage&recurse=false&source_permissions=ignore"
|
145
163
|
stub_request(:get, url).with(
|
@@ -148,7 +166,7 @@ describe Puppet::HTTP::Service::FileServer do
|
|
148
166
|
status: 200, body: formatter.render_multiple(filemetadatas), headers: { 'Content-Type' => 'application/json' }
|
149
167
|
)
|
150
168
|
|
151
|
-
metadatas = subject.get_file_metadatas(path: request_path, environment: environment, ignore: ['CVS', '.git', '.hg'])
|
169
|
+
_, metadatas = subject.get_file_metadatas(path: request_path, environment: environment, ignore: ['CVS', '.git', '.hg'])
|
152
170
|
expect(metadatas.first.path).to eq(path)
|
153
171
|
end
|
154
172
|
|
@@ -222,6 +240,13 @@ describe Puppet::HTTP::Service::FileServer do
|
|
222
240
|
}.to yield_with_args("and beyond")
|
223
241
|
end
|
224
242
|
|
243
|
+
it 'returns the request response' do
|
244
|
+
stub_request(:get, uri)
|
245
|
+
|
246
|
+
resp = subject.get_file_content(path: '/:mount/:path', environment: environment) { |b| b }
|
247
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
248
|
+
end
|
249
|
+
|
225
250
|
it 'raises response error if unsuccessful' do
|
226
251
|
stub_request(:get, uri).to_return(status: [400, 'Bad Request'])
|
227
252
|
|
@@ -255,6 +280,13 @@ describe Puppet::HTTP::Service::FileServer do
|
|
255
280
|
}.to yield_with_args("and beyond")
|
256
281
|
end
|
257
282
|
|
283
|
+
it 'returns the request response' do
|
284
|
+
stub_request(:get, uri)
|
285
|
+
|
286
|
+
resp = subject.get_static_file_content(path: '/:mount/:path', environment: environment, code_id: code_id) { |b| b }
|
287
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
288
|
+
end
|
289
|
+
|
258
290
|
it 'raises response error if unsuccessful' do
|
259
291
|
stub_request(:get, uri).to_return(status: [400, 'Bad Request'])
|
260
292
|
|
@@ -85,7 +85,9 @@ describe Puppet::HTTP::Service::Report do
|
|
85
85
|
stub_request(:put, url)
|
86
86
|
.to_return(status: 200, body: body, headers: {'Content-Type' => 'application/json'})
|
87
87
|
|
88
|
-
|
88
|
+
resp = subject.put_report('infinity', report, environment: environment)
|
89
|
+
expect(resp.body).to eq(body)
|
90
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
89
91
|
end
|
90
92
|
|
91
93
|
it 'raises response error if unsuccessful' do
|
@@ -17,7 +17,7 @@ describe Puppet::HTTP::Service do
|
|
17
17
|
@client.get(
|
18
18
|
url,
|
19
19
|
headers: add_puppet_headers({'Default-Header' => 'default-value'}),
|
20
|
-
ssl_context: ssl_context
|
20
|
+
options: {ssl_context: ssl_context}
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -82,14 +82,14 @@ describe Puppet::HTTP::Service do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "connects to the base URL with a nil ssl context" do
|
85
|
-
expect(client).to receive(:connect).with(url, ssl_context: nil)
|
85
|
+
expect(client).to receive(:connect).with(url, options: {ssl_context: nil})
|
86
86
|
|
87
87
|
service.connect
|
88
88
|
end
|
89
89
|
|
90
90
|
it "accepts an optional ssl_context" do
|
91
91
|
other_ctx = Puppet::SSL::SSLContext.new
|
92
|
-
expect(client).to receive(:connect).with(url, ssl_context: other_ctx)
|
92
|
+
expect(client).to receive(:connect).with(url, options: {ssl_context: other_ctx})
|
93
93
|
|
94
94
|
service.connect(ssl_context: other_ctx)
|
95
95
|
end
|
@@ -10,10 +10,14 @@ describe Puppet::HTTP::Session do
|
|
10
10
|
double('good', url: uri, connect: nil)
|
11
11
|
}
|
12
12
|
let(:bad_service) {
|
13
|
+
create_bad_service
|
14
|
+
}
|
15
|
+
|
16
|
+
def create_bad_service(failure_message = 'whoops')
|
13
17
|
service = double('bad', url: uri)
|
14
|
-
allow(service).to receive(:connect).and_raise(Puppet::HTTP::ConnectionError,
|
18
|
+
allow(service).to receive(:connect).and_raise(Puppet::HTTP::ConnectionError, failure_message)
|
15
19
|
service
|
16
|
-
|
20
|
+
end
|
17
21
|
|
18
22
|
class DummyResolver < Puppet::HTTP::Resolver
|
19
23
|
attr_reader :count
|
@@ -23,21 +27,19 @@ describe Puppet::HTTP::Session do
|
|
23
27
|
@count = 0
|
24
28
|
end
|
25
29
|
|
26
|
-
def resolve(session, name, ssl_context: nil)
|
30
|
+
def resolve(session, name, ssl_context: nil, error_handler: nil)
|
27
31
|
@count += 1
|
28
|
-
return @service if check_connection?(session, @service, ssl_context: ssl_context)
|
32
|
+
return @service if check_connection?(session, @service, ssl_context: ssl_context, error_handler: error_handler)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
context 'when routing' do
|
33
37
|
it 'returns the first resolved service' do
|
34
|
-
Puppet[:log_level] = :debug
|
35
38
|
resolvers = [DummyResolver.new(bad_service), DummyResolver.new(good_service)]
|
36
39
|
session = described_class.new(client, resolvers)
|
37
40
|
resolved = session.route_to(:ca)
|
38
41
|
|
39
42
|
expect(resolved).to eq(good_service)
|
40
|
-
expect(@logs).to include(an_object_having_attributes(level: :debug, message: "Connection to #{uri} failed, trying next route: whoops"))
|
41
43
|
end
|
42
44
|
|
43
45
|
it 'only resolves once per session' do
|
@@ -58,6 +60,29 @@ describe Puppet::HTTP::Session do
|
|
58
60
|
}.to raise_error(Puppet::HTTP::RouteError, 'No more routes to ca')
|
59
61
|
end
|
60
62
|
|
63
|
+
it 'logs all routing failures as errors when there are no more routes' do
|
64
|
+
resolvers = [DummyResolver.new(create_bad_service('whoops1')), DummyResolver.new(create_bad_service('whoops2'))]
|
65
|
+
session = described_class.new(client, resolvers)
|
66
|
+
|
67
|
+
expect {
|
68
|
+
session.route_to(:ca)
|
69
|
+
}.to raise_error(Puppet::HTTP::RouteError, 'No more routes to ca')
|
70
|
+
|
71
|
+
expect(@logs).to include(an_object_having_attributes(level: :err, message: "whoops1"),
|
72
|
+
an_object_having_attributes(level: :err, message: "whoops2"))
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'logs routing failures as debug until routing succeeds' do
|
76
|
+
Puppet[:log_level] = 'debug'
|
77
|
+
|
78
|
+
resolvers = [DummyResolver.new(bad_service), DummyResolver.new(good_service)]
|
79
|
+
session = described_class.new(client, resolvers)
|
80
|
+
session.route_to(:ca)
|
81
|
+
|
82
|
+
expect(@logs).to include(an_object_having_attributes(level: :debug, message: "Connection to #{uri} failed, trying next route: whoops"))
|
83
|
+
expect(@logs).to_not include(an_object_having_attributes(level: :err))
|
84
|
+
end
|
85
|
+
|
61
86
|
it 'accepts an ssl context to use when connecting' do
|
62
87
|
alt_context = Puppet::SSL::SSLContext.new
|
63
88
|
expect(good_service).to receive(:connect).with(ssl_context: alt_context)
|
@@ -166,9 +191,12 @@ describe Puppet::HTTP::Session do
|
|
166
191
|
|
167
192
|
Puppet::HTTP::Service::SERVICE_NAMES.each do |name|
|
168
193
|
it "resolves #{name} using server_list" do
|
169
|
-
|
194
|
+
Puppet[:server_list] = 'apple.example.com'
|
195
|
+
req = stub_request(:get, "https://apple.example.com:8140/status/v1/simple/master").to_return(status: 200)
|
170
196
|
|
171
197
|
session.route_to(name)
|
198
|
+
|
199
|
+
expect(req).to have_been_requested
|
172
200
|
end
|
173
201
|
end
|
174
202
|
|
@@ -183,6 +211,27 @@ describe Puppet::HTTP::Session do
|
|
183
211
|
|
184
212
|
expect(session.route_to(:report).url.to_s).to eq("https://cherry.example.com:8140/puppet/v3")
|
185
213
|
end
|
214
|
+
|
215
|
+
it 'resolves once for all services in a session' do
|
216
|
+
Puppet[:server_list] = 'apple.example.com'
|
217
|
+
req = stub_request(:get, "https://apple.example.com:8140/status/v1/simple/master").to_return(status: 200)
|
218
|
+
|
219
|
+
Puppet::HTTP::Service::SERVICE_NAMES.each do |name|
|
220
|
+
session.route_to(name)
|
221
|
+
end
|
222
|
+
|
223
|
+
expect(req).to have_been_requested
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'resolves server_list for each new session' do
|
227
|
+
Puppet[:server_list] = 'apple.example.com'
|
228
|
+
req = stub_request(:get, "https://apple.example.com:8140/status/v1/simple/master").to_return(status: 200)
|
229
|
+
|
230
|
+
client.create_session.route_to(:puppet)
|
231
|
+
client.create_session.route_to(:puppet)
|
232
|
+
|
233
|
+
expect(req).to have_been_requested.twice
|
234
|
+
end
|
186
235
|
end
|
187
236
|
|
188
237
|
context 'when retrieving capabilities' do
|
@@ -3,7 +3,87 @@ require 'spec_helper'
|
|
3
3
|
require 'puppet/indirector/file_bucket_file/rest'
|
4
4
|
|
5
5
|
describe Puppet::FileBucketFile::Rest do
|
6
|
-
|
7
|
-
|
6
|
+
let(:rest_path) {"filebucket://xanadu:8141/"}
|
7
|
+
let(:file_bucket_file) {Puppet::FileBucket::File.new('file contents', :bucket_path => '/some/random/path')}
|
8
|
+
let(:files_original_path) {'/path/to/file'}
|
9
|
+
let(:dest_path) {"#{rest_path}#{file_bucket_file.name}/#{files_original_path}"}
|
10
|
+
let(:file_bucket_path) {"#{rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}/#{files_original_path}"}
|
11
|
+
let(:source_path) {"#{rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}"}
|
12
|
+
|
13
|
+
let(:uri) { %r{/puppet/v3/file_bucket_file} }
|
14
|
+
|
15
|
+
describe '#head' do
|
16
|
+
it 'includes the environment as a request parameter' do
|
17
|
+
stub_request(:head, uri).with(query: hash_including(environment: 'outerspace'))
|
18
|
+
|
19
|
+
described_class.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path, environment: Puppet::Node::Environment.remote('outerspace'))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes bucket path in the request if bucket path is set' do
|
23
|
+
stub_request(:head, uri).with(query: hash_including(bucket_path: '/some/random/path'))
|
24
|
+
|
25
|
+
described_class.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns nil on 404" do
|
29
|
+
stub_request(:head, uri).to_return(status: 404)
|
30
|
+
|
31
|
+
expect(described_class.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path)).to be_falsy
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises for all other fail codes" do
|
35
|
+
stub_request(:head, uri).to_return(status: [503, 'server unavailable'])
|
36
|
+
|
37
|
+
expect{described_class.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path)}.to raise_error(Net::HTTPError, "Error 503 on SERVER: server unavailable")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#find' do
|
42
|
+
it 'includes the environment as a request parameter' do
|
43
|
+
stub_request(:get, uri).with(query: hash_including(environment: 'outerspace')).to_return(status: 200, headers: {'Content-Type' => 'application/octet-stream'})
|
44
|
+
|
45
|
+
described_class.indirection.find(source_path, :bucket_path => nil, environment: Puppet::Node::Environment.remote('outerspace'))
|
46
|
+
end
|
47
|
+
|
48
|
+
{bucket_path: 'path', diff_with: '4aabe1257043bd0', list_all: 'true', fromdate: '20200404', todate: '20200404'}.each do |param, val|
|
49
|
+
it "includes #{param} as a parameter in the request if #{param} is set" do
|
50
|
+
stub_request(:get, uri).with(query: hash_including(param => val)).to_return(status: 200, headers: {'Content-Type' => 'application/octet-stream'})
|
51
|
+
|
52
|
+
options = { param => val }
|
53
|
+
described_class.indirection.find(source_path, **options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raises if unsuccessful' do
|
58
|
+
stub_request(:get, uri).to_return(status: [503, 'server unavailable'])
|
59
|
+
|
60
|
+
expect{described_class.indirection.find(source_path, :bucket_path => nil)}.to raise_error(Net::HTTPError, "Error 503 on SERVER: server unavailable")
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'raises if Content-Type is not included in the response' do
|
64
|
+
stub_request(:get, uri).to_return(status: 200, headers: {})
|
65
|
+
|
66
|
+
expect{described_class.indirection.find(source_path, :bucket_path => nil)}.to raise_error(RuntimeError, "No content type in http response; cannot parse")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#save' do
|
71
|
+
it 'includes the environment as a request parameter' do
|
72
|
+
stub_request(:put, uri).with(query: hash_including(environment: 'outerspace'))
|
73
|
+
|
74
|
+
described_class.indirection.save(file_bucket_file, dest_path, environment: Puppet::Node::Environment.remote('outerspace'))
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'sends the contents of the file as the request body' do
|
78
|
+
stub_request(:put, uri).with(body: file_bucket_file.contents)
|
79
|
+
|
80
|
+
described_class.indirection.save(file_bucket_file, dest_path)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'raises if unsuccessful' do
|
84
|
+
stub_request(:put, uri).to_return(status: [503, 'server unavailable'])
|
85
|
+
|
86
|
+
expect{described_class.indirection.save(file_bucket_file, dest_path)}.to raise_error(Net::HTTPError, "Error 503 on SERVER: server unavailable")
|
87
|
+
end
|
8
88
|
end
|
9
89
|
end
|
@@ -26,11 +26,11 @@ describe Puppet::Network::HTTP::Pool do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def create_pool
|
29
|
-
Puppet::Network::HTTP::Pool.new
|
29
|
+
Puppet::Network::HTTP::Pool.new(15)
|
30
30
|
end
|
31
31
|
|
32
32
|
def create_pool_with_connections(site, *connections)
|
33
|
-
pool = Puppet::Network::HTTP::Pool.new
|
33
|
+
pool = Puppet::Network::HTTP::Pool.new(15)
|
34
34
|
connections.each do |conn|
|
35
35
|
pool.release(site, verifier, conn)
|
36
36
|
end
|
@@ -38,7 +38,7 @@ describe Puppet::Network::HTTP::Pool do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def create_pool_with_http_connections(site, *connections)
|
41
|
-
pool = Puppet::Network::HTTP::Pool.new
|
41
|
+
pool = Puppet::Network::HTTP::Pool.new(15)
|
42
42
|
connections.each do |conn|
|
43
43
|
pool.release(site, nil, conn)
|
44
44
|
end
|
@@ -422,6 +422,22 @@ describe Puppet::Node::Environment do
|
|
422
422
|
|
423
423
|
env.modules
|
424
424
|
end
|
425
|
+
|
426
|
+
it "includes the Bolt project in modules if it's defined" do
|
427
|
+
path = tmpdir('project')
|
428
|
+
PuppetSpec::Modules.generate_files('bolt_project', path)
|
429
|
+
project = Struct.new("Project", :name, :path).new('bolt_project', path)
|
430
|
+
|
431
|
+
Puppet.override(bolt_project: project) do
|
432
|
+
%w{foo bar}.each do |mod_name|
|
433
|
+
PuppetSpec::Modules.generate_files(mod_name, first_modulepath)
|
434
|
+
end
|
435
|
+
%w{bee baz}.each do |mod_name|
|
436
|
+
PuppetSpec::Modules.generate_files(mod_name, second_modulepath)
|
437
|
+
end
|
438
|
+
expect(env.modules.collect{|mod| mod.name}.sort).to eq(%w{bolt_project foo bar bee baz}.sort)
|
439
|
+
end
|
440
|
+
end
|
425
441
|
end
|
426
442
|
end
|
427
443
|
end
|
@@ -33,13 +33,18 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
33
33
|
let(:user1) { double(:account => 'user1', :domain => '.', :sid => 'user1sid') }
|
34
34
|
let(:user2) { double(:account => 'user2', :domain => '.', :sid => 'user2sid') }
|
35
35
|
let(:user3) { double(:account => 'user3', :domain => '.', :sid => 'user3sid') }
|
36
|
+
let(:user_without_domain) { double(:account => 'user_without_domain', :domain => nil, :sid => 'user_without_domain_sid') }
|
37
|
+
|
36
38
|
let(:invalid_user) { SecureRandom.uuid }
|
39
|
+
let(:invalid_user_principal) { double(:account => "#{invalid_user}", :domain => nil, :sid => "#{invalid_user}") }
|
37
40
|
|
38
41
|
before :each do
|
39
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user1').and_return(user1)
|
40
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2').and_return(user2)
|
41
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3').and_return(user3)
|
42
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user1', any_args).and_return(user1)
|
43
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2', any_args).and_return(user2)
|
44
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3', any_args).and_return(user3)
|
45
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user_without_domain', any_args).and_return(user_without_domain)
|
42
46
|
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with(invalid_user).and_return(nil)
|
47
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with(invalid_user, true).and_return(invalid_user_principal)
|
43
48
|
end
|
44
49
|
|
45
50
|
describe "#members_insync?" do
|
@@ -199,7 +204,15 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
199
204
|
]
|
200
205
|
expect(provider.members_insync?(current, ['user2','user1'])).to be_truthy
|
201
206
|
end
|
207
|
+
|
208
|
+
it "should return true even if a current user is unresolvable if should is included" do
|
209
|
+
current = [
|
210
|
+
"#{invalid_user}",
|
211
|
+
'user2',
|
212
|
+
]
|
213
|
+
expect(provider.members_insync?(current, ['user2'])).to be_truthy
|
202
214
|
end
|
215
|
+
end
|
203
216
|
end
|
204
217
|
|
205
218
|
describe "#members_to_s" do
|
@@ -222,8 +235,8 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
222
235
|
expect(provider.members_to_s(['user1', 'user2'])).to eq('.\user1,.\user2')
|
223
236
|
end
|
224
237
|
|
225
|
-
it "should return
|
226
|
-
expect(provider.members_to_s([
|
238
|
+
it "should return a user string without domain if domain is not set" do
|
239
|
+
expect(provider.members_to_s(['user_without_domain'])).to eq('user_without_domain')
|
227
240
|
end
|
228
241
|
|
229
242
|
it "should return the username when it cannot be resolved to a SID (for the sake of resource_harness error messages)" do
|
@@ -237,10 +250,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
237
250
|
let(:user2) { double(:account => 'user2', :domain => '.', :sid => 'user2sid') }
|
238
251
|
let(:user3) { double(:account => 'user3', :domain => '.', :sid => 'user3sid') }
|
239
252
|
|
253
|
+
let(:invalid_user) { SecureRandom.uuid }
|
254
|
+
let(:invalid_user_principal) { double(:account => "#{invalid_user}", :domain => nil, :sid => "#{invalid_user}") }
|
255
|
+
|
240
256
|
before :each do
|
241
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user1').and_return(user1)
|
242
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2').and_return(user2)
|
243
|
-
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3').and_return(user3)
|
257
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user1', any_args).and_return(user1)
|
258
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2', any_args).and_return(user2)
|
259
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3', any_args).and_return(user3)
|
260
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).with(invalid_user, true).and_return(invalid_user_principal)
|
244
261
|
|
245
262
|
resource[:auth_membership] = true
|
246
263
|
end
|
@@ -261,6 +278,22 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
261
278
|
expect(provider.members).to match_array(expected_members)
|
262
279
|
end
|
263
280
|
|
281
|
+
it "should be able to handle unresolvable SID in list of members" do
|
282
|
+
allow(provider.group).to receive(:members).and_return([
|
283
|
+
'user1',
|
284
|
+
"#{invalid_user}",
|
285
|
+
'user3',
|
286
|
+
])
|
287
|
+
|
288
|
+
expected_member_sids = [user1.sid, invalid_user_principal.sid, user3.sid]
|
289
|
+
expected_members = ['user1', "#{invalid_user}", 'user3']
|
290
|
+
allow(provider).to receive(:members_to_s)
|
291
|
+
.with(expected_member_sids)
|
292
|
+
.and_return(expected_members.join(','))
|
293
|
+
|
294
|
+
expect(provider.members).to match_array(expected_members)
|
295
|
+
end
|
296
|
+
|
264
297
|
it "should be able to set group members" do
|
265
298
|
allow(provider.group).to receive(:members).and_return(['user1', 'user2'])
|
266
299
|
|
@@ -272,8 +305,8 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
|
|
272
305
|
|
273
306
|
allow(provider.group).to receive(:member_sids).and_return(member_sids[0..1])
|
274
307
|
|
275
|
-
expect(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2').and_return(member_sids[1])
|
276
|
-
expect(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3').and_return(member_sids[2])
|
308
|
+
expect(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user2', any_args).and_return(member_sids[1])
|
309
|
+
expect(Puppet::Util::Windows::SID).to receive(:name_to_principal).with('user3', any_args).and_return(member_sids[2])
|
277
310
|
|
278
311
|
expect(provider.group).to receive(:remove_member_sids).with(member_sids[0])
|
279
312
|
expect(provider.group).to receive(:add_member_sids).with(member_sids[2])
|