puppet 6.22.1-x64-mingw32 → 6.23.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/Gemfile.lock +14 -14
- data/ext/osx/puppet.plist +2 -0
- data/lib/puppet/application/agent.rb +12 -5
- data/lib/puppet/application/apply.rb +2 -1
- data/lib/puppet/application/device.rb +2 -1
- data/lib/puppet/application/resource.rb +2 -1
- data/lib/puppet/application/script.rb +2 -1
- data/lib/puppet/configurer/downloader.rb +2 -1
- data/lib/puppet/defaults.rb +5 -3
- data/lib/puppet/file_serving/fileset.rb +14 -2
- data/lib/puppet/functions/all.rb +1 -1
- data/lib/puppet/functions/camelcase.rb +1 -1
- data/lib/puppet/functions/capitalize.rb +2 -2
- data/lib/puppet/functions/downcase.rb +2 -2
- data/lib/puppet/functions/get.rb +5 -5
- data/lib/puppet/functions/group_by.rb +13 -5
- data/lib/puppet/functions/lest.rb +1 -1
- data/lib/puppet/functions/new.rb +100 -100
- data/lib/puppet/functions/partition.rb +4 -4
- data/lib/puppet/functions/require.rb +5 -5
- data/lib/puppet/functions/sort.rb +3 -3
- data/lib/puppet/functions/tree_each.rb +7 -9
- data/lib/puppet/functions/type.rb +4 -4
- data/lib/puppet/functions/upcase.rb +2 -2
- data/lib/puppet/http/resolver/server_list.rb +15 -4
- data/lib/puppet/http/service/compiler.rb +69 -0
- data/lib/puppet/http/service/file_server.rb +2 -1
- data/lib/puppet/indirector/catalog/compiler.rb +1 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +1 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +14 -6
- data/lib/puppet/pops/types/p_sem_ver_type.rb +8 -2
- data/lib/puppet/pops/types/p_sensitive_type.rb +10 -0
- data/lib/puppet/provider/package/nim.rb +11 -6
- data/lib/puppet/provider/service/systemd.rb +13 -3
- data/lib/puppet/provider/service/windows.rb +38 -0
- data/lib/puppet/provider/user/directoryservice.rb +25 -12
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
- data/lib/puppet/type/file.rb +19 -1
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/service.rb +18 -38
- data/lib/puppet/type/tidy.rb +21 -2
- data/lib/puppet/type/user.rb +38 -20
- data/lib/puppet/util/selinux.rb +30 -4
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +109 -101
- data/man/man5/puppet.conf.5 +272 -252
- 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/127.0.0.1-key.pem +107 -57
- data/spec/fixtures/ssl/127.0.0.1.pem +52 -31
- data/spec/fixtures/ssl/bad-basic-constraints.pem +57 -35
- data/spec/fixtures/ssl/bad-int-basic-constraints.pem +57 -35
- data/spec/fixtures/ssl/ca.pem +57 -35
- data/spec/fixtures/ssl/crl.pem +28 -18
- data/spec/fixtures/ssl/ec-key.pem +11 -11
- data/spec/fixtures/ssl/ec.pem +33 -24
- data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
- data/spec/fixtures/ssl/encrypted-key.pem +108 -58
- data/spec/fixtures/ssl/intermediate-agent-crl.pem +28 -19
- data/spec/fixtures/ssl/intermediate-agent.pem +57 -36
- data/spec/fixtures/ssl/intermediate-crl.pem +31 -21
- data/spec/fixtures/ssl/intermediate.pem +57 -36
- data/spec/fixtures/ssl/pluto-key.pem +107 -57
- data/spec/fixtures/ssl/pluto.pem +52 -30
- data/spec/fixtures/ssl/request-key.pem +107 -57
- data/spec/fixtures/ssl/request.pem +47 -26
- data/spec/fixtures/ssl/revoked-key.pem +107 -57
- data/spec/fixtures/ssl/revoked.pem +52 -30
- data/spec/fixtures/ssl/signed-key.pem +107 -57
- data/spec/fixtures/ssl/signed.pem +52 -30
- data/spec/fixtures/ssl/tampered-cert.pem +52 -30
- data/spec/fixtures/ssl/tampered-csr.pem +47 -26
- data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +107 -57
- data/spec/fixtures/ssl/unknown-127.0.0.1.pem +50 -29
- data/spec/fixtures/ssl/unknown-ca-key.pem +107 -57
- data/spec/fixtures/ssl/unknown-ca.pem +55 -33
- data/spec/integration/application/resource_spec.rb +30 -0
- data/spec/lib/puppet/test_ca.rb +2 -2
- data/spec/unit/application/agent_spec.rb +7 -2
- data/spec/unit/configurer/downloader_spec.rb +6 -0
- data/spec/unit/configurer_spec.rb +23 -0
- data/spec/unit/file_serving/fileset_spec.rb +60 -0
- data/spec/unit/gettext/config_spec.rb +12 -0
- data/spec/unit/http/service/compiler_spec.rb +123 -0
- data/spec/unit/indirector/catalog/compiler_spec.rb +14 -10
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +15 -1
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +18 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +18 -0
- data/spec/unit/provider/package/nim_spec.rb +42 -0
- data/spec/unit/provider/service/init_spec.rb +1 -0
- data/spec/unit/provider/service/openwrt_spec.rb +3 -1
- data/spec/unit/provider/service/systemd_spec.rb +42 -8
- data/spec/unit/provider/service/windows_spec.rb +202 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +67 -35
- data/spec/unit/ssl/state_machine_spec.rb +19 -5
- data/spec/unit/transaction/additional_resource_generator_spec.rb +0 -2
- data/spec/unit/transaction_spec.rb +18 -20
- data/spec/unit/type/file/selinux_spec.rb +3 -3
- data/spec/unit/type/service_spec.rb +59 -188
- data/spec/unit/type/tidy_spec.rb +17 -7
- data/spec/unit/type/user_spec.rb +45 -0
- data/spec/unit/util/selinux_spec.rb +87 -16
- data/tasks/generate_cert_fixtures.rake +2 -2
- metadata +4 -2
@@ -81,6 +81,12 @@ describe Puppet::Configurer::Downloader do
|
|
81
81
|
expect(file[:source_permissions]).to eq(:ignore)
|
82
82
|
end
|
83
83
|
|
84
|
+
it "should ignore the max file limit" do
|
85
|
+
file = generate_file_resource
|
86
|
+
|
87
|
+
expect(file[:max_files]).to eq(-1)
|
88
|
+
end
|
89
|
+
|
84
90
|
describe "on POSIX", :if => Puppet.features.posix? do
|
85
91
|
it "should allow source_permissions to be overridden" do
|
86
92
|
file = generate_file_resource(:source_permissions => :use)
|
@@ -1072,6 +1072,29 @@ describe Puppet::Configurer do
|
|
1072
1072
|
}.to raise_error(Puppet::Error, /Could not select a functional puppet server from server_list: 'myserver:123,someotherservername'/)
|
1073
1073
|
end
|
1074
1074
|
|
1075
|
+
it "should warn when servers in 'server_list' are unreachable" do
|
1076
|
+
Puppet.settings[:server_list] = "mybadserver1:123,mybadserver2:123,mygoodserver"
|
1077
|
+
Puppet[:usecacheonfailure] = false
|
1078
|
+
|
1079
|
+
stub_request(:get, 'https://mybadserver1:123/status/v1/simple/master').and_raise(Puppet::HTTP::HTTPError)
|
1080
|
+
stub_request(:get, 'https://mybadserver2:123/status/v1/simple/master').and_raise(Puppet::HTTP::HTTPError)
|
1081
|
+
stub_request(:get, 'https://mygoodserver:8140/status/v1/simple/master').to_return(status: 200)
|
1082
|
+
|
1083
|
+
expect(Puppet).to receive(:warning).with(/^Unable to connect to server from server_list setting:.*Trying with next server from server_list.$/).twice
|
1084
|
+
configurer.run
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
it "should warn when servers in 'server_list' respond with error" do
|
1088
|
+
Puppet.settings[:server_list] = "mybadserver:123,someotherservername"
|
1089
|
+
Puppet[:usecacheonfailure] = false
|
1090
|
+
|
1091
|
+
stub_request(:get, 'https://mybadserver:123/status/v1/simple/master').to_return(status: 400)
|
1092
|
+
stub_request(:get, 'https://someotherservername:8140/status/v1/simple/master').to_return(status: 200)
|
1093
|
+
|
1094
|
+
expect(Puppet).to receive(:warning).with(/^Puppet server mybadserver:123 is unavailable: 400 Trying with next server from server_list.$/)
|
1095
|
+
configurer.run
|
1096
|
+
end
|
1097
|
+
|
1075
1098
|
it "should not error when usecacheonfailure is true and no servers in 'server_list' are reachable" do
|
1076
1099
|
Puppet.settings[:server_list] = "myserver:123,someotherservername"
|
1077
1100
|
Puppet[:usecacheonfailure] = true
|
@@ -46,6 +46,13 @@ describe Puppet::FileServing::Fileset do
|
|
46
46
|
expect(set.recurselimit).to eq(3)
|
47
47
|
end
|
48
48
|
|
49
|
+
it "accepts a 'max_files' option" do
|
50
|
+
expect(Puppet::FileSystem).to receive(:lstat).with(somefile).and_return(double('stat'))
|
51
|
+
set = Puppet::FileServing::Fileset.new(somefile, :recurselimit => 3, :max_files => 100)
|
52
|
+
expect(set.recurselimit).to eq(3)
|
53
|
+
expect(set.max_files).to eq(100)
|
54
|
+
end
|
55
|
+
|
49
56
|
it "accepts an 'ignore' option" do
|
50
57
|
expect(Puppet::FileSystem).to receive(:lstat).with(somefile).and_return(double('stat'))
|
51
58
|
set = Puppet::FileServing::Fileset.new(somefile, :ignore => ".svn")
|
@@ -160,6 +167,29 @@ describe Puppet::FileServing::Fileset do
|
|
160
167
|
end
|
161
168
|
end
|
162
169
|
|
170
|
+
def mock_big_dir_structure(path, stat_method = :lstat)
|
171
|
+
allow(Puppet::FileSystem).to receive(stat_method).with(path).and_return(@dirstat)
|
172
|
+
|
173
|
+
# Keep track of the files we're stubbing.
|
174
|
+
@files = %w{.}
|
175
|
+
|
176
|
+
top_names = (1..10).map {|i| "dir_#{i}" }
|
177
|
+
sub_names = (1..100).map {|i| "file__#{i}" }
|
178
|
+
|
179
|
+
allow(Dir).to receive(:entries).with(path, encoding: Encoding::UTF_8).and_return(top_names)
|
180
|
+
top_names.each do |subdir|
|
181
|
+
@files << subdir # relative path
|
182
|
+
subpath = File.join(path, subdir)
|
183
|
+
allow(Puppet::FileSystem).to receive(stat_method).with(subpath).and_return(@dirstat)
|
184
|
+
allow(Dir).to receive(:entries).with(subpath, encoding: Encoding::UTF_8).and_return(sub_names)
|
185
|
+
sub_names.each do |file|
|
186
|
+
@files << File.join(subdir, file) # relative path
|
187
|
+
subfile_path = File.join(subpath, file)
|
188
|
+
allow(Puppet::FileSystem).to receive(stat_method).with(subfile_path).and_return(@filestat)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
163
193
|
def setup_mocks_for_dir(mock_dir, base_path)
|
164
194
|
path = File.join(base_path, mock_dir.name)
|
165
195
|
allow(Puppet::FileSystem).to receive(:lstat).with(path).and_return(MockStat.new(path, true))
|
@@ -258,6 +288,36 @@ describe Puppet::FileServing::Fileset do
|
|
258
288
|
expect(@fileset.files.find { |file| file.include?("0") }).to be_nil
|
259
289
|
end
|
260
290
|
|
291
|
+
it "raises exception if number of files is greater than :max_files" do
|
292
|
+
mock_dir_structure(@path)
|
293
|
+
@fileset.recurse = true
|
294
|
+
@fileset.max_files = 22
|
295
|
+
expect { @fileset.files }.to raise_error(Puppet::Error, "The directory '#{@path}' contains 28 entries, which exceeds the limit of 22 specified by the max_files parameter for this resource. The limit may be increased, but be aware that large number of file resources can result in excessive resource consumption and degraded performance. Consider using an alternate method to manage large directory trees")
|
296
|
+
end
|
297
|
+
|
298
|
+
it "logs a warning if number of files is greater than soft max_files limit of 1000" do
|
299
|
+
mock_big_dir_structure(@path)
|
300
|
+
@fileset.recurse = true
|
301
|
+
expect(Puppet).to receive(:warning).with("The directory '#{@path}' contains 1010 entries, which exceeds the default soft limit 1000 and may cause excessive resource consumption and degraded performance. To remove this warning set a value for `max_files` parameter or consider using an alternate method to manage large directory trees")
|
302
|
+
expect { @fileset.files }.to_not raise_error
|
303
|
+
end
|
304
|
+
|
305
|
+
it "does not emit a warning if max_files is -1" do
|
306
|
+
mock_big_dir_structure(@path)
|
307
|
+
@fileset.recurse = true
|
308
|
+
@fileset.max_files = -1
|
309
|
+
expect(Puppet).to receive(:warning).never
|
310
|
+
@fileset.files
|
311
|
+
end
|
312
|
+
|
313
|
+
it "does not emit a warning if max_files is `-1`(string)" do
|
314
|
+
mock_big_dir_structure(@path)
|
315
|
+
@fileset.recurse = true
|
316
|
+
@fileset.max_files = '-1'
|
317
|
+
expect(Puppet).to receive(:warning).never
|
318
|
+
@fileset.files
|
319
|
+
end
|
320
|
+
|
261
321
|
it "ignores files that match a pattern given as a boolean" do
|
262
322
|
mock_dir_structure(@path)
|
263
323
|
@fileset.recurse = true
|
@@ -27,6 +27,18 @@ describe Puppet::GettextConfig do
|
|
27
27
|
Puppet::GettextConfig.delete_all_text_domains
|
28
28
|
end
|
29
29
|
|
30
|
+
# These tests assume gettext is enabled, but it will be disabled when the
|
31
|
+
# first time the `Puppet[:disable_i18n]` setting is resolved
|
32
|
+
around(:each) do |example|
|
33
|
+
disabled = Puppet::GettextConfig.instance_variable_get(:@gettext_disabled)
|
34
|
+
Puppet::GettextConfig.instance_variable_set(:@gettext_disabled, false)
|
35
|
+
begin
|
36
|
+
example.run
|
37
|
+
ensure
|
38
|
+
Puppet::GettextConfig.instance_variable_set(:@gettext_disabled, disabled)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
describe 'setting and getting the locale' do
|
31
43
|
it 'should return "en" when gettext is unavailable' do
|
32
44
|
allow(Puppet::GettextConfig).to receive(:gettext_loaded?).and_return(false)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
# coding: utf-8
|
2
3
|
require 'spec_helper'
|
3
4
|
require 'puppet/http'
|
@@ -258,6 +259,128 @@ describe Puppet::HTTP::Service::Compiler do
|
|
258
259
|
end
|
259
260
|
end
|
260
261
|
|
262
|
+
context 'when posting for a v4 catalog' do
|
263
|
+
let(:uri) {"https://compiler.example.com:8140/puppet/v4/catalog"}
|
264
|
+
let(:persistence) {{ facts: true, catalog: true }}
|
265
|
+
let(:facts) {{ 'foo' => 'bar' }}
|
266
|
+
let(:trusted_facts) {{}}
|
267
|
+
let(:uuid) { "ec3d2844-b236-4287-b0ad-632fbb4d1ff0" }
|
268
|
+
let(:job_id) { "1" }
|
269
|
+
let(:payload) {{
|
270
|
+
environment: environment,
|
271
|
+
persistence: persistence,
|
272
|
+
facts: facts,
|
273
|
+
trusted_facts: trusted_facts,
|
274
|
+
transaction_uuid: uuid,
|
275
|
+
job_id: job_id,
|
276
|
+
options: {
|
277
|
+
prefer_requested_environment: false,
|
278
|
+
capture_logs: false
|
279
|
+
}
|
280
|
+
}}
|
281
|
+
let(:serialized_catalog) {{ 'catalog' => catalog.to_data_hash }.to_json}
|
282
|
+
let(:catalog_response) {{ body: serialized_catalog, headers: {'Content-Type' => formatter.mime }}}
|
283
|
+
|
284
|
+
it 'includes default HTTP headers' do
|
285
|
+
stub_request(:post, uri).with do |request|
|
286
|
+
expect(request.headers).to include({'X-Puppet-Version' => /./, 'User-Agent' => /./})
|
287
|
+
expect(request.headers).to_not include('X-Puppet-Profiling')
|
288
|
+
end.to_return(**catalog_response)
|
289
|
+
|
290
|
+
subject.post_catalog4(certname, **payload)
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'defaults the server and port based on settings' do
|
294
|
+
Puppet[:server] = 'compiler2.example.com'
|
295
|
+
Puppet[:serverport] = 8141
|
296
|
+
|
297
|
+
stub_request(:post, "https://compiler2.example.com:8141/puppet/v4/catalog")
|
298
|
+
.to_return(**catalog_response)
|
299
|
+
|
300
|
+
subject.post_catalog4(certname, **payload)
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'includes puppet headers set via the :http_extra_headers and :profile settings' do
|
304
|
+
stub_request(:post, uri).with(headers: {'Example-Header' => 'real-thing', 'another' => 'thing', 'X-Puppet-Profiling' => 'true'}).
|
305
|
+
to_return(**catalog_response)
|
306
|
+
|
307
|
+
Puppet[:http_extra_headers] = 'Example-Header:real-thing,another:thing'
|
308
|
+
Puppet[:profile] = true
|
309
|
+
|
310
|
+
subject.post_catalog4(certname, **payload)
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'returns a deserialized catalog' do
|
314
|
+
stub_request(:post, uri)
|
315
|
+
.to_return(**catalog_response)
|
316
|
+
|
317
|
+
_, cat, _ = subject.post_catalog4(certname, **payload)
|
318
|
+
expect(cat).to be_a(Puppet::Resource::Catalog)
|
319
|
+
expect(cat.name).to eq(certname)
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'returns the request response' do
|
323
|
+
stub_request(:post, uri)
|
324
|
+
.to_return(**catalog_response)
|
325
|
+
|
326
|
+
resp, _, _ = subject.post_catalog4(certname, **payload)
|
327
|
+
expect(resp).to be_a(Puppet::HTTP::Response)
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'raises a response error if unsuccessful' do
|
331
|
+
stub_request(:post, uri)
|
332
|
+
.to_return(status: [500, "Server Error"])
|
333
|
+
|
334
|
+
expect {
|
335
|
+
subject.post_catalog4(certname, **payload)
|
336
|
+
}.to raise_error do |err|
|
337
|
+
expect(err).to be_an_instance_of(Puppet::HTTP::ResponseError)
|
338
|
+
expect(err.message).to eq('Server Error')
|
339
|
+
expect(err.response.code).to eq(500)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'raises a response error when server response is not JSON' do
|
344
|
+
stub_request(:post, uri)
|
345
|
+
.to_return(body: "this isn't valid JSON", headers: {'Content-Type' => 'application/json'})
|
346
|
+
|
347
|
+
expect {
|
348
|
+
subject.post_catalog4(certname, **payload)
|
349
|
+
}.to raise_error do |err|
|
350
|
+
expect(err).to be_an_instance_of(Puppet::HTTP::SerializationError)
|
351
|
+
expect(err.message).to match(/Failed to deserialize catalog from puppetserver response/)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'raises a response error when server response a JSON serialized catalog' do
|
356
|
+
stub_request(:post, uri)
|
357
|
+
.to_return(body: {oops: 'bad response data'}.to_json, headers: {'Content-Type' => 'application/json'})
|
358
|
+
|
359
|
+
expect {
|
360
|
+
subject.post_catalog4(certname, **payload)
|
361
|
+
}.to raise_error do |err|
|
362
|
+
expect(err).to be_an_instance_of(Puppet::HTTP::SerializationError)
|
363
|
+
expect(err.message).to match(/Failed to deserialize catalog from puppetserver response/)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'raises ArgumentError when the `persistence` hash does not contain required keys' do
|
368
|
+
payload[:persistence].delete(:facts)
|
369
|
+
expect { subject.post_catalog4(certname, **payload) }.to raise_error do |err|
|
370
|
+
expect(err).to be_an_instance_of(ArgumentError)
|
371
|
+
expect(err.message).to match(/The 'persistence' hash is missing the keys: facts/)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
it 'raises ArgumentError when `facts` are not a Hash' do
|
376
|
+
payload[:facts] = Puppet::Node::Facts.new(certname)
|
377
|
+
expect { subject.post_catalog4(certname, **payload) }.to raise_error do |err|
|
378
|
+
expect(err).to be_an_instance_of(ArgumentError)
|
379
|
+
expect(err.message).to match(/Facts must be a Hash not a Puppet::Node::Facts/)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
261
384
|
context 'when getting a node' do
|
262
385
|
let(:uri) { %r{/puppet/v3/node/ziggy} }
|
263
386
|
let(:node_response) { { body: formatter.render(node), headers: {'Content-Type' => formatter.mime } } }
|
@@ -909,9 +909,10 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
909
909
|
it "inlines child metadata" do
|
910
910
|
catalog = compile_to_catalog(<<-MANIFEST, node)
|
911
911
|
file { '#{path}':
|
912
|
-
ensure
|
913
|
-
recurse
|
914
|
-
source
|
912
|
+
ensure => directory,
|
913
|
+
recurse => true,
|
914
|
+
source => '#{source_dir}',
|
915
|
+
max_files => 1234,
|
915
916
|
}
|
916
917
|
MANIFEST
|
917
918
|
|
@@ -925,6 +926,7 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
925
926
|
:source_permissions => :ignore,
|
926
927
|
:recurse => true,
|
927
928
|
:recurselimit => nil,
|
929
|
+
:max_files => 1234,
|
928
930
|
:ignore => nil,
|
929
931
|
}
|
930
932
|
expect(Puppet::FileServing::Metadata.indirection).to receive(:search).with(source_dir, options).and_return([metadata, child_metadata])
|
@@ -938,14 +940,15 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
938
940
|
it "uses resource parameters when inlining metadata" do
|
939
941
|
catalog = compile_to_catalog(<<-MANIFEST, node)
|
940
942
|
file { '#{path}':
|
941
|
-
ensure
|
942
|
-
recurse
|
943
|
-
source
|
944
|
-
checksum
|
943
|
+
ensure => directory,
|
944
|
+
recurse => true,
|
945
|
+
source => '#{source_dir}',
|
946
|
+
checksum => sha256,
|
945
947
|
source_permissions => use_when_creating,
|
946
|
-
recurselimit
|
947
|
-
|
948
|
-
|
948
|
+
recurselimit => 2,
|
949
|
+
max_files => 4321,
|
950
|
+
ignore => 'foo.+',
|
951
|
+
links => follow,
|
949
952
|
}
|
950
953
|
MANIFEST
|
951
954
|
|
@@ -956,6 +959,7 @@ describe Puppet::Resource::Catalog::Compiler do
|
|
956
959
|
:source_permissions => :use_when_creating,
|
957
960
|
:recurse => true,
|
958
961
|
:recurselimit => 2,
|
962
|
+
:max_files => 4321,
|
959
963
|
:ignore => 'foo.+',
|
960
964
|
}
|
961
965
|
expect(Puppet::FileServing::Metadata.indirection).to receive(:search).with(source_dir, options).and_return([metadata, child_metadata])
|
@@ -61,12 +61,26 @@ describe "the fqdn_rand function" do
|
|
61
61
|
expect(fqdn_rand(5000, :extra_identifier => ['expensive job 33'])).to eql(2389)
|
62
62
|
end
|
63
63
|
|
64
|
+
it "returns the same value if only host differs by case" do
|
65
|
+
val1 = fqdn_rand(1000000000, :host => "host.example.com", :extra_identifier => [nil, true])
|
66
|
+
val2 = fqdn_rand(1000000000, :host => "HOST.example.com", :extra_identifier => [nil, true])
|
67
|
+
|
68
|
+
expect(val1).to eql(val2)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns the same value if only host differs by case and an initial seed is given" do
|
72
|
+
val1 = fqdn_rand(1000000000, :host => "host.example.com", :extra_identifier => ['a seed', true])
|
73
|
+
val2 = fqdn_rand(1000000000, :host => "HOST.example.com", :extra_identifier => ['a seed', true])
|
74
|
+
|
75
|
+
expect(val1).to eql(val2)
|
76
|
+
end
|
77
|
+
|
64
78
|
def fqdn_rand(max, args = {})
|
65
79
|
host = args[:host] || '127.0.0.1'
|
66
80
|
extra = args[:extra_identifier] || []
|
67
81
|
|
68
82
|
scope = create_test_scope_for_node('localhost')
|
69
|
-
|
83
|
+
scope.compiler.topscope['fqdn'] = host.freeze
|
70
84
|
|
71
85
|
scope.function_fqdn_rand([max] + extra)
|
72
86
|
end
|
@@ -125,6 +125,24 @@ describe 'Semantic Versions' do
|
|
125
125
|
expect(eval_and_collect_notices(code)).to eql(['true', 'false'])
|
126
126
|
end
|
127
127
|
|
128
|
+
it 'can be compared to another instance created from arguments' do
|
129
|
+
code = <<-CODE
|
130
|
+
$x = SemVer('1.2.3-rc4+5')
|
131
|
+
$y = SemVer(1, 2, 3, 'rc4', '5')
|
132
|
+
notice($x == $y)
|
133
|
+
CODE
|
134
|
+
expect(eval_and_collect_notices(code)).to eql(['true'])
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'can be compared to another instance created from a hash' do
|
138
|
+
code = <<-CODE
|
139
|
+
$x = SemVer('1.2.3-rc4+5')
|
140
|
+
$y = SemVer(major => 1, minor => 2, patch => 3, prerelease => 'rc4', build => '5')
|
141
|
+
notice($x == $y)
|
142
|
+
CODE
|
143
|
+
expect(eval_and_collect_notices(code)).to eql(['true'])
|
144
|
+
end
|
145
|
+
|
128
146
|
it 'can be compared to another instance for magnitude' do
|
129
147
|
code = <<-CODE
|
130
148
|
$x = SemVer('1.1.1')
|
@@ -113,6 +113,24 @@ describe 'Sensitive Type' do
|
|
113
113
|
expect(eval_and_collect_notices(code)).to eq(['Sensitive[Integer] != Sensitive[String]'])
|
114
114
|
end
|
115
115
|
|
116
|
+
it 'equals another instance with the same value' do
|
117
|
+
code =<<-CODE
|
118
|
+
$i = Sensitive('secret')
|
119
|
+
$o = Sensitive('secret')
|
120
|
+
notice($i == $o)
|
121
|
+
CODE
|
122
|
+
expect(eval_and_collect_notices(code)).to eq(['true'])
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'has equal hash keys for same values' do
|
126
|
+
code =<<-CODE
|
127
|
+
$i = Sensitive('secret')
|
128
|
+
$o = Sensitive('secret')
|
129
|
+
notice({$i => 1} == {$o => 1})
|
130
|
+
CODE
|
131
|
+
expect(eval_and_collect_notices(code)).to eq(['true'])
|
132
|
+
end
|
133
|
+
|
116
134
|
it 'can be created from another sensitive instance ' do
|
117
135
|
code =<<-CODE
|
118
136
|
$o = Sensitive("hunter2")
|
@@ -191,6 +191,27 @@ OUTPUT
|
|
191
191
|
expect(versions[version]).to eq(:rpm)
|
192
192
|
end
|
193
193
|
end
|
194
|
+
|
195
|
+
it "should be able to parse RPM package listings with letters in version" do
|
196
|
+
showres_output = <<END
|
197
|
+
cairo ALL @@R:cairo _all_filesets
|
198
|
+
@@R:cairo-1.14.6-2waixX11 1.14.6-2waixX11
|
199
|
+
END
|
200
|
+
packages = subject.send(:parse_showres_output, showres_output)
|
201
|
+
expect(Set.new(packages.keys)).to eq(Set.new(['cairo']))
|
202
|
+
versions = packages['cairo']
|
203
|
+
expect(versions.has_key?('1.14.6-2waixX11')).to eq(true)
|
204
|
+
expect(versions['1.14.6-2waixX11']).to eq(:rpm)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should raise error when parsing invalid RPM package listings" do
|
208
|
+
showres_output = <<END
|
209
|
+
cairo ALL @@R:cairo _all_filesets
|
210
|
+
@@R:cairo-invalid_version invalid_version
|
211
|
+
END
|
212
|
+
expect{ subject.send(:parse_showres_output, showres_output) }.to raise_error(Puppet::Error,
|
213
|
+
/Unable to parse output from nimclient showres: package string does not match expected rpm package string format/)
|
214
|
+
end
|
194
215
|
end
|
195
216
|
|
196
217
|
context "#determine_latest_version" do
|
@@ -220,6 +241,27 @@ END
|
|
220
241
|
it "should return :installp for installp/bff packages" do
|
221
242
|
expect(subject.send(:determine_package_type, bff_showres_output, 'mypackage.foo', '1.2.3.4')).to eq(:installp)
|
222
243
|
end
|
244
|
+
|
245
|
+
it "should return :installp for security updates" do
|
246
|
+
nimclient_showres_output = <<END
|
247
|
+
bos.net ALL @@S:bos.net _all_filesets
|
248
|
+
+ 7.2.0.1 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.1
|
249
|
+
+ 7.2.0.2 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.2
|
250
|
+
|
251
|
+
END
|
252
|
+
expect(subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2')).to eq(:installp)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should raise error when invalid header format is given" do
|
256
|
+
nimclient_showres_output = <<END
|
257
|
+
bos.net ALL @@INVALID_TYPE:bos.net _all_filesets
|
258
|
+
+ 7.2.0.1 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.1
|
259
|
+
+ 7.2.0.2 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.2
|
260
|
+
|
261
|
+
END
|
262
|
+
expect{ subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2') }.to raise_error(
|
263
|
+
Puppet::Error, /Unable to parse output from nimclient showres: line does not match expected package header format/)
|
264
|
+
end
|
223
265
|
end
|
224
266
|
end
|
225
267
|
end
|