puppet 5.5.6 → 5.5.7
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 +3 -1
- data/Gemfile.lock +12 -12
- data/Rakefile +9 -0
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/application/apply.rb +1 -0
- data/lib/puppet/application/master.rb +9 -7
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/defaults.rb +51 -31
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions.rb +123 -0
- data/lib/puppet/functions/new.rb +37 -53
- data/lib/puppet/functions/warning.rb +1 -1
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/parser/functions.rb +3 -1
- data/lib/puppet/parser/functions/sprintf.rb +12 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +16 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
- data/lib/puppet/pops/issues.rb +8 -0
- data/lib/puppet/pops/loader/loader.rb +2 -2
- data/lib/puppet/pops/loader/loader_paths.rb +3 -1
- data/lib/puppet/pops/loader/module_loaders.rb +1 -1
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
- data/lib/puppet/pops/loaders.rb +5 -21
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +31 -6
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/property/keyvalue.rb +70 -8
- data/lib/puppet/provider/aix_object.rb +483 -0
- data/lib/puppet/provider/exec.rb +54 -57
- data/lib/puppet/provider/group/aix.rb +40 -115
- data/lib/puppet/provider/group/pw.rb +4 -8
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -3
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +3 -10
- data/lib/puppet/provider/package/zypper.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/windows.rb +49 -40
- data/lib/puppet/provider/user/aix.rb +180 -246
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/exec.rb +16 -14
- data/lib/puppet/type/file.rb +2 -2
- data/lib/puppet/type/file/source.rb +9 -5
- data/lib/puppet/type/group.rb +65 -23
- data/lib/puppet/type/k5login.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +3 -6
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +8 -1
- data/lib/puppet/type/selboolean.rb +2 -2
- data/lib/puppet/type/selmodule.rb +3 -4
- data/lib/puppet/type/service.rb +2 -5
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +15 -20
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zone.rb +2 -2
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows.rb +4 -2
- data/lib/puppet/util/windows/adsi.rb +235 -205
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +977 -0
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/version.rb +1 -1
- data/locales/ja/puppet.po +705 -374
- data/locales/puppet.pot +485 -261
- data/man/man5/puppet.conf.5 +36 -15
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.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-master.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-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out +1 -0
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out +1 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +32 -0
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/adsi_spec.rb +6 -5
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/apply_spec.rb +41 -2
- data/spec/unit/application/master_spec.rb +7 -0
- data/spec/unit/application_spec.rb +21 -3
- data/spec/unit/defaults_spec.rb +20 -0
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/gettext/config_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +6 -6
- data/spec/unit/pops/loaders/loaders_spec.rb +40 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/validator/validator_spec.rb +129 -10
- data/spec/unit/property/keyvalue_spec.rb +97 -6
- data/spec/unit/provider/aix_object_spec.rb +805 -0
- data/spec/unit/provider/group/aix_spec.rb +57 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -6
- data/spec/unit/provider/group/windows_adsi_spec.rb +34 -35
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -2
- data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- data/spec/unit/provider/service/launchd_spec.rb +19 -0
- data/spec/unit/provider/service/windows_spec.rb +71 -78
- data/spec/unit/provider/user/aix_spec.rb +162 -116
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/ssl/certificate_authority_spec.rb +0 -1
- data/spec/unit/type/group_spec.rb +111 -13
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/windows/adsi_spec.rb +108 -13
- data/spec/unit/util/windows/service_spec.rb +669 -0
- metadata +17 -5
- data/lib/puppet/provider/aixobject.rb +0 -392
- data/spec/unit/provider/aixobject_spec.rb +0 -101
data/spec/unit/defaults_spec.rb
CHANGED
@@ -150,4 +150,24 @@ describe "Defaults" do
|
|
150
150
|
).to match(%r{.*/code/modules})
|
151
151
|
end
|
152
152
|
end
|
153
|
+
|
154
|
+
describe 'ordering' do
|
155
|
+
it 'issues a deprecation warning when set to title-hash' do
|
156
|
+
Puppet.expects(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering')
|
157
|
+
|
158
|
+
Puppet.settings[:ordering] = 'title-hash'
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'issues a deprecation warning when set to random' do
|
162
|
+
Puppet.expects(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering')
|
163
|
+
|
164
|
+
Puppet.settings[:ordering] = 'random'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'does not issue a deprecation warning when set to manifest' do
|
168
|
+
Puppet.expects(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering').never
|
169
|
+
|
170
|
+
Puppet.settings[:ordering] = 'manifest'
|
171
|
+
end
|
172
|
+
end
|
153
173
|
end
|
data/spec/unit/etc_spec.rb
CHANGED
@@ -412,6 +412,31 @@ describe Puppet::Etc, :if => !Puppet.features.microsoft_windows? do
|
|
412
412
|
end
|
413
413
|
end
|
414
414
|
|
415
|
+
describe :group do
|
416
|
+
it 'should return the next group struct if a block is not provided' do
|
417
|
+
Puppet::Etc.expects(:getgrent).returns(ascii_group_struct)
|
418
|
+
|
419
|
+
expect(Puppet::Etc.group).to eql(ascii_group_struct)
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'should iterate over the available groups if a block is provided' do
|
423
|
+
expected_groups = [
|
424
|
+
utf_8_group_struct,
|
425
|
+
euc_kr_group_struct,
|
426
|
+
ascii_group_struct
|
427
|
+
]
|
428
|
+
Puppet::Etc.stubs(:getgrent).returns(*(expected_groups + [nil]))
|
429
|
+
|
430
|
+
Puppet::Etc.expects(:setgrent)
|
431
|
+
Puppet::Etc.expects(:endgrent)
|
432
|
+
|
433
|
+
actual_groups = []
|
434
|
+
Puppet::Etc.group { |group| actual_groups << group }
|
435
|
+
|
436
|
+
expect(actual_groups).to eql(expected_groups)
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
415
440
|
describe "endgrent" do
|
416
441
|
it "should call Etc.getgrent" do
|
417
442
|
Etc.expects(:getgrent)
|
@@ -147,12 +147,12 @@ describe Puppet::FileServing::Fileset do
|
|
147
147
|
top_names = %w{one two .svn CVS}
|
148
148
|
sub_names = %w{file1 file2 .svn CVS 0 false}
|
149
149
|
|
150
|
-
Dir.stubs(:entries).with(path).returns(top_names)
|
150
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(top_names)
|
151
151
|
top_names.each do |subdir|
|
152
152
|
@files << subdir # relative path
|
153
153
|
subpath = File.join(path, subdir)
|
154
154
|
Puppet::FileSystem.stubs(stat_method).with(subpath).returns @dirstat
|
155
|
-
Dir.stubs(:entries).with(subpath).returns(sub_names)
|
155
|
+
Dir.stubs(:entries).with(subpath, encoding: Encoding::UTF_8).returns(sub_names)
|
156
156
|
sub_names.each do |file|
|
157
157
|
@files << File.join(subdir, file) # relative path
|
158
158
|
subfile_path = File.join(subpath, file)
|
@@ -173,7 +173,7 @@ describe Puppet::FileServing::Fileset do
|
|
173
173
|
extend Mocha::API
|
174
174
|
path = File.join(base_path, name)
|
175
175
|
Puppet::FileSystem.stubs(:lstat).with(path).returns MockStat.new(path, true)
|
176
|
-
Dir.stubs(:entries).with(path).returns(['.', '..'] + entries.map(&:name))
|
176
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(['.', '..'] + entries.map(&:name))
|
177
177
|
entries.each do |entry|
|
178
178
|
entry.mock(path)
|
179
179
|
end
|
@@ -295,7 +295,7 @@ describe Puppet::FileServing::Fileset do
|
|
295
295
|
link_path = File.join(path, "mylink")
|
296
296
|
Puppet::FileSystem.expects(:stat).with(link_path).raises(Errno::ENOENT)
|
297
297
|
|
298
|
-
Dir.stubs(:entries).with(path).returns(["mylink"])
|
298
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(["mylink"])
|
299
299
|
|
300
300
|
fileset = Puppet::FileServing::Fileset.new(path)
|
301
301
|
|
@@ -319,9 +319,9 @@ describe Puppet::FileServing::Fileset do
|
|
319
319
|
end
|
320
320
|
|
321
321
|
it "returns a hash of all files in each fileset with the value being the base path" do
|
322
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one uno})
|
323
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two dos})
|
324
|
-
Dir.expects(:entries).with(make_absolute("/third/path")).returns(%w{three tres})
|
322
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one uno})
|
323
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{two dos})
|
324
|
+
Dir.expects(:entries).with(make_absolute("/third/path"), encoding: Encoding::UTF_8).returns(%w{three tres})
|
325
325
|
|
326
326
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)).to eq({
|
327
327
|
"." => make_absolute("/first/path"),
|
@@ -335,15 +335,15 @@ describe Puppet::FileServing::Fileset do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "includes the base directory from the first fileset" do
|
338
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
339
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two})
|
338
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
339
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{two})
|
340
340
|
|
341
341
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)["."]).to eq(make_absolute("/first/path"))
|
342
342
|
end
|
343
343
|
|
344
344
|
it "uses the base path of the first found file when relative file paths conflict" do
|
345
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
346
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{one})
|
345
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
346
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
347
347
|
|
348
348
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)["one"]).to eq(make_absolute("/first/path"))
|
349
349
|
end
|
@@ -108,7 +108,7 @@ describe Puppet::GettextConfig do
|
|
108
108
|
describe "clearing the configured text domain" do
|
109
109
|
it 'succeeds' do
|
110
110
|
Puppet::GettextConfig.clear_text_domain
|
111
|
-
expect(FastGettext.text_domain).to
|
111
|
+
expect(FastGettext.text_domain).to eq(FastGettext.default_text_domain)
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'falls back to default' do
|
@@ -1102,15 +1102,15 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
1102
1102
|
end
|
1103
1103
|
|
1104
1104
|
it 'does not map :undef to empty string in arrays' do
|
1105
|
-
Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0][0] }
|
1106
|
-
expect(parser.evaluate_string(scope, "$a = {} $b = [$a[nope]] bazinga($b)", __FILE__)).to eq(
|
1107
|
-
expect(parser.evaluate_string(scope, "bazinga([undef])", __FILE__)).to eq(
|
1105
|
+
Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0][0] == :undef}
|
1106
|
+
expect(parser.evaluate_string(scope, "$a = {} $b = [$a[nope]] bazinga($b)", __FILE__)).to eq(true)
|
1107
|
+
expect(parser.evaluate_string(scope, "bazinga([undef])", __FILE__)).to eq(true)
|
1108
1108
|
end
|
1109
1109
|
|
1110
1110
|
it 'does not map :undef to empty string in hashes' do
|
1111
|
-
Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0]['a'] }
|
1112
|
-
expect(parser.evaluate_string(scope, "$a = {} $b = {a => $a[nope]} bazinga($b)", __FILE__)).to eq(
|
1113
|
-
expect(parser.evaluate_string(scope, "bazinga({a => undef})", __FILE__)).to eq(
|
1111
|
+
Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0]['a'] == :undef }
|
1112
|
+
expect(parser.evaluate_string(scope, "$a = {} $b = {a => $a[nope]} bazinga($b)", __FILE__)).to eq(true)
|
1113
|
+
expect(parser.evaluate_string(scope, "bazinga({a => undef})", __FILE__)).to eq(true)
|
1114
1114
|
end
|
1115
1115
|
end
|
1116
1116
|
end
|
@@ -271,7 +271,10 @@ describe 'loaders' do
|
|
271
271
|
File.stubs(:read).with(usee_metadata_path, {:encoding => 'utf-8'}).raises Errno::ENOENT
|
272
272
|
File.stubs(:read).with(usee2_metadata_path, {:encoding => 'utf-8'}).raises Errno::ENOENT
|
273
273
|
Puppet[:code] = "$case_number = #{case_number}\ninclude ::user"
|
274
|
-
|
274
|
+
catalog = compiler.compile
|
275
|
+
resource = catalog.resource('Notify', "case_#{case_number}")
|
276
|
+
expect(resource).not_to be_nil
|
277
|
+
expect(resource['message']).to eq(desc[:expects])
|
275
278
|
end
|
276
279
|
end
|
277
280
|
end
|
@@ -408,6 +411,36 @@ describe 'loaders' do
|
|
408
411
|
function = loader.load_typed(typed_name(:function, 'user::caller_ws')).value
|
409
412
|
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'passed in scope'")
|
410
413
|
end
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
context 'when causing a 3x load followed by a 4x load' do
|
418
|
+
let(:env) { environment_for(mix_4x_and_3x_functions) }
|
419
|
+
let(:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new("test", :environment => env)) }
|
420
|
+
let(:scope) { compiler.topscope }
|
421
|
+
let(:loader) { compiler.loaders.private_loader_for_module('user') }
|
422
|
+
|
423
|
+
|
424
|
+
before(:each) do
|
425
|
+
Puppet.push_context(:current_environment => scope.environment, :global_scope => scope, :loaders => compiler.loaders)
|
426
|
+
end
|
427
|
+
after(:each) do
|
428
|
+
Puppet.pop_context
|
429
|
+
end
|
430
|
+
|
431
|
+
it 'a 3x function is loaded once' do
|
432
|
+
# create a 3x function that when called will do a load of "callee_ws"
|
433
|
+
Puppet::Parser::Functions::newfunction(:callee, :type => :rvalue, :arity => 1) do |args|
|
434
|
+
function_callee_ws(['passed in scope'])
|
435
|
+
end
|
436
|
+
Puppet.expects(:warning).with(any_parameters).never
|
437
|
+
scope['passed_in_scope'] = 'value'
|
438
|
+
function = loader.load_typed(typed_name(:function, 'callee')).value
|
439
|
+
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'value'")
|
440
|
+
|
441
|
+
function = loader.load_typed(typed_name(:function, 'callee_ws')).value
|
442
|
+
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'value'")
|
443
|
+
end
|
411
444
|
end
|
412
445
|
|
413
446
|
context 'loading' do
|
@@ -576,22 +609,22 @@ describe 'loaders' do
|
|
576
609
|
expect(type).to be_a(Puppet::Pops::Types::PIntegerType)
|
577
610
|
end
|
578
611
|
|
579
|
-
it 'will
|
612
|
+
it 'will resolve implicit transitive dependencies, a -> c' do
|
580
613
|
type = Puppet::Pops::Types::TypeParser.singleton.parse('A::N', Puppet::Pops::Loaders.find_loader('a'))
|
581
614
|
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
582
615
|
expect(type.name).to eql('A::N')
|
583
616
|
type = type.resolved_type
|
584
|
-
expect(type).to be_a(Puppet::Pops::Types::
|
585
|
-
expect(type.
|
617
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
618
|
+
expect(type.name).to eql('C::C')
|
586
619
|
end
|
587
620
|
|
588
|
-
it 'will
|
621
|
+
it 'will resolve reverse dependencies, b -> a' do
|
589
622
|
type = Puppet::Pops::Types::TypeParser.singleton.parse('B::X', Puppet::Pops::Loaders.find_loader('b'))
|
590
623
|
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
591
624
|
expect(type.name).to eql('B::X')
|
592
625
|
type = type.resolved_type
|
593
|
-
expect(type).to be_a(Puppet::Pops::Types::
|
594
|
-
expect(type.
|
626
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
627
|
+
expect(type.name).to eql('A::A')
|
595
628
|
end
|
596
629
|
|
597
630
|
it 'does not resolve init_typeset when more qualified type is found in typeset' do
|
@@ -140,6 +140,22 @@ describe "egrammar parsing heredoc" do
|
|
140
140
|
].join("\n"))
|
141
141
|
end
|
142
142
|
|
143
|
+
it "parses interpolated [] expression by looking at the correct preceding char for space" do
|
144
|
+
# NOTE: Important not to use the left margin feature here
|
145
|
+
src = <<-CODE
|
146
|
+
$xxxxxxx = @("END")
|
147
|
+
${facts['os']['family']}
|
148
|
+
XXXXXXX XXX
|
149
|
+
END
|
150
|
+
CODE
|
151
|
+
expect(dump(parse(src))).to eq([
|
152
|
+
"(= $xxxxxxx (@()",
|
153
|
+
" (sublocated (cat (str (slice (slice $facts 'os') 'family')) '",
|
154
|
+
"XXXXXXX XXX",
|
155
|
+
"'))",
|
156
|
+
"))"].join("\n"))
|
157
|
+
end
|
158
|
+
|
143
159
|
it 'parses multiple heredocs on the same line' do
|
144
160
|
src = <<-CODE
|
145
161
|
notice({ @(foo) => @(bar) })
|
@@ -23,7 +23,11 @@ describe "validating 4x" do
|
|
23
23
|
|
24
24
|
def with_environment(environment, env_params = {})
|
25
25
|
override_env = environment
|
26
|
-
override_env = environment.override_with(
|
26
|
+
override_env = environment.override_with({
|
27
|
+
modulepath: env_params[:modulepath] || environment.full_modulepath,
|
28
|
+
manifest: env_params[:manifest] || environment.manifest,
|
29
|
+
config_version: env_params[:config_version] || environment.config_version
|
30
|
+
}) if env_params.count > 0
|
27
31
|
Puppet.override(current_environment: override_env) do
|
28
32
|
yield
|
29
33
|
end
|
@@ -72,15 +76,6 @@ describe "validating 4x" do
|
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
75
|
-
it 'should not raise error for legal definition locations' do
|
76
|
-
with_environment(environment, :manifest => 'a/manifest/file.pp') do
|
77
|
-
expect(validate(parse('function aaa::bbb() {}', 'path/aaa/manifests/bbb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
78
|
-
expect(validate(parse('class aaa() {}', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
79
|
-
expect(validate(parse('function aaa::bbB::ccc() {}', 'path/aaa/manifests/bBb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
80
|
-
expect(validate(parse('function aaa::bbb::ccc() {}', 'path/aaa/manifests/bbb/CCC.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
79
|
it 'should not raise error for definitions inside initial --manifest file' do
|
85
80
|
with_environment(environment, :manifest => 'a/manifest/file.pp') do
|
86
81
|
expect(validate(parse('class aaa() {}', 'a/manifest/file.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
@@ -100,6 +95,13 @@ describe "validating 4x" do
|
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
98
|
+
it 'should not raise error for empty files in modulepath' do
|
99
|
+
with_environment(environment) do
|
100
|
+
expect(validate(parse('', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
101
|
+
expect(validate(parse('#this is a comment', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
103
105
|
it 'should raise error if the file is in the modulepath but is not well formed' do
|
104
106
|
with_environment(environment) do
|
105
107
|
expect(validate(parse('class aaa::bbb::ccc() {}', 'path/manifest/aaa/bbb.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
@@ -113,6 +115,18 @@ describe "validating 4x" do
|
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
118
|
+
it 'should not raise error when one modulepath is a substring of another' do
|
119
|
+
with_environment(environment, modulepath: ['path', 'pathplus']) do
|
120
|
+
expect(validate(parse('class aaa::ccc() {}', 'pathplus/aaa/manifests/ccc.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should not raise error when a modulepath ends with a file separator' do
|
125
|
+
with_environment(environment, modulepath: ['path/']) do
|
126
|
+
expect(validate(parse('class aaa::ccc() {}', 'pathplus/aaa/manifests/ccc.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
116
130
|
it 'should raise error for illegal type names' do
|
117
131
|
expect(validate(parse('type ::Aaa = Any'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
|
118
132
|
end
|
@@ -145,6 +159,16 @@ describe "validating 4x" do
|
|
145
159
|
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
146
160
|
end
|
147
161
|
end
|
162
|
+
|
163
|
+
it 'produces a deprecation for illegal top level constructs' do
|
164
|
+
with_environment(environment) do
|
165
|
+
acceptor = validate(parse('$foo = 1', 'path/aaa/manifests/bbb.pp'))
|
166
|
+
expect(deprecation_count(acceptor)).to eql(1)
|
167
|
+
expect(acceptor.warning_count).to eql(1)
|
168
|
+
expect(acceptor.error_count).to eql(0)
|
169
|
+
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
170
|
+
end
|
171
|
+
end
|
148
172
|
end
|
149
173
|
|
150
174
|
context 'with --strict set to warning' do
|
@@ -179,6 +203,16 @@ describe "validating 4x" do
|
|
179
203
|
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
180
204
|
end
|
181
205
|
end
|
206
|
+
|
207
|
+
it 'produces a deprecation for illegal top level constructs' do
|
208
|
+
with_environment(environment) do
|
209
|
+
acceptor = validate(parse('$foo = 1', 'path/aaa/manifests/bbb.pp'))
|
210
|
+
expect(deprecation_count(acceptor)).to eql(1)
|
211
|
+
expect(acceptor.warning_count).to eql(1)
|
212
|
+
expect(acceptor.error_count).to eql(0)
|
213
|
+
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
214
|
+
end
|
215
|
+
end
|
182
216
|
end
|
183
217
|
|
184
218
|
context 'with --strict set to error' do
|
@@ -220,6 +254,16 @@ describe "validating 4x" do
|
|
220
254
|
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
221
255
|
end
|
222
256
|
end
|
257
|
+
|
258
|
+
it 'produces a deprecation for illegal top level constructs' do
|
259
|
+
with_environment(environment) do
|
260
|
+
acceptor = validate(parse('$foo = 1', 'path/aaa/manifests/bbb.pp'))
|
261
|
+
expect(deprecation_count(acceptor)).to eql(1)
|
262
|
+
expect(acceptor.warning_count).to eql(1)
|
263
|
+
expect(acceptor.error_count).to eql(0)
|
264
|
+
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
265
|
+
end
|
266
|
+
end
|
223
267
|
end
|
224
268
|
|
225
269
|
context 'with --strict set to off' do
|
@@ -240,6 +284,16 @@ describe "validating 4x" do
|
|
240
284
|
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
|
241
285
|
end
|
242
286
|
end
|
287
|
+
|
288
|
+
it 'produces a deprecation for illegal top level constructs' do
|
289
|
+
with_environment(environment) do
|
290
|
+
acceptor = validate(parse('$foo = 1', 'path/aaa/manifests/bbb.pp'))
|
291
|
+
expect(deprecation_count(acceptor)).to eql(1)
|
292
|
+
expect(acceptor.warning_count).to eql(1)
|
293
|
+
expect(acceptor.error_count).to eql(0)
|
294
|
+
expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
295
|
+
end
|
296
|
+
end
|
243
297
|
end
|
244
298
|
|
245
299
|
context 'irrespective of --strict' do
|
@@ -760,6 +814,71 @@ describe "validating 4x" do
|
|
760
814
|
end
|
761
815
|
end
|
762
816
|
|
817
|
+
context 'top level constructs' do
|
818
|
+
{
|
819
|
+
'a class' => 'class x{}',
|
820
|
+
'a define' => 'define x{}',
|
821
|
+
'a function' => 'function x() {}',
|
822
|
+
'a type alias' => 'type A = Data',
|
823
|
+
'a type alias for a complex type' => 'type C = Hash[String[1],Integer]',
|
824
|
+
'a type definition' => 'type A {}',
|
825
|
+
}.each_pair do |word, source|
|
826
|
+
it "will not have an issue with #{word} at the top level in a module" do
|
827
|
+
with_environment(environment) do
|
828
|
+
expect(validate(parse(source, 'path/x/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
829
|
+
end
|
830
|
+
end
|
831
|
+
end
|
832
|
+
end
|
833
|
+
|
834
|
+
context 'non-top level constructs' do
|
835
|
+
{
|
836
|
+
'an assignment' => '$foo = 1',
|
837
|
+
'a resource' => 'notify { nope: }',
|
838
|
+
'a resource default' => "Notify { message => 'yo' }",
|
839
|
+
'a function call' => "include 'foo'",
|
840
|
+
'a node definition' => 'node default {}',
|
841
|
+
'an expression' => '1+1',
|
842
|
+
'a conditional' => 'if true {42}',
|
843
|
+
'a literal value' => '42',
|
844
|
+
'a virtual collector' => 'User <| tag == web |>',
|
845
|
+
'an exported collector' => 'Sshkey <<| |>>',
|
846
|
+
}.each_pair do |word, source|
|
847
|
+
it "will have an issue with #{word} at the top level in a module" do
|
848
|
+
with_environment(environment) do
|
849
|
+
expect(validate(parse(source, 'path/x/manifests/init.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
850
|
+
end
|
851
|
+
end
|
852
|
+
|
853
|
+
it "will not have an issue with #{word} at top level not in a module" do
|
854
|
+
with_environment(environment) do
|
855
|
+
expect(validate(parse(source))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
|
856
|
+
end
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
it "will give multiple errors in one file with multiple issues" do
|
861
|
+
source = <<-SOURCE
|
862
|
+
class foo {}
|
863
|
+
notify { nope: }
|
864
|
+
node bar {}
|
865
|
+
|
866
|
+
$a = 7
|
867
|
+
SOURCE
|
868
|
+
|
869
|
+
with_environment(environment) do
|
870
|
+
acceptor = validate(parse(source, 'path/foo/manifests/init.pp'))
|
871
|
+
expect(deprecation_count(acceptor)).to eql(3)
|
872
|
+
expect(acceptor.warning_count).to eql(3)
|
873
|
+
expect(acceptor.error_count).to eql(0)
|
874
|
+
|
875
|
+
expect(acceptor.warnings[0].source_pos.line).to eql(2)
|
876
|
+
expect(acceptor.warnings[1].source_pos.line).to eql(3)
|
877
|
+
expect(acceptor.warnings[2].source_pos.line).to eql(5)
|
878
|
+
end
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
763
882
|
context "capability annotations" do
|
764
883
|
['produces', 'consumes'].each do |word|
|
765
884
|
it "rejects illegal resource types in #{word} clauses" do
|