puppet 4.0.0.rc1-x64-mingw32 → 4.0.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 +7 -0
- data/CONTRIBUTING.md +11 -6
- data/Gemfile +1 -1
- data/conf/environment.conf +4 -2
- data/ext/build_defaults.yaml +3 -3
- data/ext/debian/control +2 -2
- data/ext/project_data.yaml +1 -1
- data/ext/rack/config.ru +1 -0
- data/ext/redhat/client.sysconfig +1 -1
- data/ext/redhat/puppet.spec.erb +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +2 -2
- data/lib/puppet/application/device.rb +22 -5
- data/lib/puppet/data_providers.rb +7 -4
- data/lib/puppet/data_providers/data_adapter.rb +6 -1
- data/lib/puppet/data_providers/data_function_support.rb +17 -4
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -1
- data/lib/puppet/data_providers/function_module_data_provider.rb +14 -19
- data/lib/puppet/defaults.rb +43 -16
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +33 -4
- data/lib/puppet/pops/evaluator/runtime3_support.rb +5 -1
- data/lib/puppet/pops/parser/egrammar.ra +2 -0
- data/lib/puppet/pops/parser/eparser.rb +732 -724
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/lexer2.rb +19 -21
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +19 -6
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +17 -0
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +2 -2
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/util/errors.rb +4 -2
- data/lib/puppet/util/network_device/config.rb +5 -0
- data/lib/puppet/util/run_mode.rb +28 -11
- data/lib/puppet/util/windows/registry.rb +3 -3
- data/lib/puppet/vendor/deep_merge/PUPPET_README.md +6 -0
- data/lib/puppet/vendor/load_plist.rb +1 -0
- data/lib/puppet/vendor/plist/CHANGELOG +82 -0
- data/lib/puppet/vendor/plist/MIT-LICENSE +21 -0
- data/lib/puppet/vendor/plist/PUPPET_README.md +6 -0
- data/lib/puppet/vendor/plist/README +36 -0
- data/lib/puppet/vendor/plist/Rakefile +144 -0
- data/lib/puppet/vendor/plist/docs/USAGE +104 -0
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +591 -0
- data/lib/puppet/vendor/plist/lib/plist.rb +22 -0
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +224 -0
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +225 -0
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +203 -0
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +104 -0
- data/lib/puppet/vendor/plist/test/assets/commented.plist +9 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +259 -0
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +24 -0
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +13 -0
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +115 -0
- data/lib/puppet/vendor/plist/test/test_generator.rb +59 -0
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +58 -0
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +82 -0
- data/lib/puppet/vendor/plist/test/test_parser.rb +90 -0
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +5 -13
- data/man/man8/extlookup2hiera.8 +1 -1
- 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-file.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-inspect.8 +1 -1
- data/man/man8/puppet-key.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-resource_type.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/lib/puppet/functions/environment/data.rb +8 -6
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +4 -4
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +6 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bca/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/no_provider/manifests/init.pp +2 -0
- data/spec/integration/provider/yumrepo_spec.rb +127 -0
- data/spec/unit/application/device_spec.rb +52 -14
- data/spec/unit/functions/lookup_spec.rb +95 -55
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +0 -18
- data/spec/unit/pops/parser/lexer2_spec.rb +26 -16
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +21 -0
- data/spec/unit/pops/validator/validator_spec.rb +2 -3
- data/spec/unit/provider/macauthorization_spec.rb +1 -1
- data/spec/unit/provider/package/gem_spec.rb +201 -139
- data/spec/unit/provider/package/puppet_gem_spec.rb +67 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
- data/spec/unit/util/network_device/config_spec.rb +6 -0
- data/spec/unit/util/run_mode_spec.rb +26 -26
- data/spec/unit/util/windows/registry_spec.rb +4 -3
- metadata +3016 -2994
@@ -0,0 +1,9 @@
|
|
1
|
+
Puppet::Functions.create_function(:'bca::data') do
|
2
|
+
def data()
|
3
|
+
{ 'bca::b' => 'module_bca_b',
|
4
|
+
'bca::c' => 'module_bca_c',
|
5
|
+
'bca::e' => { 'k1' => 'module_bca_e1', 'k2' => 'module_bca_e2' },
|
6
|
+
'bca::f' => { 'k1' => { 's1' => 'module_bca_f11', 's3' => 'module_bca_f13' }, 'k2' => { 's1' => 'module_bca_f21', 's2' => 'module_bca_f22' }},
|
7
|
+
}
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'puppet/file_bucket/dipper'
|
5
|
+
require 'puppet_spec/files'
|
6
|
+
require 'puppet_spec/compiler'
|
7
|
+
|
8
|
+
describe Puppet::Type.type(:yumrepo).provider(:inifile), '(integration)',
|
9
|
+
:unless => Puppet.features.microsoft_windows? do
|
10
|
+
include PuppetSpec::Files
|
11
|
+
include PuppetSpec::Compiler
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
# Don't backup to filebucket
|
15
|
+
Puppet::FileBucket::Dipper.any_instance.stubs(:backup)
|
16
|
+
# We don't want to execute anything
|
17
|
+
described_class.stubs(:filetype).
|
18
|
+
returns Puppet::Util::FileType::FileTypeFlat
|
19
|
+
|
20
|
+
@yumrepo_dir = tmpdir('yumrepo_integration_specs')
|
21
|
+
@yumrepo_file = tmpfile('yumrepo_file', @yumrepo_dir)
|
22
|
+
@yumrepo_conf_file = tmpfile('yumrepo_conf_file', @yumrepo_dir)
|
23
|
+
# this mocks the reposdir logic in the provider and thus won't test for
|
24
|
+
# issues like PUP-2916. Cover these types of issues in acceptance
|
25
|
+
described_class.stubs(:reposdir).returns [@yumrepo_dir]
|
26
|
+
described_class.stubs(:repofiles).returns [@yumrepo_conf_file]
|
27
|
+
end
|
28
|
+
|
29
|
+
after :each do
|
30
|
+
# yumrepo provider class
|
31
|
+
described_class.clear
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:type_under_test) { :yumrepo }
|
35
|
+
|
36
|
+
describe 'when managing a yumrepo file it...' do
|
37
|
+
let(:super_creative) { 'my.super.creati.ve' }
|
38
|
+
let(:manifest) {
|
39
|
+
"#{type_under_test} { '#{super_creative}':
|
40
|
+
baseurl => 'http://#{super_creative}',
|
41
|
+
target => '#{@yumrepo_file}' }"
|
42
|
+
}
|
43
|
+
let(:expected_match) { "\[#{super_creative}\]\nbaseurl=http:\/\/my\.super\.creati\.ve" }
|
44
|
+
|
45
|
+
it 'should create a new yumrepo file with mode 0644 and yumrepo entry' do
|
46
|
+
apply_with_error_check(manifest)
|
47
|
+
expect_file_mode(File.join(@yumrepo_dir, super_creative + '.repo'), "644")
|
48
|
+
expect(File.read(File.join(@yumrepo_dir, super_creative + '.repo'))).
|
49
|
+
to match(expected_match + "\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should remove a managed yumrepo entry' do
|
53
|
+
apply_with_error_check(manifest)
|
54
|
+
manifest = "#{type_under_test} { '#{super_creative}':
|
55
|
+
ensure => absent,
|
56
|
+
target => '#{@yumrepo_file}' }"
|
57
|
+
apply_with_error_check(manifest)
|
58
|
+
expect(File.read(File.join(@yumrepo_dir, super_creative + '.repo'))).
|
59
|
+
to be_empty
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should update a managed yumrepo entry' do
|
63
|
+
apply_with_error_check(manifest)
|
64
|
+
manifest = "#{type_under_test} { '#{super_creative}':
|
65
|
+
baseurl => 'http://#{super_creative}.updated',
|
66
|
+
target => '#{@yumrepo_file}' }"
|
67
|
+
apply_with_error_check(manifest)
|
68
|
+
expect(File.read(File.join(@yumrepo_dir, super_creative + '.repo'))).
|
69
|
+
to match(expected_match + ".updated\n")
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should create all properties of a yumrepo entry' do
|
73
|
+
manifest = "#{type_under_test} { '#{super_creative}':
|
74
|
+
baseurl => 'http://#{super_creative}',
|
75
|
+
target => '#{@yumrepo_file}' }"
|
76
|
+
apply_with_error_check(manifest)
|
77
|
+
expect(File.read(File.join(@yumrepo_dir, super_creative + '.repo'))).
|
78
|
+
to match("\[#{super_creative}\]")
|
79
|
+
end
|
80
|
+
|
81
|
+
# The unit-tests cover all properties
|
82
|
+
# and we have to hard-code the "should" values here.
|
83
|
+
# Puppet::Type.type(:yumrepo).validproperties contains the full list
|
84
|
+
# but we can't get the property "should" values from the yumrepo-type
|
85
|
+
# without having an instance of type, which is what yumrepo defines...
|
86
|
+
# Just cover the most probable used properties.
|
87
|
+
properties = {"bandwidth" => "42M",
|
88
|
+
"baseurl" => "http://er0ck",
|
89
|
+
"cost" => "42",
|
90
|
+
"enabled" => "YeS",
|
91
|
+
"exclude" => "er0ckSet2.0",
|
92
|
+
"failovermethod" => "roundrobin",
|
93
|
+
"include" => "https://er0ck",
|
94
|
+
"mirrorlist" => "https://er0ckMirr0r.co",
|
95
|
+
"priority" => "99",
|
96
|
+
"retries" => "413189",
|
97
|
+
"timeout" => "666"
|
98
|
+
}
|
99
|
+
|
100
|
+
it "should create an entry with various properties" do
|
101
|
+
manifest = "#{type_under_test} { '#{super_creative}':
|
102
|
+
target => '#{@yumrepo_file}',\n"
|
103
|
+
properties.each do |property_key, property_value|
|
104
|
+
manifest << "#{property_key} => '#{property_value}',\n"
|
105
|
+
end
|
106
|
+
manifest << "}"
|
107
|
+
apply_with_error_check(manifest)
|
108
|
+
file_lines = File.read(File.join(@yumrepo_dir, super_creative + '.repo'))
|
109
|
+
properties.each do |property_key, property_value|
|
110
|
+
expect(file_lines).to match(/^#{property_key}=#{Regexp.escape(property_value)}$/)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
##puppet resource yumrepo
|
115
|
+
it "should fetch the yumrepo entries from resource face" do
|
116
|
+
@resource_app = Puppet::Application[:resource]
|
117
|
+
@resource_app.preinit
|
118
|
+
@resource_app.command_line.stubs(:args).
|
119
|
+
returns([type_under_test, super_creative])
|
120
|
+
|
121
|
+
@resource_app.expects(:puts).with do |args|
|
122
|
+
expect(args).to match(/#{super_creative}/)
|
123
|
+
end
|
124
|
+
@resource_app.main
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -126,7 +126,6 @@ describe Puppet::Application::Device do
|
|
126
126
|
describe "during setup" do
|
127
127
|
before :each do
|
128
128
|
@device.options.stubs(:[])
|
129
|
-
Puppet.stubs(:info)
|
130
129
|
Puppet[:libdir] = "/dev/null/lib"
|
131
130
|
Puppet::SSL::Host.stubs(:ca_location=)
|
132
131
|
Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
|
@@ -271,6 +270,7 @@ describe Puppet::Application::Device do
|
|
271
270
|
before :each do
|
272
271
|
@device.options.stubs(:[]).with(:fingerprint).returns(false)
|
273
272
|
Puppet.stubs(:notice)
|
273
|
+
@device.options.stubs(:[]).with(:detailed_exitcodes).returns(false)
|
274
274
|
@device.options.stubs(:[]).with(:client)
|
275
275
|
Puppet::Util::NetworkDevice::Config.stubs(:devices).returns({})
|
276
276
|
end
|
@@ -283,7 +283,7 @@ describe Puppet::Application::Device do
|
|
283
283
|
it "should get the device list" do
|
284
284
|
device_hash = stub_everything 'device hash'
|
285
285
|
Puppet::Util::NetworkDevice::Config.expects(:devices).returns(device_hash)
|
286
|
-
@device.main
|
286
|
+
expect { @device.main }.to exit_with 1
|
287
287
|
end
|
288
288
|
|
289
289
|
it "should exit if the device list is empty" do
|
@@ -296,8 +296,8 @@ describe Puppet::Application::Device do
|
|
296
296
|
Puppet[:confdir] = make_absolute("/dummy")
|
297
297
|
Puppet[:certname] = "certname"
|
298
298
|
@device_hash = {
|
299
|
-
"device1" => OpenStruct.new(:name => "device1", :url => "
|
300
|
-
"device2" => OpenStruct.new(:name => "device2", :url => "
|
299
|
+
"device1" => OpenStruct.new(:name => "device1", :url => "ssh://user:pass@testhost", :provider => "cisco"),
|
300
|
+
"device2" => OpenStruct.new(:name => "device2", :url => "https://user:pass@testhost/some/path", :provider => "rest"),
|
301
301
|
}
|
302
302
|
Puppet::Util::NetworkDevice::Config.stubs(:devices).returns(@device_hash)
|
303
303
|
Puppet.stubs(:[]=)
|
@@ -310,38 +310,76 @@ describe Puppet::Application::Device do
|
|
310
310
|
|
311
311
|
it "should set vardir to the device vardir" do
|
312
312
|
Puppet.expects(:[]=).with(:vardir, make_absolute("/dummy/devices/device1"))
|
313
|
-
@device.main
|
313
|
+
expect { @device.main }.to exit_with 1
|
314
314
|
end
|
315
315
|
|
316
316
|
it "should set confdir to the device confdir" do
|
317
317
|
Puppet.expects(:[]=).with(:confdir, make_absolute("/dummy/devices/device1"))
|
318
|
-
@device.main
|
318
|
+
expect { @device.main }.to exit_with 1
|
319
319
|
end
|
320
320
|
|
321
321
|
it "should set certname to the device certname" do
|
322
322
|
Puppet.expects(:[]=).with(:certname, "device1")
|
323
323
|
Puppet.expects(:[]=).with(:certname, "device2")
|
324
|
-
@device.main
|
324
|
+
expect { @device.main }.to exit_with 1
|
325
325
|
end
|
326
326
|
|
327
327
|
it "should make sure all the required folders and files are created" do
|
328
328
|
Puppet.settings.expects(:use).with(:main, :agent, :ssl).twice
|
329
|
-
@device.main
|
329
|
+
expect { @device.main }.to exit_with 1
|
330
330
|
end
|
331
331
|
|
332
332
|
it "should initialize the device singleton" do
|
333
333
|
Puppet::Util::NetworkDevice.expects(:init).with(@device_hash["device1"]).then.with(@device_hash["device2"])
|
334
|
-
@device.main
|
334
|
+
expect { @device.main }.to exit_with 1
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should print the device url scheme, host, and port" do
|
338
|
+
Puppet.expects(:info).with "starting applying configuration to device1 at ssh://testhost"
|
339
|
+
Puppet.expects(:info).with "starting applying configuration to device2 at https://testhost:443/some/path"
|
340
|
+
expect { @device.main }.to exit_with 1
|
335
341
|
end
|
336
342
|
|
337
343
|
it "should setup the SSL context" do
|
338
344
|
@device.expects(:setup_host).twice
|
339
|
-
@device.main
|
345
|
+
expect { @device.main }.to exit_with 1
|
340
346
|
end
|
341
347
|
|
342
348
|
it "should launch a configurer for this device" do
|
343
349
|
@configurer.expects(:run).twice
|
344
|
-
@device.main
|
350
|
+
expect { @device.main }.to exit_with 1
|
351
|
+
end
|
352
|
+
|
353
|
+
it "exits 1 when configurer raises error" do
|
354
|
+
@configurer.stubs(:run).raises(Puppet::Error).then.returns(0)
|
355
|
+
expect { @device.main }.to exit_with 1
|
356
|
+
end
|
357
|
+
|
358
|
+
it "exits 0 when run happens without puppet errors but with failed run" do
|
359
|
+
@configurer.stubs(:run).returns(6,2)
|
360
|
+
expect { @device.main }.to exit_with 0
|
361
|
+
end
|
362
|
+
|
363
|
+
it "exits 2 when --detailed-exitcodes and successful runs" do
|
364
|
+
@device.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
|
365
|
+
@configurer.stubs(:run).returns(0,2)
|
366
|
+
expect { @device.main }.to exit_with 2
|
367
|
+
end
|
368
|
+
|
369
|
+
it "exits 1 when --detailed-exitcodes and failed parse" do
|
370
|
+
@configurer = stub_everything 'configurer'
|
371
|
+
Puppet::Configurer.stubs(:new).returns(@configurer)
|
372
|
+
@device.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
|
373
|
+
@configurer.stubs(:run).returns(6,1)
|
374
|
+
expect { @device.main }.to exit_with 7
|
375
|
+
end
|
376
|
+
|
377
|
+
it "exits 6 when --detailed-exitcodes and failed run" do
|
378
|
+
@configurer = stub_everything 'configurer'
|
379
|
+
Puppet::Configurer.stubs(:new).returns(@configurer)
|
380
|
+
@device.options.stubs(:[]).with(:detailed_exitcodes).returns(true)
|
381
|
+
@configurer.stubs(:run).returns(6,2)
|
382
|
+
expect { @device.main }.to exit_with 6
|
345
383
|
end
|
346
384
|
|
347
385
|
[:vardir, :confdir].each do |setting|
|
@@ -369,7 +407,7 @@ describe Puppet::Application::Device do
|
|
369
407
|
end
|
370
408
|
|
371
409
|
|
372
|
-
@device.main
|
410
|
+
expect { @device.main }.to exit_with 1
|
373
411
|
|
374
412
|
expect(found_devices).to eq(all_devices)
|
375
413
|
end
|
@@ -399,7 +437,7 @@ describe Puppet::Application::Device do
|
|
399
437
|
end
|
400
438
|
|
401
439
|
|
402
|
-
@device.main
|
440
|
+
expect { @device.main }.to exit_with 1
|
403
441
|
|
404
442
|
# make sure that we were called with each of the defined devices
|
405
443
|
expect(found_devices).to eq(all_devices)
|
@@ -408,7 +446,7 @@ describe Puppet::Application::Device do
|
|
408
446
|
it "should expire all cached attributes" do
|
409
447
|
Puppet::SSL::Host.expects(:reset).twice
|
410
448
|
|
411
|
-
@device.main
|
449
|
+
expect { @device.main }.to exit_with 1
|
412
450
|
end
|
413
451
|
end
|
414
452
|
end
|
@@ -67,198 +67,198 @@ describe "when performing lookup" do
|
|
67
67
|
|
68
68
|
context 'using normal parameters' do
|
69
69
|
it 'can lookup value provided by the environment' do
|
70
|
-
resources = assemble_and_compile('${r}', "'a'")
|
70
|
+
resources = assemble_and_compile('${r}', "'abc::a'")
|
71
71
|
expect(resources).to include('env_a')
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'can lookup value provided by the module' do
|
75
|
-
resources = assemble_and_compile('${r}', "'b'")
|
75
|
+
resources = assemble_and_compile('${r}', "'abc::b'")
|
76
76
|
expect(resources).to include('module_b')
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'can lookup value provided in global scope' do
|
80
|
-
Hiera.any_instance.expects(:lookup).with('a', any_parameters).returns('global_a')
|
81
|
-
resources = assemble_and_compile('${r}', "'a'")
|
80
|
+
Hiera.any_instance.expects(:lookup).with('abc::a', any_parameters).returns('global_a')
|
81
|
+
resources = assemble_and_compile('${r}', "'abc::a'")
|
82
82
|
expect(resources).to include('global_a')
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'will stop at first found name when several names are provided' do
|
86
|
-
resources = assemble_and_compile('${r}', "['b', 'a']")
|
86
|
+
resources = assemble_and_compile('${r}', "['abc::b', 'abc::a']")
|
87
87
|
expect(resources).to include('module_b')
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'can lookup value provided by the module that is overriden by environment' do
|
91
|
-
resources = assemble_and_compile('${r}', "'c'")
|
91
|
+
resources = assemble_and_compile('${r}', "'abc::c'")
|
92
92
|
expect(resources).to include('env_c')
|
93
93
|
end
|
94
94
|
|
95
95
|
it "can 'unique' merge values provided by both the module and the environment" do
|
96
|
-
resources = assemble_and_compile('${r[0]}_${r[1]}', "'c'", 'Array[String]', "'unique'")
|
96
|
+
resources = assemble_and_compile('${r[0]}_${r[1]}', "'abc::c'", 'Array[String]', "'unique'")
|
97
97
|
expect(resources).to include('env_c_module_c')
|
98
98
|
end
|
99
99
|
|
100
100
|
it "can 'hash' merge values provided by the environment only" do
|
101
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'d'", 'Hash[String,String]', "'hash'")
|
101
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::d'", 'Hash[String,String]', "'hash'")
|
102
102
|
expect(resources).to include('env_d1_env_d2_env_d3')
|
103
103
|
end
|
104
104
|
|
105
105
|
it "can 'hash' merge values provided by both the environment and the module" do
|
106
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "'hash'")
|
106
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "'hash'")
|
107
107
|
expect(resources).to include('env_e1_module_e2_env_e3')
|
108
108
|
end
|
109
109
|
|
110
110
|
it "can 'hash' merge values provided by global, environment, and module" do
|
111
|
-
Hiera.any_instance.expects(:lookup).with('e', any_parameters).returns({ 'k1' => 'global_e1' })
|
112
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "'hash'")
|
111
|
+
Hiera.any_instance.expects(:lookup).with('abc::e', any_parameters).returns({ 'k1' => 'global_e1' })
|
112
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "'hash'")
|
113
113
|
expect(resources).to include('global_e1_module_e2_env_e3')
|
114
114
|
end
|
115
115
|
|
116
116
|
it "can pass merge parameter in the form of a hash with a 'strategy=>unique'" do
|
117
|
-
resources = assemble_and_compile('${r[0]}_${r[1]}', "'c'", 'Array[String]', "{strategy => 'unique'}")
|
117
|
+
resources = assemble_and_compile('${r[0]}_${r[1]}', "'abc::c'", 'Array[String]', "{strategy => 'unique'}")
|
118
118
|
expect(resources).to include('env_c_module_c')
|
119
119
|
end
|
120
120
|
|
121
121
|
it "can pass merge parameter in the form of a hash with 'strategy=>hash'" do
|
122
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "{strategy => 'hash'}")
|
122
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "{strategy => 'hash'}")
|
123
123
|
expect(resources).to include('env_e1_module_e2_env_e3')
|
124
124
|
end
|
125
125
|
|
126
126
|
it "can pass merge parameter in the form of a hash with a 'strategy=>deep'" do
|
127
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "{strategy => 'deep'}")
|
127
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "{strategy => 'deep'}")
|
128
128
|
expect(resources).to include('env_e1_module_e2_env_e3')
|
129
129
|
end
|
130
130
|
|
131
131
|
it "will fail unless merge in the form of a hash contains a 'strategy'" do
|
132
132
|
expect do
|
133
|
-
assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "{merge_key => 'hash'}")
|
133
|
+
assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "{merge_key => 'hash'}")
|
134
134
|
end.to raise_error(Puppet::ParseError, /hash given as 'merge' must contain the name of a strategy/)
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'will raise an exception when value is not found for single key and no default is provided' do
|
138
138
|
expect do
|
139
|
-
assemble_and_compile('${r}', "'x'")
|
140
|
-
end.to raise_error(Puppet::ParseError, /did not find a value for the name 'x'/)
|
139
|
+
assemble_and_compile('${r}', "'abc::x'")
|
140
|
+
end.to raise_error(Puppet::ParseError, /did not find a value for the name 'abc::x'/)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'can lookup an undef value' do
|
144
|
-
resources = assemble_and_compile('${r}', "'n'")
|
144
|
+
resources = assemble_and_compile('${r}', "'abc::n'")
|
145
145
|
expect(resources).to include('no_value')
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'will not replace an undef value with a given default' do
|
149
|
-
resources = assemble_and_compile('${r}', "'n'", 'undef', 'undef', '"default_n"')
|
149
|
+
resources = assemble_and_compile('${r}', "'abc::n'", 'undef', 'undef', '"default_n"')
|
150
150
|
expect(resources).to include('no_value')
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'will not accept a succesful lookup of an undef value when the type rejects it' do
|
154
154
|
expect do
|
155
|
-
assemble_and_compile('${r}', "'n'", 'String')
|
155
|
+
assemble_and_compile('${r}', "'abc::n'", 'String')
|
156
156
|
end.to raise_error(Puppet::ParseError, /found value has wrong type/)
|
157
157
|
end
|
158
158
|
|
159
159
|
it 'will raise an exception when value is not found for array key and no default is provided' do
|
160
160
|
expect do
|
161
|
-
assemble_and_compile('${r}', "['x', 'y']")
|
162
|
-
end.to raise_error(Puppet::ParseError, /did not find a value for any of the names \['x', 'y'\]/)
|
161
|
+
assemble_and_compile('${r}', "['abc::x', 'abc::y']")
|
162
|
+
end.to raise_error(Puppet::ParseError, /did not find a value for any of the names \['abc::x', 'abc::y'\]/)
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'can lookup and deep merge shallow values provided by the environment only' do
|
166
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'d'", 'Hash[String,String]', "'deep'")
|
166
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::d'", 'Hash[String,String]', "'deep'")
|
167
167
|
expect(resources).to include('env_d1_env_d2_env_d3')
|
168
168
|
end
|
169
169
|
|
170
170
|
it 'can lookup and deep merge shallow values provided by both the module and the environment' do
|
171
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "'deep'")
|
171
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "'deep'")
|
172
172
|
expect(resources).to include('env_e1_module_e2_env_e3')
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'can lookup and deep merge deep values provided by global, environment, and module' do
|
176
|
-
Hiera.any_instance.expects(:lookup).with('f', any_parameters).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
177
|
-
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'f'", 'Hash[String,Hash[String,String]]', "'deep'")
|
176
|
+
Hiera.any_instance.expects(:lookup).with('abc::f', any_parameters).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
177
|
+
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'abc::f'", 'Hash[String,Hash[String,String]]', "'deep'")
|
178
178
|
expect(resources).to include('global_f11_env_f12_module_f13_env_f21_module_f22_global_f23')
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'will propagate resolution_type :array to Hiera when merge == \'unique\'' do
|
182
|
-
Hiera.any_instance.expects(:lookup).with('c', anything, anything, anything, :array).returns(['global_c'])
|
183
|
-
resources = assemble_and_compile('${r[0]}_${r[1]}_${r[2]}', "'c'", 'Array[String]', "'unique'")
|
182
|
+
Hiera.any_instance.expects(:lookup).with('abc::c', anything, anything, anything, :array).returns(['global_c'])
|
183
|
+
resources = assemble_and_compile('${r[0]}_${r[1]}_${r[2]}', "'abc::c'", 'Array[String]', "'unique'")
|
184
184
|
expect(resources).to include('global_c_env_c_module_c')
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'will propagate a Hash resolution_type with :behavior => :native to Hiera when merge == \'hash\'' do
|
188
|
-
Hiera.any_instance.expects(:lookup).with('e', anything, anything, anything, { :behavior => :native }).returns({ 'k1' => 'global_e1' })
|
189
|
-
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'e'", 'Hash[String,String]', "{strategy => 'hash'}")
|
188
|
+
Hiera.any_instance.expects(:lookup).with('abc::e', anything, anything, anything, { :behavior => :native }).returns({ 'k1' => 'global_e1' })
|
189
|
+
resources = assemble_and_compile('${r[k1]}_${r[k2]}_${r[k3]}', "'abc::e'", 'Hash[String,String]', "{strategy => 'hash'}")
|
190
190
|
expect(resources).to include('global_e1_module_e2_env_e3')
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'will propagate a Hash resolution_type with :behavior => :deeper to Hiera when merge == \'deep\'' do
|
194
|
-
Hiera.any_instance.expects(:lookup).with('f', anything, anything, anything, { :behavior => :deeper }).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
195
|
-
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'f'", 'Hash[String,Hash[String,String]]', "'deep'")
|
194
|
+
Hiera.any_instance.expects(:lookup).with('abc::f', anything, anything, anything, { :behavior => :deeper }).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
195
|
+
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'abc::f'", 'Hash[String,Hash[String,String]]', "'deep'")
|
196
196
|
expect(resources).to include('global_f11_env_f12_module_f13_env_f21_module_f22_global_f23')
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'will propagate a Hash resolution_type with symbolic deep merge options to Hiera' do
|
200
|
-
Hiera.any_instance.expects(:lookup).with('f', anything, anything, anything, { :behavior => :deeper, :knockout_prefix => '--' }).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
201
|
-
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'f'", 'Hash[String,Hash[String,String]]', "{ 'strategy' => 'deep', 'knockout_prefix' => '--' }")
|
200
|
+
Hiera.any_instance.expects(:lookup).with('abc::f', anything, anything, anything, { :behavior => :deeper, :knockout_prefix => '--' }).returns({ 'k1' => { 's1' => 'global_f11' }, 'k2' => { 's3' => 'global_f23' }})
|
201
|
+
resources = assemble_and_compile('${r[k1][s1]}_${r[k1][s2]}_${r[k1][s3]}_${r[k2][s1]}_${r[k2][s2]}_${r[k2][s3]}', "'abc::f'", 'Hash[String,Hash[String,String]]', "{ 'strategy' => 'deep', 'knockout_prefix' => '--' }")
|
202
202
|
expect(resources).to include('global_f11_env_f12_module_f13_env_f21_module_f22_global_f23')
|
203
203
|
end
|
204
204
|
|
205
205
|
context 'with provided default' do
|
206
206
|
it 'will return default when lookup fails' do
|
207
|
-
resources = assemble_and_compile('${r}', "'x'", 'String', 'undef', "'dflt_x'")
|
207
|
+
resources = assemble_and_compile('${r}', "'abc::x'", 'String', 'undef', "'dflt_x'")
|
208
208
|
expect(resources).to include('dflt_x')
|
209
209
|
end
|
210
210
|
|
211
211
|
it 'can precede default parameter with undef as the value_type and undef as the merge type' do
|
212
|
-
resources = assemble_and_compile('${r}', "'x'", 'undef', 'undef', "'dflt_x'")
|
212
|
+
resources = assemble_and_compile('${r}', "'abc::x'", 'undef', 'undef', "'dflt_x'")
|
213
213
|
expect(resources).to include('dflt_x')
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'can use array' do
|
217
|
-
resources = assemble_and_compile('${r[0]}_${r[1]}', "'x'", 'Array[String]', 'undef', "['dflt_x', 'dflt_y']")
|
217
|
+
resources = assemble_and_compile('${r[0]}_${r[1]}', "'abc::x'", 'Array[String]', 'undef', "['dflt_x', 'dflt_y']")
|
218
218
|
expect(resources).to include('dflt_x_dflt_y')
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'can use hash' do
|
222
|
-
resources = assemble_and_compile('${r[a]}_${r[b]}', "'x'", 'Hash[String,String]', 'undef', "{'a' => 'dflt_x', 'b' => 'dflt_y'}")
|
222
|
+
resources = assemble_and_compile('${r[a]}_${r[b]}', "'abc::x'", 'Hash[String,String]', 'undef', "{'a' => 'dflt_x', 'b' => 'dflt_y'}")
|
223
223
|
expect(resources).to include('dflt_x_dflt_y')
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'fails unless default is an instance of value_type' do
|
227
227
|
expect do
|
228
|
-
assemble_and_compile('${r[a]}_${r[b]}', "'x'", 'Hash[String,String]', 'undef', "{'a' => 'dflt_x', 'b' => 32}")
|
228
|
+
assemble_and_compile('${r[a]}_${r[b]}', "'abc::x'", 'Hash[String,String]', 'undef', "{'a' => 'dflt_x', 'b' => 32}")
|
229
229
|
end.to raise_error(Puppet::ParseError, /default_value value has wrong type/)
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
233
|
context 'with a default block' do
|
234
234
|
it 'will be called when lookup fails' do
|
235
|
-
resources = assemble_and_compile_with_block('${r}', "'dflt_x'", "'x'")
|
235
|
+
resources = assemble_and_compile_with_block('${r}', "'dflt_x'", "'abc::x'")
|
236
236
|
expect(resources).to include('dflt_x')
|
237
237
|
end
|
238
238
|
|
239
239
|
it 'will not called when lookup succeeds but the found value is nil' do
|
240
|
-
resources = assemble_and_compile_with_block('${r}', "'dflt_x'", "'n'")
|
240
|
+
resources = assemble_and_compile_with_block('${r}', "'dflt_x'", "'abc::n'")
|
241
241
|
expect(resources).to include('no_value')
|
242
242
|
end
|
243
243
|
|
244
244
|
it 'can use array' do
|
245
|
-
resources = assemble_and_compile_with_block('${r[0]}_${r[1]}', "['dflt_x', 'dflt_y']", "'x'")
|
245
|
+
resources = assemble_and_compile_with_block('${r[0]}_${r[1]}', "['dflt_x', 'dflt_y']", "'abc::x'")
|
246
246
|
expect(resources).to include('dflt_x_dflt_y')
|
247
247
|
end
|
248
248
|
|
249
249
|
it 'can use hash' do
|
250
|
-
resources = assemble_and_compile_with_block('${r[a]}_${r[b]}', "{'a' => 'dflt_x', 'b' => 'dflt_y'}", "'x'")
|
250
|
+
resources = assemble_and_compile_with_block('${r[a]}_${r[b]}', "{'a' => 'dflt_x', 'b' => 'dflt_y'}", "'abc::x'")
|
251
251
|
expect(resources).to include('dflt_x_dflt_y')
|
252
252
|
end
|
253
253
|
|
254
254
|
it 'can return undef from block' do
|
255
|
-
resources = assemble_and_compile_with_block('${r}', 'undef', "'x'")
|
255
|
+
resources = assemble_and_compile_with_block('${r}', 'undef', "'abc::x'")
|
256
256
|
expect(resources).to include('no_value')
|
257
257
|
end
|
258
258
|
|
259
259
|
it 'fails unless block returns an instance of value_type' do
|
260
260
|
expect do
|
261
|
-
assemble_and_compile_with_block('${r[a]}_${r[b]}', "{'a' => 'dflt_x', 'b' => 32}", "'x'", 'Hash[String,String]')
|
261
|
+
assemble_and_compile_with_block('${r[a]}_${r[b]}', "{'a' => 'dflt_x', 'b' => 32}", "'abc::x'", 'Hash[String,String]')
|
262
262
|
end.to raise_error(Puppet::ParseError, /default_block value has wrong type/)
|
263
263
|
end
|
264
264
|
|
@@ -276,49 +276,89 @@ describe "when performing lookup" do
|
|
276
276
|
|
277
277
|
context 'when passing a hash as the only parameter' do
|
278
278
|
it 'can pass a single name correctly' do
|
279
|
-
resources = assemble_and_compile('${r}', "{name => 'a'}")
|
279
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::a'}")
|
280
280
|
expect(resources).to include('env_a')
|
281
281
|
end
|
282
282
|
|
283
283
|
it 'can pass a an array of names correctly' do
|
284
|
-
resources = assemble_and_compile('${r}', "{name => ['b', 'a']}")
|
284
|
+
resources = assemble_and_compile('${r}', "{name => ['abc::b', 'abc::a']}")
|
285
285
|
expect(resources).to include('module_b')
|
286
286
|
end
|
287
287
|
|
288
288
|
it 'can pass an override map and find values there even though they would be found' do
|
289
|
-
resources = assemble_and_compile('${r}', "{name => 'a', override => { a => 'override_a'}}")
|
289
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::a', override => { abc::a => 'override_a'}}")
|
290
290
|
expect(resources).to include('override_a')
|
291
291
|
end
|
292
292
|
|
293
293
|
it 'can pass an default_values_hash and find values there correctly' do
|
294
|
-
resources = assemble_and_compile('${r}', "{name => 'x', default_values_hash => { x => 'extra_x'}}")
|
294
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::x', default_values_hash => { abc::x => 'extra_x'}}")
|
295
295
|
expect(resources).to include('extra_x')
|
296
296
|
end
|
297
297
|
|
298
298
|
it 'can pass an default_values_hash but not use it when value is found elsewhere' do
|
299
|
-
resources = assemble_and_compile('${r}', "{name => 'a', default_values_hash => { a => 'extra_a'}}")
|
299
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::a', default_values_hash => { abc::a => 'extra_a'}}")
|
300
300
|
expect(resources).to include('env_a')
|
301
301
|
end
|
302
302
|
|
303
303
|
it 'can pass an default_values_hash but not use it when value is found elsewhere even when found value is undef' do
|
304
|
-
resources = assemble_and_compile('${r}', "{name => 'n', default_values_hash => { n => 'extra_n'}}")
|
304
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::n', default_values_hash => { abc::n => 'extra_n'}}")
|
305
305
|
expect(resources).to include('no_value')
|
306
306
|
end
|
307
307
|
|
308
308
|
it 'can pass an override and an default_values_hash and find the override value' do
|
309
|
-
resources = assemble_and_compile('${r}', "{name => 'x', override => { x => 'override_x'}, default_values_hash => { x => 'extra_x'}}")
|
309
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::x', override => { abc::x => 'override_x'}, default_values_hash => { abc::x => 'extra_x'}}")
|
310
310
|
expect(resources).to include('override_x')
|
311
311
|
end
|
312
312
|
|
313
313
|
it 'will raise an exception when value is not found for single key and no default is provided' do
|
314
314
|
expect do
|
315
|
-
assemble_and_compile('${r}', "{name => 'x'}")
|
316
|
-
end.to raise_error(Puppet::ParseError, /did not find a value for the name 'x'/)
|
315
|
+
assemble_and_compile('${r}', "{name => 'abc::x'}")
|
316
|
+
end.to raise_error(Puppet::ParseError, /did not find a value for the name 'abc::x'/)
|
317
317
|
end
|
318
318
|
|
319
319
|
it 'will not raise an exception when value is not found default value is nil' do
|
320
|
-
resources = assemble_and_compile('${r}', "{name => 'x', default_value => undef}")
|
320
|
+
resources = assemble_and_compile('${r}', "{name => 'abc::x', default_value => undef}")
|
321
321
|
expect(resources).to include('no_value')
|
322
322
|
end
|
323
323
|
end
|
324
|
+
|
325
|
+
context 'when accessing from outside a module' do
|
326
|
+
it 'will raise an exception when key in the function provided module data is not prefixed' do
|
327
|
+
Puppet[:code] = "include bad_data\nlookup(bad_data::b)"
|
328
|
+
expect do
|
329
|
+
compiler.compile()
|
330
|
+
end.to raise_error(Puppet::ParseError, /data for module 'bad_data' must use keys qualified with the name of the module/)
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'will resolve global, environment, and module correctly' do
|
334
|
+
Hiera.any_instance.expects(:lookup).with('bca::e', any_parameters).returns({ 'k1' => 'global_e1' })
|
335
|
+
Puppet[:code] = <<-END.gsub(/^ {8}/, '')
|
336
|
+
include bca
|
337
|
+
$r = lookup(bca::e, Hash[String,String], hash)
|
338
|
+
notify { "${r[k1]}_${r[k2]}_${r[k3]}": }
|
339
|
+
END
|
340
|
+
resources = compiler.compile().resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
|
341
|
+
expect(resources).to include('global_e1_module_bca_e2_env_bca_e3')
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'will resolve global and environment correctly when module has no provider' do
|
345
|
+
Hiera.any_instance.expects(:lookup).with('no_provider::e', any_parameters).returns({ 'k1' => 'global_e1' })
|
346
|
+
Puppet[:code] = <<-END.gsub(/^ {8}/, '')
|
347
|
+
include no_provider
|
348
|
+
$r = lookup(no_provider::e, Hash[String,String], hash)
|
349
|
+
notify { "${r[k1]}_${r[k2]}_${r[k3]}": }
|
350
|
+
END
|
351
|
+
resources = compiler.compile().resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
|
352
|
+
expect(resources).to include('global_e1__env_no_provider_e3') # k2 is missing
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
context 'when accessing bad data' do
|
357
|
+
it 'will raise an exception when key in the function provided module data is not prefixed' do
|
358
|
+
Puppet[:code] = 'include bad_data'
|
359
|
+
expect do
|
360
|
+
compiler.compile()
|
361
|
+
end.to raise_error(Puppet::ParseError, /data for module 'bad_data' must use keys qualified with the name of the module/)
|
362
|
+
end
|
363
|
+
end
|
324
364
|
end
|