puppet 6.0.0-universal-darwin → 6.0.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/lib/puppet/application/apply.rb +99 -59
  4. data/lib/puppet/application/cert.rb +2 -112
  5. data/lib/puppet/configurer.rb +2 -3
  6. data/lib/puppet/defaults.rb +14 -1
  7. data/lib/puppet/etc.rb +20 -0
  8. data/lib/puppet/module/task.rb +29 -38
  9. data/lib/puppet/parser/catalog_compiler.rb +24 -0
  10. data/lib/puppet/parser/compiler.rb +3 -1
  11. data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
  12. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  13. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +18 -10
  14. data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
  15. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  16. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  17. data/lib/puppet/pops/pcore.rb +10 -33
  18. data/lib/puppet/pops/serialization.rb +1 -0
  19. data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
  20. data/lib/puppet/provider/exec.rb +57 -57
  21. data/lib/puppet/provider/group/aix.rb +1 -15
  22. data/lib/puppet/provider/group/pw.rb +4 -8
  23. data/lib/puppet/provider/group/windows_adsi.rb +7 -4
  24. data/lib/puppet/provider/nameservice.rb +1 -25
  25. data/lib/puppet/provider/nameservice/directoryservice.rb +5 -3
  26. data/lib/puppet/provider/package/portage.rb +2 -2
  27. data/lib/puppet/provider/service/launchd.rb +19 -3
  28. data/lib/puppet/provider/user/aix.rb +48 -2
  29. data/lib/puppet/type/group.rb +62 -18
  30. data/lib/puppet/type/schedule.rb +7 -0
  31. data/lib/puppet/util/execution.rb +14 -1
  32. data/lib/puppet/util/posix.rb +15 -0
  33. data/lib/puppet/util/storage.rb +12 -0
  34. data/lib/puppet/util/windows/adsi.rb +60 -1
  35. data/lib/puppet/util/windows/process.rb +16 -1
  36. data/lib/puppet/util/windows/service.rb +68 -26
  37. data/lib/puppet/version.rb +1 -1
  38. data/lib/puppet_pal.rb +36 -3
  39. data/locales/ja/puppet.po +598 -861
  40. data/locales/puppet.pot +197 -160
  41. data/man/man5/puppet.conf.5 +12 -1
  42. data/man/man8/puppet.8 +1 -1
  43. data/spec/integration/application/apply_spec.rb +4 -1
  44. data/spec/integration/util/windows/adsi_spec.rb +2 -1
  45. data/spec/unit/application/apply_spec.rb +14 -0
  46. data/spec/unit/configurer_spec.rb +11 -0
  47. data/spec/unit/etc_spec.rb +25 -0
  48. data/spec/unit/indirector/catalog/json_spec.rb +9 -3
  49. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
  50. data/spec/unit/pops/loaders/loader_spec.rb +3 -10
  51. data/spec/unit/pops/loaders/loaders_spec.rb +30 -0
  52. data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
  53. data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
  54. data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
  55. data/spec/unit/pops/types/task_spec.rb +42 -116
  56. data/spec/unit/provider/group/aix_spec.rb +0 -19
  57. data/spec/unit/provider/group/pw_spec.rb +0 -6
  58. data/spec/unit/provider/group/windows_adsi_spec.rb +34 -35
  59. data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -2
  60. data/spec/unit/provider/service/launchd_spec.rb +19 -0
  61. data/spec/unit/provider/user/aix_spec.rb +43 -2
  62. data/spec/unit/provider/user/windows_adsi_spec.rb +1 -4
  63. data/spec/unit/puppet_pal_2pec.rb +6 -6
  64. data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
  65. data/spec/unit/task_spec.rb +50 -5
  66. data/spec/unit/type/group_spec.rb +111 -13
  67. data/spec/unit/util/execution_spec.rb +59 -0
  68. data/spec/unit/util/posix_spec.rb +28 -0
  69. data/spec/unit/util/storage_spec.rb +107 -0
  70. data/spec/unit/util/windows/adsi_spec.rb +100 -5
  71. data/spec/unit/util/windows/service_spec.rb +100 -43
  72. metadata +2 -2
@@ -54,23 +54,4 @@ describe 'Puppet::Type::Group::Provider::Aix' do
54
54
  expect(provider_class.find(1, ia_module_args)).to eql(expected_group)
55
55
  end
56
56
  end
57
-
58
- describe '.users_to_members' do
59
- it 'converts the users attribute to the members property' do
60
- expect(provider_class.users_to_members('foo,bar'))
61
- .to eql(['foo', 'bar'])
62
- end
63
- end
64
-
65
- describe '.members_to_users' do
66
- it 'returns the members property as-is if it is not an Array' do
67
- expect(provider_class.members_to_users('members'))
68
- .to eql('members')
69
- end
70
-
71
- it 'returns the members property as a comma-separated string if it is an Array' do
72
- expect(provider_class.members_to_users(['user1', 'user2']))
73
- .to eql('user1,user2')
74
- end
75
- end
76
57
  end
@@ -71,11 +71,5 @@ describe provider_class do
71
71
  provider.expects(:execute).with(all_of(includes("-M"), includes("user2")), has_entry(:custom_environment, {}))
72
72
  provider.members = "user2"
73
73
  end
74
-
75
- it "should use -M with all the given users when the members property is changed with an array" do
76
- resource[:members] = ["user1", "user2"]
77
- provider.expects(:execute).with(all_of(includes("-M"), includes("user3,user4")), has_entry(:custom_environment, {}))
78
- provider.members = ["user3", "user4"]
79
- end
80
74
  end
81
75
  end
@@ -49,25 +49,25 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
49
49
  describe "#members_insync?" do
50
50
  it "should return true for same lists of members" do
51
51
  current = [
52
- Puppet::Util::Windows::SID.name_to_principal('user1'),
53
- Puppet::Util::Windows::SID.name_to_principal('user2'),
52
+ 'user1',
53
+ 'user2'
54
54
  ]
55
55
  expect(provider.members_insync?(current, ['user1', 'user2'])).to be_truthy
56
56
  end
57
57
 
58
58
  it "should return true for same lists of unordered members" do
59
59
  current = [
60
- Puppet::Util::Windows::SID.name_to_principal('user1'),
61
- Puppet::Util::Windows::SID.name_to_principal('user2'),
60
+ 'user1',
61
+ 'user2'
62
62
  ]
63
63
  expect(provider.members_insync?(current, ['user2', 'user1'])).to be_truthy
64
64
  end
65
65
 
66
66
  it "should return true for same lists of members irrespective of duplicates" do
67
67
  current = [
68
- Puppet::Util::Windows::SID.name_to_principal('user1'),
69
- Puppet::Util::Windows::SID.name_to_principal('user2'),
70
- Puppet::Util::Windows::SID.name_to_principal('user2'),
68
+ 'user1',
69
+ 'user2',
70
+ 'user2'
71
71
  ]
72
72
  expect(provider.members_insync?(current, ['user2', 'user1', 'user1'])).to be_truthy
73
73
  end
@@ -91,9 +91,9 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
91
91
 
92
92
  it "should return true when current and should contain the same users in a different order" do
93
93
  current = [
94
- Puppet::Util::Windows::SID.name_to_principal('user1'),
95
- Puppet::Util::Windows::SID.name_to_principal('user2'),
96
- Puppet::Util::Windows::SID.name_to_principal('user3'),
94
+ 'user1',
95
+ 'user2',
96
+ 'user3'
97
97
  ]
98
98
  expect(provider.members_insync?(current, ['user3', 'user1', 'user2'])).to be_truthy
99
99
  end
@@ -104,21 +104,21 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
104
104
 
105
105
  it "should return false when should is nil" do
106
106
  current = [
107
- Puppet::Util::Windows::SID.name_to_principal('user1'),
107
+ 'user1'
108
108
  ]
109
109
  expect(provider.members_insync?(current, nil)).to be_falsey
110
110
  end
111
111
 
112
112
  it "should return false when current contains different users than should" do
113
113
  current = [
114
- Puppet::Util::Windows::SID.name_to_principal('user1'),
114
+ 'user1'
115
115
  ]
116
116
  expect(provider.members_insync?(current, ['user2'])).to be_falsey
117
117
  end
118
118
 
119
119
  it "should return false when current contains members and should is empty" do
120
120
  current = [
121
- Puppet::Util::Windows::SID.name_to_principal('user1'),
121
+ 'user1'
122
122
  ]
123
123
  expect(provider.members_insync?(current, [])).to be_falsey
124
124
  end
@@ -129,16 +129,16 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
129
129
 
130
130
  it "should return false when should user(s) are not the only items in the current" do
131
131
  current = [
132
- Puppet::Util::Windows::SID.name_to_principal('user1'),
133
- Puppet::Util::Windows::SID.name_to_principal('user2'),
132
+ 'user1',
133
+ 'user2'
134
134
  ]
135
135
  expect(provider.members_insync?(current, ['user1'])).to be_falsey
136
136
  end
137
137
 
138
138
  it "should return false when current user(s) is not empty and should is an empty list" do
139
139
  current = [
140
- Puppet::Util::Windows::SID.name_to_principal('user1'),
141
- Puppet::Util::Windows::SID.name_to_principal('user2'),
140
+ 'user1',
141
+ 'user2'
142
142
  ]
143
143
  expect(provider.members_insync?(current, [])).to be_falsey
144
144
  end
@@ -156,21 +156,21 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
156
156
 
157
157
  it "should return true when should is nil" do
158
158
  current = [
159
- Puppet::Util::Windows::SID.name_to_principal('user1'),
159
+ 'user1'
160
160
  ]
161
161
  expect(provider.members_insync?(current, nil)).to be_truthy
162
162
  end
163
163
 
164
164
  it "should return false when current contains different users than should" do
165
165
  current = [
166
- Puppet::Util::Windows::SID.name_to_principal('user1'),
166
+ 'user1'
167
167
  ]
168
168
  expect(provider.members_insync?(current, ['user2'])).to be_falsey
169
169
  end
170
170
 
171
171
  it "should return true when current contains members and should is empty" do
172
172
  current = [
173
- Puppet::Util::Windows::SID.name_to_principal('user1'),
173
+ 'user1'
174
174
  ]
175
175
  expect(provider.members_insync?(current, [])).to be_truthy
176
176
  end
@@ -181,25 +181,25 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
181
181
 
182
182
  it "should return true when current user(s) contains at least the should list" do
183
183
  current = [
184
- Puppet::Util::Windows::SID.name_to_principal('user1'),
185
- Puppet::Util::Windows::SID.name_to_principal('user2'),
184
+ 'user1',
185
+ 'user2'
186
186
  ]
187
187
  expect(provider.members_insync?(current, ['user1'])).to be_truthy
188
188
  end
189
189
 
190
190
  it "should return true when current user(s) is not empty and should is an empty list" do
191
191
  current = [
192
- Puppet::Util::Windows::SID.name_to_principal('user1'),
193
- Puppet::Util::Windows::SID.name_to_principal('user2'),
192
+ 'user1',
193
+ 'user2'
194
194
  ]
195
195
  expect(provider.members_insync?(current, [])).to be_truthy
196
196
  end
197
197
 
198
198
  it "should return true when current user(s) contains at least the should list, even unordered" do
199
199
  current = [
200
- Puppet::Util::Windows::SID.name_to_principal('user3'),
201
- Puppet::Util::Windows::SID.name_to_principal('user1'),
202
- Puppet::Util::Windows::SID.name_to_principal('user2'),
200
+ 'user3',
201
+ 'user1',
202
+ 'user2'
203
203
  ]
204
204
  expect(provider.members_insync?(current, ['user2','user1'])).to be_truthy
205
205
  end
@@ -238,13 +238,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
238
238
 
239
239
  it "should be able to provide a list of members" do
240
240
  provider.group.stubs(:members).returns ['user1', 'user2', 'user3']
241
+ Puppet::Util::Windows::ADSI::User.stubs(:name_sid_hash)
242
+ .with(provider.group.members)
243
+ .returns({ 'user1' => '', 'user2' => '', 'user3' => '' })
241
244
 
242
245
  expect(provider.members).to match_array(['user1', 'user2', 'user3'])
243
246
  end
244
247
 
245
248
  it "should be able to set group members" do
246
- provider.group.stubs(:members).returns ['user1', 'user2']
247
-
248
249
  member_sids = [
249
250
  stub(:account => 'user1', :domain => 'testcomputername', :sid => 1),
250
251
  stub(:account => 'user2', :domain => 'testcomputername', :sid => 2),
@@ -259,7 +260,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
259
260
  provider.group.expects(:remove_member_sids).with(member_sids[0])
260
261
  provider.group.expects(:add_member_sids).with(member_sids[2])
261
262
 
262
- provider.members = ['user2', 'user3']
263
+ provider.members = 'user2,user3'
263
264
  end
264
265
  end
265
266
 
@@ -268,12 +269,13 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
268
269
  resource[:members] = ['user1', 'user2']
269
270
 
270
271
  group = stub 'group'
272
+ group.stubs(:members).returns([])
271
273
  Puppet::Util::Windows::ADSI::Group.expects(:create).with('testers').returns group
272
274
 
273
275
  create = sequence('create')
274
276
  group.expects(:commit).in_sequence(create)
275
277
  # due to PUP-1967, defaultto false will set the default to nil
276
- group.expects(:set_members).with(['user1', 'user2'], nil).in_sequence(create)
278
+ group.expects(:set_members).with('user1,user2', nil).in_sequence(create)
277
279
 
278
280
  provider.create
279
281
  end
@@ -290,10 +292,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet::Util:
290
292
  connection.expects(:Create)
291
293
  connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
292
294
 
293
- expect{ provider.create }.to raise_error(
294
- Puppet::Error,
295
- /not able to create\/delete domain groups/
296
- )
295
+ expect{ provider.create }.to raise_error(Puppet::Error)
297
296
  end
298
297
 
299
298
  it 'should commit a newly created group' do
@@ -17,13 +17,13 @@ end
17
17
 
18
18
  it "[#6009] should handle nested arrays of members" do
19
19
  current = ["foo", "bar", "baz"]
20
- desired = ["foo", ["quux"], "qorp"]
20
+ desired = "foo,quux,qorp"
21
21
  group = 'example'
22
22
 
23
23
  @resource.stubs(:[]).with(:name).returns(group)
24
24
  @resource.stubs(:[]).with(:auth_membership).returns(true)
25
25
  @provider.instance_variable_set(:@property_value_cache_hash,
26
- { :members => current })
26
+ { :members => current.join(',') })
27
27
 
28
28
  %w{bar baz}.each do |del|
29
29
  @provider.expects(:execute).once.
@@ -345,4 +345,23 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
345
345
  expect { provider.jobsearch("NOSUCH") }.to raise_error(Puppet::Error)
346
346
  end
347
347
  end
348
+
349
+ describe "read_overrides" do
350
+ before do
351
+ Kernel.stubs(:sleep)
352
+ end
353
+ it "should read overrides" do
354
+ provider.expects(:read_plist).once.returns({})
355
+ expect(provider.read_overrides).to eq({})
356
+ end
357
+ it "should retry if read_plist fails" do
358
+ provider.expects(:read_plist).once.returns({})
359
+ provider.expects(:read_plist).once.returns(nil)
360
+ expect(provider.read_overrides).to eq({})
361
+ end
362
+ it "raises Puppet::Error after 20 attempts" do
363
+ provider.expects(:read_plist).times(20).returns(nil)
364
+ expect { provider.read_overrides }.to raise_error(Puppet::Error)
365
+ end
366
+ end
348
367
  end
@@ -70,11 +70,23 @@ describe 'Puppet::Type::User::Provider::Aix' do
70
70
  end
71
71
  end
72
72
 
73
- describe '.groups_to_groups' do
73
+ describe '.groups_attribute_to_property' do
74
+ it "reads the user's groups from the etc/groups file" do
75
+ groups = ['system', 'adm']
76
+ Puppet::Util::POSIX.stubs(:groups_of).with(resource[:name]).returns(groups)
77
+
78
+ actual_groups = provider_class.groups_attribute_to_property(provider, 'unused_value')
79
+ expected_groups = groups.join(',')
80
+
81
+ expect(actual_groups).to eql(expected_groups)
82
+ end
83
+ end
84
+
85
+ describe '.groups_property_to_attribute' do
74
86
  it 'raises an ArgumentError if the groups are space-separated' do
75
87
  groups = "foo bar baz"
76
88
  expect do
77
- provider_class.groups_to_groups(groups)
89
+ provider_class.groups_property_to_attribute(groups)
78
90
  end.to raise_error do |error|
79
91
  expect(error).to be_a(ArgumentError)
80
92
 
@@ -84,6 +96,33 @@ describe 'Puppet::Type::User::Provider::Aix' do
84
96
  end
85
97
  end
86
98
 
99
+ describe '#gid=' do
100
+ let(:value) { 'new_pgrp' }
101
+
102
+ let(:old_pgrp) { 'old_pgrp' }
103
+ let(:cur_groups) { 'system,adm' }
104
+ before(:each) do
105
+ provider.stubs(:gid).returns(old_pgrp)
106
+ provider.stubs(:groups).returns(cur_groups)
107
+ provider.stubs(:set)
108
+ end
109
+
110
+ it 'raises a Puppet::Error if it fails to set the groups property' do
111
+ provider.stubs(:set)
112
+ .with(:groups, cur_groups)
113
+ .raises(Puppet::ExecutionFailure, 'failed to reset the groups!')
114
+
115
+ expect { provider.gid = value }.to raise_error do |error|
116
+ expect(error).to be_a(Puppet::Error)
117
+
118
+ expect(error.message).to match('groups')
119
+ expect(error.message).to match(cur_groups)
120
+ expect(error.message).to match(old_pgrp)
121
+ expect(error.message).to match(value)
122
+ end
123
+ end
124
+ end
125
+
87
126
  describe '#parse_password' do
88
127
  def call_parse_password
89
128
  File.open(my_fixture('aix_passwd_file.out')) do |f|
@@ -163,9 +202,11 @@ describe 'Puppet::Type::User::Provider::Aix' do
163
202
  describe '#create' do
164
203
  it 'should create the user' do
165
204
  provider.resource.stubs(:should).with(anything).returns(nil)
205
+ provider.resource.stubs(:should).with(:groups).returns('g1,g2')
166
206
  provider.resource.stubs(:should).with(:password).returns('password')
167
207
 
168
208
  provider.expects(:execute)
209
+ provider.expects(:groups=).with('g1,g2')
169
210
  provider.expects(:password=).with('password')
170
211
 
171
212
  provider.create
@@ -259,10 +259,7 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet::Util::
259
259
  connection.expects(:Put).with('UserFlags', true)
260
260
  connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
261
261
 
262
- expect{ provider.create }.to raise_error(
263
- Puppet::Error,
264
- /not able to create\/delete domain users/
265
- )
262
+ expect{ provider.create }.to raise_error(Puppet::Error)
266
263
  end
267
264
  end
268
265
 
@@ -767,13 +767,13 @@ describe 'Puppet Pal' do
767
767
  [ signature.runnable_with?('string_param' => 'foo', 'int_param' => 10),
768
768
  signature.runnable_with?('anything_goes' => 'foo'),
769
769
  signature.task_hash['name'],
770
- signature.task_hash['parameters']['string_param']['description'],
771
- signature.task.description,
772
- signature.task.parameters['int_param']['type'],
770
+ signature.task_hash['metadata']['parameters']['string_param']['description'],
771
+ signature.task_hash['metadata']['description'],
772
+ signature.task_hash['metadata']['parameters']['int_param']['type'],
773
773
  ]
774
774
  end
775
775
  end
776
- expect(result).to eq([true, false, 'b::atask', 'A string parameter', 'test task b::atask', Puppet::Pops::Types::PIntegerType::DEFAULT])
776
+ expect(result).to eq([true, false, 'b::atask', 'A string parameter', 'test task b::atask', 'Integer'])
777
777
  end
778
778
 
779
779
  it '"TaskSignature#runnable_with?" calls a given lambda if there is an error' do
@@ -802,7 +802,7 @@ describe 'Puppet Pal' do
802
802
  signature.task_hash
803
803
  end
804
804
  end
805
- expect(result['input_method']).to be_nil
805
+ expect(result['metadata']['input_method']).to be_nil
806
806
  end
807
807
 
808
808
  it 'task input_method is parsed from task metadata' do
@@ -812,7 +812,7 @@ describe 'Puppet Pal' do
812
812
  signature.task_hash
813
813
  end
814
814
  end
815
- expect(result['input_method']).to eq('stdin')
815
+ expect(result['metadata']['input_method']).to eq('stdin')
816
816
  end
817
817
 
818
818
  it '"list_tasks" returns an array with all tasks that can be loaded' do
@@ -463,6 +463,64 @@ describe 'Puppet Pal' do
463
463
  end.to raise_error(/does not represent a literal value/)
464
464
  end
465
465
 
466
+ it 'the "evaluate" method evaluates but does not evaluate lazy constructs' do
467
+ result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do | ctx|
468
+ ctx.with_catalog_compiler do |c|
469
+ c.evaluate(c.parse_string('define foo() { notify {nope: }} foo { test: }'))
470
+ c.with_json_encoding() {|encoder| encoder.encode }
471
+ end
472
+ end
473
+ parsed = JSON.parse(result)
474
+ expect(parsed['resources']).to_not include(include('type' => 'Notify'))
475
+ end
476
+
477
+ it 'an "evaluate" followed by "compile_additions" evaluates lazy constructs' do
478
+ result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do | ctx|
479
+ ctx.with_catalog_compiler do |c|
480
+ c.evaluate(c.parse_string('define foo() { notify {nope: }} foo { test: }'))
481
+ c.compile_additions
482
+ c.with_json_encoding() {|encoder| encoder.encode }
483
+ end
484
+ end
485
+ parsed = JSON.parse(result)
486
+ expect(parsed['resources']).to include(include('type' => 'Notify'))
487
+ end
488
+
489
+ it 'an "evaluate" followed by "compile_additions" validates the result' do
490
+ expect do
491
+ Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do | ctx|
492
+ ctx.with_catalog_compiler do |c|
493
+ c.evaluate(c.parse_string('define foo() { notify {nope: }} foo { test: before =>"Bar[nope]"}'))
494
+ c.compile_additions
495
+ end
496
+ end
497
+ end.to raise_error(Puppet::Error, /Could not find resource 'Bar\[nope\]'/)
498
+ end
499
+
500
+ it 'an "evaluate" followed by "evaluate_additions" does not validate the result' do
501
+ result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do | ctx|
502
+ ctx.with_catalog_compiler do |c|
503
+ c.evaluate(c.parse_string('define foo() { notify {nope: }} foo { test: before =>"Bar[nope]"}'))
504
+ c.evaluate_additions
505
+ c.with_json_encoding() {|encoder| encoder.encode }
506
+ end
507
+ end
508
+ parsed = JSON.parse(result)
509
+ expect(parsed['resources']).to include(include('type' => 'Notify'))
510
+ end
511
+
512
+ it 'an "evaluate" followed by "evaluate_additions" and "validate" validates the result' do
513
+ expect do
514
+ Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do | ctx|
515
+ ctx.with_catalog_compiler do |c|
516
+ c.evaluate(c.parse_string('define foo() { notify {nope: }} foo { test: before =>"Bar[nope]"}'))
517
+ c.compile_additions
518
+ c.validate
519
+ end
520
+ end
521
+ end.to raise_error(Puppet::Error, /Could not find resource 'Bar\[nope\]'/)
522
+ end
523
+
466
524
  end
467
525
  end
468
526