puppet 5.5.3-x64-mingw32 → 5.5.6-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.

Files changed (71) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +1 -4
  3. data/Gemfile +5 -1
  4. data/Gemfile.lock +167 -0
  5. data/Rakefile +4 -34
  6. data/ext/build_defaults.yaml +0 -2
  7. data/lib/puppet/application/cert.rb +3 -1
  8. data/lib/puppet/defaults.rb +55 -26
  9. data/lib/puppet/face/certificate.rb +2 -0
  10. data/lib/puppet/indirector/ldap.rb +6 -0
  11. data/lib/puppet/node/environment.rb +4 -2
  12. data/lib/puppet/parser/functions/tagged.rb +1 -4
  13. data/lib/puppet/pops/issues.rb +4 -0
  14. data/lib/puppet/pops/validation/checker4_0.rb +100 -0
  15. data/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
  16. data/lib/puppet/provider/augeas/augeas.rb +198 -4
  17. data/lib/puppet/provider/service/smf.rb +2 -3
  18. data/lib/puppet/provider/service/upstart.rb +10 -2
  19. data/lib/puppet/test/test_helper.rb +0 -3
  20. data/lib/puppet/type/file/source.rb +10 -1
  21. data/lib/puppet/version.rb +1 -1
  22. data/locales/puppet.pot +132 -118
  23. data/man/man5/puppet.conf.5 +23 -23
  24. data/man/man8/puppet-agent.8 +1 -1
  25. data/man/man8/puppet-apply.8 +1 -1
  26. data/man/man8/puppet-ca.8 +3 -3
  27. data/man/man8/puppet-catalog.8 +1 -1
  28. data/man/man8/puppet-cert.8 +2 -2
  29. data/man/man8/puppet-certificate.8 +3 -3
  30. data/man/man8/puppet-certificate_request.8 +1 -1
  31. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  32. data/man/man8/puppet-config.8 +1 -1
  33. data/man/man8/puppet-describe.8 +1 -1
  34. data/man/man8/puppet-device.8 +1 -1
  35. data/man/man8/puppet-doc.8 +1 -1
  36. data/man/man8/puppet-epp.8 +1 -1
  37. data/man/man8/puppet-facts.8 +1 -1
  38. data/man/man8/puppet-filebucket.8 +1 -1
  39. data/man/man8/puppet-generate.8 +1 -1
  40. data/man/man8/puppet-help.8 +1 -1
  41. data/man/man8/puppet-key.8 +1 -1
  42. data/man/man8/puppet-lookup.8 +1 -1
  43. data/man/man8/puppet-man.8 +1 -1
  44. data/man/man8/puppet-master.8 +1 -1
  45. data/man/man8/puppet-module.8 +1 -1
  46. data/man/man8/puppet-node.8 +1 -1
  47. data/man/man8/puppet-parser.8 +1 -1
  48. data/man/man8/puppet-plugin.8 +1 -1
  49. data/man/man8/puppet-report.8 +1 -1
  50. data/man/man8/puppet-resource.8 +1 -1
  51. data/man/man8/puppet-script.8 +1 -1
  52. data/man/man8/puppet-status.8 +1 -1
  53. data/man/man8/puppet.8 +3 -3
  54. data/spec/integration/type/file_spec.rb +18 -3
  55. data/spec/integration/util/settings_spec.rb +1 -0
  56. data/spec/integration/util/windows/security_spec.rb +78 -1
  57. data/spec/unit/application/master_spec.rb +2 -0
  58. data/spec/unit/configurer/downloader_spec.rb +5 -0
  59. data/spec/unit/defaults_spec.rb +13 -0
  60. data/spec/unit/face/help_spec.rb +2 -1
  61. data/spec/unit/indirector/ldap_spec.rb +22 -1
  62. data/spec/unit/node/environment_spec.rb +14 -0
  63. data/spec/unit/parser/functions/tagged_spec.rb +16 -0
  64. data/spec/unit/pops/validator/validator_spec.rb +139 -4
  65. data/spec/unit/provider/augeas/augeas_spec.rb +66 -1
  66. data/spec/unit/provider/service/smf_spec.rb +2 -6
  67. data/spec/unit/provider/service/upstart_spec.rb +37 -0
  68. data/spec/unit/settings/autosign_setting_spec.rb +2 -2
  69. data/spec/unit/settings/file_setting_spec.rb +6 -0
  70. data/spec/unit/ssl/certificate_authority_spec.rb +1 -0
  71. metadata +4 -3
@@ -224,7 +224,58 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
224
224
  end
225
225
  end
226
226
 
227
- it "should round-trip all 128 modes that do not require deny ACEs" do
227
+ it "should round-trip all 128 modes that do not require deny ACEs, where owner and group are different" do
228
+ # windows defaults set Administrators, None when Administrator
229
+ # or Administrators, SYSTEM when System
230
+ # but we can guarantee group is different by explicitly setting to Users
231
+ winsec.set_group(sids[:users], path)
232
+
233
+ 0.upto(1).each do |s|
234
+ 0.upto(7).each do |u|
235
+ 0.upto(u).each do |g|
236
+ 0.upto(g).each do |o|
237
+ # if user is superset of group, and group superset of other, then
238
+ # no deny ace is required, and mode can be converted to win32
239
+ # access mask, and back to mode without loss of information
240
+ # (provided the owner and group are not the same)
241
+ next if ((u & g) != g) or ((g & o) != o)
242
+
243
+ mode = (s << 9 | u << 6 | g << 3 | o << 0)
244
+ winsec.set_mode(mode, path)
245
+ expect(winsec.get_mode(path).to_s(8)).to eq(mode.to_s(8))
246
+ end
247
+ end
248
+ end
249
+ end
250
+ end
251
+
252
+ it "should round-trip all 54 modes that do not require deny ACEs, where owner and group are same" do
253
+ winsec.set_group(winsec.get_owner(path), path)
254
+
255
+ 0.upto(1).each do |s|
256
+ 0.upto(7).each do |ug|
257
+ 0.upto(ug).each do |o|
258
+ # if user and group superset of other, then
259
+ # no deny ace is required, and mode can be converted to win32
260
+ # access mask, and back to mode without loss of information
261
+ # (provided the owner and group are the same)
262
+ next if ((ug & o) != o)
263
+ mode = (s << 9 | ug << 6 | ug << 3 | o << 0)
264
+ winsec.set_mode(mode, path)
265
+ expect(winsec.get_mode(path).to_s(8)).to eq(mode.to_s(8))
266
+ end
267
+ end
268
+ end
269
+ end
270
+
271
+ # The SYSTEM user is a special case therefore we need to test that we round trip correctly when set
272
+ it "should round-trip all 128 modes that do not require deny ACEs, when simulating a SYSTEM service" do
273
+ # The owner and group for files/dirs created, when running as a service under Local System are
274
+ # Owner = Administrators
275
+ # Group = SYSTEM
276
+ winsec.set_owner(sids[:administrators], path)
277
+ winsec.set_group(sids[:system], path)
278
+
228
279
  0.upto(1).each do |s|
229
280
  0.upto(7).each do |u|
230
281
  0.upto(u).each do |g|
@@ -566,6 +617,32 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
566
617
  # end
567
618
  end
568
619
 
620
+ describe "#mode=" do
621
+ # setting owner to SYSTEM requires root
622
+ it "should round-trip all 54 modes that do not require deny ACEs, when simulating a SYSTEM scheduled task" do
623
+ # The owner and group for files/dirs created, when running as a Scheduled Task as Local System are
624
+ # Owner = SYSTEM
625
+ # Group = SYSTEM
626
+ winsec.set_group(sids[:system], path)
627
+ winsec.set_owner(sids[:system], path)
628
+
629
+ 0.upto(1).each do |s|
630
+ 0.upto(7).each do |ug|
631
+ 0.upto(ug).each do |o|
632
+ # if user and group superset of other, then
633
+ # no deny ace is required, and mode can be converted to win32
634
+ # access mask, and back to mode without loss of information
635
+ # (provided the owner and group are the same)
636
+ next if ((ug & o) != o)
637
+ mode = (s << 9 | ug << 6 | ug << 3 | o << 0)
638
+ winsec.set_mode(mode, path)
639
+ expect(winsec.get_mode(path).to_s(8)).to eq(mode.to_s(8))
640
+ end
641
+ end
642
+ end
643
+ end
644
+ end
645
+
569
646
  describe "when the parent directory" do
570
647
  before :each do
571
648
  winsec.set_owner(sids[:current_user], parent)
@@ -7,6 +7,7 @@ require 'puppet/network/server'
7
7
 
8
8
  describe Puppet::Application::Master, :unless => Puppet.features.microsoft_windows? do
9
9
  before :each do
10
+ Puppet[:bindaddress] = '127.0.0.1'
10
11
  @master = Puppet::Application[:master]
11
12
  @daemon = stub_everything 'daemon'
12
13
  Puppet::Daemon.stubs(:new).returns(@daemon)
@@ -357,6 +358,7 @@ describe Puppet::Application::Master, :unless => Puppet.features.microsoft_windo
357
358
 
358
359
  it "should log a deprecation notice when running a WEBrick server" do
359
360
  Puppet.expects(:deprecation_warning).with("The WEBrick Puppet master server is deprecated and will be removed in a future release. Please use Puppet Server instead. See http://links.puppet.com/deprecate-rack-webrick-servers for more information.")
361
+ Puppet.expects(:deprecation_warning).with("Accessing 'bindaddress' as a setting is deprecated.")
360
362
 
361
363
  @master.main
362
364
  end
@@ -160,6 +160,11 @@ describe Puppet::Configurer::Downloader do
160
160
  expect(@dler.catalog.host_config).to eq(false)
161
161
  end
162
162
 
163
+ it "should not issue a deprecation warning for source_permissions" do
164
+ Puppet.expects(:puppet_deprecation_warning).never
165
+ catalog = @dler.catalog
166
+ expect(catalog.resources.size).to eq(1) # Must consume catalog to fix warnings
167
+ end
163
168
  end
164
169
 
165
170
  describe "when downloading" do
@@ -124,6 +124,19 @@ describe "Defaults" do
124
124
  end
125
125
  end
126
126
 
127
+ describe 'manage_internal_file_permissions' do
128
+ describe 'on windows', :if => Puppet::Util::Platform.windows? do
129
+ it 'should default to false' do
130
+ expect(Puppet.settings[:manage_internal_file_permissions]).to be false
131
+ end
132
+ end
133
+ describe 'on non-windows', :if => ! Puppet::Util::Platform.windows? do
134
+ it 'should default to true' do
135
+ expect(Puppet.settings[:manage_internal_file_permissions]).to be true
136
+ end
137
+ end
138
+ end
139
+
127
140
  describe 'basemodulepath' do
128
141
  it 'includes the global and system modules on non-windows', :unless => Puppet::Util::Platform.windows? do
129
142
  expect(
@@ -127,7 +127,8 @@ describe Puppet::Face[:help, '0.0.1'] do
127
127
  expect(subject).to match(%r{ #{appname} })
128
128
 
129
129
  summary = Puppet::Face[:help, :current].horribly_extract_summary_from(appname)
130
- summary and expect(subject).to match(%r{ #{summary}\b})
130
+ summary_regex = Regexp.escape(summary)
131
+ summary and expect(subject).to match(%r{ #{summary_regex}$})
131
132
  end
132
133
  end
133
134
  end
@@ -13,12 +13,33 @@ describe Puppet::Indirector::Ldap do
13
13
  end
14
14
 
15
15
  @connection = mock 'ldap'
16
+ end
17
+
18
+ describe "when instantiating ldap" do
19
+ it "should be deprecated" do
20
+ Puppet.expects(:deprecation_warning).with("Puppet::Indirector::Ldap is deprecated and will be removed in a future release of Puppet.")
21
+
22
+ @ldap_class.new
23
+ end
24
+
25
+ it "should not emit a deprecation warning when they are disabled" do
26
+ Puppet.expects(:warning).with(regexp_matches(/Puppet::Indirector::Ldap is deprecated/)).never
27
+ Puppet[:disable_warnings] = ['deprecations']
16
28
 
17
- @searcher = @ldap_class.new
29
+ @ldap_class.new
30
+ end
31
+
32
+ it "should only emit the deprecation warning once" do
33
+ Puppet.expects(:warning).with(regexp_matches(/Puppet::Indirector::Ldap is deprecated/)).once
34
+
35
+ @ldap_class.new
36
+ @ldap_class.new
37
+ end
18
38
  end
19
39
 
20
40
  describe "when searching ldap" do
21
41
  before do
42
+ @searcher = @ldap_class.new
22
43
  # Stub everything, and we can selectively replace with an expect as
23
44
  # we need to for testing.
24
45
  @searcher.stubs(:connection).returns(@connection)
@@ -507,6 +507,20 @@ describe Puppet::Node::Environment do
507
507
  Puppet::GettextConfig.expects(:use_text_domain).with(env.name)
508
508
  env.with_text_domain do; end
509
509
  end
510
+
511
+ it "yields block results" do
512
+ ran = false
513
+ expect(env.with_text_domain { ran = true; :result }).to eq(:result)
514
+ expect(ran).to eq(true)
515
+ end
516
+
517
+ it "yields block results when i18n is disabled" do
518
+ Puppet[:disable_i18n] = true
519
+
520
+ ran = false
521
+ expect(env.with_text_domain { ran = true; :result }).to eq(:result)
522
+ expect(ran).to eq(true)
523
+ end
510
524
  end
511
525
 
512
526
  end
@@ -22,4 +22,20 @@ describe "the 'tagged' function" do
22
22
  @scope.function_tagged(['one', 'two'])
23
23
  end.to raise_error(Puppet::ParseError, /is only available when compiling a catalog/)
24
24
  end
25
+
26
+ it 'should be case-insensitive' do
27
+ resource = Puppet::Parser::Resource.new(:file, "/file", :scope => @scope)
28
+ @scope.stubs(:resource).returns resource
29
+ @scope.function_tag ["one"]
30
+
31
+ expect(@scope.function_tagged(['One'])).to eq(true)
32
+ end
33
+
34
+ it 'should check if all specified tags are included' do
35
+ resource = Puppet::Parser::Resource.new(:file, "/file", :scope => @scope)
36
+ @scope.stubs(:resource).returns resource
37
+ @scope.function_tag ["one"]
38
+
39
+ expect(@scope.function_tagged(['one', 'two'])).to eq(false)
40
+ end
25
41
  end
@@ -10,12 +10,25 @@ describe "validating 4x" do
10
10
 
11
11
  let(:acceptor) { Puppet::Pops::Validation::Acceptor.new() }
12
12
  let(:validator) { Puppet::Pops::Validation::ValidatorFactory_4_0.new().validator(acceptor) }
13
+ let(:environment) { Puppet::Node::Environment.create(:bar, ['path']) }
13
14
 
14
15
  def validate(factory)
15
16
  validator.validate(factory.model)
16
17
  acceptor
17
18
  end
18
19
 
20
+ def deprecation_count(acceptor)
21
+ acceptor.diagnostics.select {|d| d.severity == :deprecation }.count
22
+ end
23
+
24
+ def with_environment(environment, env_params = {})
25
+ override_env = environment
26
+ override_env = environment.override_with(env_params) if env_params.count > 0
27
+ Puppet.override(current_environment: override_env) do
28
+ yield
29
+ end
30
+ end
31
+
19
32
  it 'should raise error for illegal class names' do
20
33
  expect(validate(parse('class aaa::_bbb {}'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
21
34
  expect(validate(parse('class Aaa {}'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
@@ -34,6 +47,72 @@ describe "validating 4x" do
34
47
  expect(validate(parse('function ::aaa() {}'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
35
48
  end
36
49
 
50
+ it 'should raise error for illegal definition locations' do
51
+ with_environment(environment) do
52
+ expect(validate(parse('function aaa::ccc() {}', 'path/aaa/manifests/bbb.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
53
+ expect(validate(parse('class bbb() {}', 'path/aaa/manifests/init.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
54
+ expect(validate(parse('define aaa::bbb::ccc::eee() {}', 'path/aaa/manifests/bbb/ddd.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
55
+ end
56
+ end
57
+
58
+ it 'should not raise error for legal definition locations' do
59
+ with_environment(environment) do
60
+ expect(validate(parse('function aaa::bbb() {}', 'path/aaa/manifests/bbb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
61
+ expect(validate(parse('class aaa() {}', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
62
+ expect(validate(parse('function aaa::bbB::ccc() {}', 'path/aaa/manifests/bBb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
63
+ expect(validate(parse('function aaa::bbb::ccc() {}', 'path/aaa/manifests/bbb/CCC.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
64
+ end
65
+ end
66
+
67
+ it 'should not raise error for class locations when not parsing a file' do
68
+ #nil/'' file means eval or some other way to get puppet language source code into the catalog
69
+ with_environment(environment) do
70
+ expect(validate(parse('function aaa::ccc() {}', nil))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
71
+ expect(validate(parse('function aaa::ccc() {}', ''))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
72
+ end
73
+ end
74
+
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
+ it 'should not raise error for definitions inside initial --manifest file' do
85
+ with_environment(environment, :manifest => 'a/manifest/file.pp') do
86
+ expect(validate(parse('class aaa() {}', 'a/manifest/file.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
87
+ end
88
+ end
89
+
90
+ it 'should not raise error for definitions inside initial --manifest directory' do
91
+ with_environment(environment, :manifest => 'a/manifest/dir') do
92
+ expect(validate(parse('class aaa() {}', 'a/manifest/dir/file1.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
93
+ expect(validate(parse('class bbb::ccc::ddd() {}', 'a/manifest/dir/and/more/stuff.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
94
+ end
95
+ end
96
+
97
+ it 'should not raise error for definitions not inside initial --manifest but also not in modulepath' do
98
+ with_environment(environment, :manifest => 'a/manifest/somewhere/else') do
99
+ expect(validate(parse('class aaa() {}', 'a/random/dir/file1.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
100
+ end
101
+ end
102
+
103
+ it 'should raise error if the file is in the modulepath but is not well formed' do
104
+ with_environment(environment) do
105
+ expect(validate(parse('class aaa::bbb::ccc() {}', 'path/manifest/aaa/bbb.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
106
+ expect(validate(parse('class aaa::bbb::ccc() {}', 'path/aaa/bbb/manifest/ccc.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
107
+ end
108
+ end
109
+
110
+ it 'should not raise error for definitions not inside initial --manifest but also not in modulepath because of only a case difference' do
111
+ with_environment(environment) do
112
+ expect(validate(parse('class aaa::bb() {}', 'Path/aaa/manifests/ccc.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
113
+ end
114
+ end
115
+
37
116
  it 'should raise error for illegal type names' do
38
117
  expect(validate(parse('type ::Aaa = Any'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
39
118
  end
@@ -56,6 +135,16 @@ describe "validating 4x" do
56
135
  expect(acceptor.error_count).to eql(0)
57
136
  expect(acceptor).to have_issue(Puppet::Pops::Issues::DUPLICATE_KEY)
58
137
  end
138
+
139
+ it 'produces a deprecation for illegal function locations' do
140
+ with_environment(environment) do
141
+ acceptor = validate(parse('function aaa::ccc() {}', 'path/aaa/manifests/bbb.pp'))
142
+ expect(deprecation_count(acceptor)).to eql(1)
143
+ expect(acceptor.warning_count).to eql(1)
144
+ expect(acceptor.error_count).to eql(0)
145
+ expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
146
+ end
147
+ end
59
148
  end
60
149
 
61
150
  context 'with --strict set to warning' do
@@ -74,12 +163,22 @@ describe "validating 4x" do
74
163
  expect(acceptor).to have_issue(Puppet::Pops::Issues::CLASS_NOT_VIRTUALIZABLE)
75
164
  end
76
165
 
77
- it 'produces a warning for exported class resource' do
166
+ it 'produces a warning for exported class resource' do
78
167
  acceptor = validate(parse('@@class { test: }'))
79
168
  expect(acceptor.warning_count).to eql(1)
80
169
  expect(acceptor.error_count).to eql(0)
81
170
  expect(acceptor).to have_issue(Puppet::Pops::Issues::CLASS_NOT_VIRTUALIZABLE)
82
171
  end
172
+
173
+ it 'produces a deprecation for illegal function locations' do
174
+ with_environment(environment) do
175
+ acceptor = validate(parse('function aaa::ccc() {}', 'path/aaa/manifests/bbb.pp'))
176
+ expect(deprecation_count(acceptor)).to eql(1)
177
+ expect(acceptor.warning_count).to eql(1)
178
+ expect(acceptor.error_count).to eql(0)
179
+ expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
180
+ end
181
+ end
83
182
  end
84
183
 
85
184
  context 'with --strict set to error' do
@@ -111,6 +210,16 @@ describe "validating 4x" do
111
210
  expect(acceptor.error_count).to eql(1)
112
211
  expect(acceptor).to have_issue(Puppet::Pops::Issues::CLASS_NOT_VIRTUALIZABLE)
113
212
  end
213
+
214
+ it 'produces a deprecation for illegal function locations' do
215
+ with_environment(environment) do
216
+ acceptor = validate(parse('function aaa::ccc() {}', 'path/aaa/manifests/bbb.pp'))
217
+ expect(deprecation_count(acceptor)).to eql(1)
218
+ expect(acceptor.warning_count).to eql(1)
219
+ expect(acceptor.error_count).to eql(0)
220
+ expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
221
+ end
222
+ end
114
223
  end
115
224
 
116
225
  context 'with --strict set to off' do
@@ -121,6 +230,16 @@ describe "validating 4x" do
121
230
  expect(acceptor.error_count).to eql(0)
122
231
  expect(acceptor).to_not have_issue(Puppet::Pops::Issues::DUPLICATE_KEY)
123
232
  end
233
+
234
+ it 'produces a deprecation for illegal function locations' do
235
+ with_environment(environment) do
236
+ acceptor = validate(parse('function aaa::ccc() {}', 'path/aaa/manifests/bbb.pp'))
237
+ expect(deprecation_count(acceptor)).to eql(1)
238
+ expect(acceptor.warning_count).to eql(1)
239
+ expect(acceptor.error_count).to eql(0)
240
+ expect(acceptor).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
241
+ end
242
+ end
124
243
  end
125
244
 
126
245
  context 'irrespective of --strict' do
@@ -145,7 +264,7 @@ describe "validating 4x" do
145
264
  expect(acceptor).to have_issue(Puppet::Pops::Issues::CLASS_NOT_VIRTUALIZABLE)
146
265
  end
147
266
 
148
- it 'produces a warning for exported class resource' do
267
+ it 'produces a warning for exported class resource' do
149
268
  acceptor = validate(parse('@@class { test: }'))
150
269
  expect(acceptor.warning_count).to eql(1)
151
270
  expect(acceptor.error_count).to eql(0)
@@ -156,6 +275,22 @@ describe "validating 4x" do
156
275
  context 'with --tasks set' do
157
276
  before(:each) { Puppet[:tasks] = true }
158
277
 
278
+ it 'raises an error for illegal plan names' do
279
+ with_environment(environment) do
280
+ expect(validate(parse('plan aaa::ccc::eee() {}', 'path/aaa/plans/bbb/ccc/eee.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
281
+ expect(validate(parse('plan aaa() {}', 'path/aaa/plans/aaa.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
282
+ expect(validate(parse('plan aaa::bbb() {}', 'path/aaa/plans/bbb/bbb.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
283
+ end
284
+ end
285
+
286
+ it 'accepts legal plan names' do
287
+ with_environment(environment) do
288
+ expect(validate(parse('plan aaa::ccc::eee() {}', 'path/aaa/plans/ccc/eee.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
289
+ expect(validate(parse('plan aaa() {}', 'path/aaa/plans/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
290
+ expect(validate(parse('plan aaa::bbb() {}', 'path/aaa/plans/bbb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
291
+ end
292
+ end
293
+
159
294
  it 'produces an error for application' do
160
295
  acceptor = validate(parse('application test {}'))
161
296
  expect(acceptor.error_count).to eql(1)
@@ -662,7 +797,7 @@ describe "validating 4x" do
662
797
  end
663
798
  end
664
799
 
665
- def parse(source)
666
- Puppet::Pops::Parser::Parser.new.parse_string(source)
800
+ def parse(source, path=nil)
801
+ Puppet::Pops::Parser::Parser.new.parse_string(source, path)
667
802
  end
668
803
  end
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
  require 'puppet/util/package'
4
3
 
@@ -235,6 +234,50 @@ describe provider_class do
235
234
  expect(@provider.process_values(command)).to eq(true)
236
235
  end
237
236
 
237
+ it "should return true for an array match with double quotes and spaces" do
238
+ command = ["values", "fake value", "== [ \"set\" , \"of\" , \"values\" ] "]
239
+ expect(@provider.process_values(command)).to eq(true)
240
+ end
241
+
242
+ it "should return true for an array match with internally escaped single quotes" do
243
+ @provider.aug.stubs(:match).returns(["set", "o'values", "here"])
244
+ @provider.aug.stubs(:get).returns('set').then.returns("o'values").then.returns('here')
245
+ command = ["values", "fake value", "== [ 'set', 'o\\'values', 'here']"]
246
+ expect(@provider.process_values(command)).to eq(true)
247
+ end
248
+
249
+ it "should return true for an array match with octal character sequences" do
250
+ command = ["values", "fake value", "== [\"\\x73et\", \"of\", \"values\"]"]
251
+ expect(@provider.process_values(command)).to eq(true)
252
+ end
253
+
254
+ it "should return true for an array match with hex character sequences" do
255
+ command = ["values", "fake value", "== [\"\\163et\", \"of\", \"values\"]"]
256
+ expect(@provider.process_values(command)).to eq(true)
257
+ end
258
+
259
+ it "should return true for an array match with short unicode escape sequences" do
260
+ command = ["values", "fake value", "== [\"\\u0073et\", \"of\", \"values\"]"]
261
+ expect(@provider.process_values(command)).to eq(true)
262
+ end
263
+
264
+ it "should return true for an array match with single character long unicode escape sequences" do
265
+ command = ["values", "fake value", "== [\"\\u{0073}et\", \"of\", \"values\"]"]
266
+ expect(@provider.process_values(command)).to eq(true)
267
+ end
268
+
269
+ it "should return true for an array match with multi-character long unicode escape sequences" do
270
+ command = ["values", "fake value", "== [\"\\u{0073 0065 0074}\", \"of\", \"values\"]"]
271
+ expect(@provider.process_values(command)).to eq(true)
272
+ end
273
+
274
+ it "should return true for an array match with literal backslashes" do
275
+ @provider.aug.stubs(:match).returns(["set", "o\\values", "here"])
276
+ @provider.aug.stubs(:get).returns('set').then.returns("o\\values").then.returns('here')
277
+ command = ["values", "fake value", "== [ 'set', 'o\\\\values', 'here']"]
278
+ expect(@provider.process_values(command)).to eq(true)
279
+ end
280
+
238
281
  it "should return false for an array non match" do
239
282
  command = ["values", "fake value", "== ['this', 'should', 'not', 'match']"]
240
283
  expect(@provider.process_values(command)).to eq(false)
@@ -249,6 +292,18 @@ describe provider_class do
249
292
  command = ["values", "fake value", "!= ['this', 'should', 'not', 'match']"]
250
293
  expect(@provider.process_values(command)).to eq(true)
251
294
  end
295
+
296
+ it "should return true for an array non match with double quotes and spaces" do
297
+ command = ["values", "fake value", "!= [ \"this\" , \"should\" ,\"not\", \"match\" ] "]
298
+ expect(@provider.process_values(command)).to eq(true)
299
+ end
300
+
301
+ it "should return true for an empty array match" do
302
+ @provider.aug.stubs(:match).returns([])
303
+ @provider.aug.stubs(:get)
304
+ command = ["values", "fake value", "== []"]
305
+ expect(@provider.process_values(command)).to eq(true)
306
+ end
252
307
  end
253
308
 
254
309
  describe "match filters" do
@@ -294,6 +349,11 @@ describe provider_class do
294
349
  expect(@provider.process_match(command)).to eq(true)
295
350
  end
296
351
 
352
+ it "should return true for an array match with double quotes and spaces" do
353
+ command = ["match", "fake value", "== [ \"set\" , \"of\" , \"values\" ] "]
354
+ expect(@provider.process_match(command)).to eq(true)
355
+ end
356
+
297
357
  it "should return false for an array non match" do
298
358
  command = ["match", "fake value", "== ['this', 'should', 'not', 'match']"]
299
359
  expect(@provider.process_match(command)).to eq(false)
@@ -308,6 +368,11 @@ describe provider_class do
308
368
  command = ["match", "fake value", "!= ['this', 'should', 'not', 'match']"]
309
369
  expect(@provider.process_match(command)).to eq(true)
310
370
  end
371
+
372
+ it "should return true for an array non match with double quotes and spaces" do
373
+ command = ["match", "fake value", "!= [ \"this\" , \"should\" ,\"not\", \"match\" ] "]
374
+ expect(@provider.process_match(command)).to eq(true)
375
+ end
311
376
  end
312
377
 
313
378
  describe "need to run" do
@@ -18,8 +18,6 @@ describe provider_class, :if => Puppet.features.posix? do
18
18
 
19
19
  FileTest.stubs(:file?).with('/usr/sbin/svcadm').returns true
20
20
  FileTest.stubs(:executable?).with('/usr/sbin/svcadm').returns true
21
- FileTest.stubs(:file?).with('/usr/sbin/svccfg').returns true
22
- FileTest.stubs(:executable?).with('/usr/sbin/svccfg').returns true
23
21
  FileTest.stubs(:file?).with('/usr/bin/svcs').returns true
24
22
  FileTest.stubs(:executable?).with('/usr/bin/svcs').returns true
25
23
  Facter.stubs(:value).with(:operatingsystem).returns('Solaris')
@@ -76,9 +74,9 @@ describe provider_class, :if => Puppet.features.posix? do
76
74
  @provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
77
75
  @provider.status
78
76
  end
79
- it "should return absent if svcs can't find the service" do
77
+ it "should return stopped if svcs can't find the service" do
80
78
  @provider.stubs(:svcs).raises(Puppet::ExecutionFailure.new("no svc found"))
81
- expect(@provider.status).to eq(:absent)
79
+ expect(@provider.status).to eq(:stopped)
82
80
  end
83
81
  it "should return running if online in svcs output" do
84
82
  @provider.stubs(:svcs).returns("online\t-")
@@ -168,14 +166,12 @@ describe provider_class, :if => Puppet.features.posix? do
168
166
 
169
167
  describe "when stopping" do
170
168
  it "should execute external command 'svcadm disable /system/myservice'" do
171
- @provider.stubs(:status).returns :running
172
169
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
173
170
  @provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
174
171
  @provider.stop
175
172
  end
176
173
 
177
174
  it "should error if timeout occurs while stopping the service" do
178
- @provider.stubs(:status).returns :running
179
175
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
180
176
  Timeout.expects(:timeout).with(60).raises(Timeout::Error)
181
177
  expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
@@ -34,6 +34,43 @@ describe Puppet::Type.type(:service).provider(:upstart) do
34
34
  expect(described_class.default?).to be_truthy
35
35
  end
36
36
 
37
+ context "upstart daemon existence confine" do
38
+ # We have a separate method here because our search for the upstart daemon
39
+ # confine expects it to be the last confine declared in the upstart provider.
40
+ # If in the future we add other confines below it or change its order, these
41
+ # unit tests will fail. Placing knowledge of where this confine is located
42
+ # in one place makes updating it less painful in case we ever need to do this.
43
+ def assert_upstart_daemon_existence_confine_is(expected_value)
44
+ upstart_daemon_existence_confine = provider_class.confine_collection.instance_variable_get(:@confines)[-1]
45
+ expect(upstart_daemon_existence_confine.valid?).to be(expected_value)
46
+ end
47
+
48
+ let(:initctl_version) { ['/sbin/initctl', 'version', '--quiet'] }
49
+ before(:each) do
50
+ # Stub out /sbin/initctl
51
+ Puppet::Util.stubs(:which).with('/sbin/initctl').returns('/sbin/initctl')
52
+
53
+ # Both of our tests are asserting the confine :true block that shells out to
54
+ # `initctl version --quiet`. Its expression is evaluated at provider load-time.
55
+ # Hence before each test, we want to reload the upstart provider so that the
56
+ # confine is re-evaluated.
57
+ Puppet::Type.type(:service).unprovide(:upstart)
58
+ end
59
+
60
+ it "should return true when the daemon is running" do
61
+ Puppet::Util::Execution.expects(:execute).with(initctl_version, instance_of(Hash))
62
+ assert_upstart_daemon_existence_confine_is(true)
63
+ end
64
+
65
+ it "should return false when the daemon is not running" do
66
+ Puppet::Util::Execution.expects(:execute)
67
+ .with(initctl_version, instance_of(Hash))
68
+ .raises(Puppet::ExecutionFailure, "initctl failed!")
69
+
70
+ assert_upstart_daemon_existence_confine_is(false)
71
+ end
72
+ end
73
+
37
74
  describe "excluding services" do
38
75
  it "ignores tty and serial on Redhat systems" do
39
76
  Facter.stubs(:value).with(:osfamily).returns('RedHat')
@@ -72,11 +72,11 @@ describe Puppet::Settings::AutosignSetting do
72
72
  end
73
73
 
74
74
  describe "converting the setting to a resource" do
75
- it "converts the file path to a file resource" do
75
+ it "converts the file path to a file resource", :if => !Puppet::Util::Platform.windows? do
76
76
  path = File.expand_path('/path/to/autosign.conf')
77
77
  settings.stubs(:value).with('autosign', nil, false).returns(path)
78
78
  Puppet::FileSystem.stubs(:exist?).with(path).returns true
79
- Puppet.stubs(:features).returns(stub(:root? => true, :microsoft_windows? => false))
79
+ Puppet.features.expects(:root?).returns(true)
80
80
 
81
81
  setting.mode = '0664'
82
82
  setting.owner = 'service'