puppet 2.7.14 → 2.7.16

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 (111) hide show
  1. data/CHANGELOG +85 -0
  2. data/conf/redhat/puppet.spec +31 -4
  3. data/lib/puppet.rb +1 -1
  4. data/lib/puppet/defaults.rb +2 -3
  5. data/lib/puppet/face/module/install.rb +3 -3
  6. data/lib/puppet/face/module/search.rb +3 -3
  7. data/lib/puppet/indirector/face.rb +1 -1
  8. data/lib/puppet/network/http_pool.rb +17 -8
  9. data/lib/puppet/node/environment.rb +1 -3
  10. data/lib/puppet/parser/ast.rb +1 -1
  11. data/lib/puppet/parser/compiler.rb +2 -10
  12. data/lib/puppet/parser/functions/template.rb +2 -1
  13. data/lib/puppet/parser/lexer.rb +2 -2
  14. data/lib/puppet/parser/scope.rb +3 -2
  15. data/lib/puppet/provider/package/gem.rb +3 -1
  16. data/lib/puppet/provider/package/pkg.rb +18 -2
  17. data/lib/puppet/provider/service/gentoo.rb +5 -0
  18. data/lib/puppet/provider/service/init.rb +12 -14
  19. data/lib/puppet/provider/service/redhat.rb +1 -1
  20. data/lib/puppet/provider/service/upstart.rb +257 -7
  21. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +6 -9
  22. data/lib/puppet/reports/http.rb +1 -1
  23. data/lib/puppet/reports/tagmail.rb +1 -1
  24. data/lib/puppet/type/cron.rb +5 -0
  25. data/lib/puppet/type/filebucket.rb +12 -0
  26. data/lib/puppet/util.rb +15 -9
  27. data/lib/puppet/util/colors.rb +94 -64
  28. data/lib/puppet/util/platform.rb +15 -0
  29. data/man/man5/puppet.conf.5 +73 -27
  30. data/man/man8/filebucket.8 +1 -1
  31. data/man/man8/pi.8 +1 -1
  32. data/man/man8/puppet-agent.8 +17 -17
  33. data/man/man8/puppet-apply.8 +8 -3
  34. data/man/man8/puppet-ca.8 +183 -0
  35. data/man/man8/puppet-catalog.8 +17 -10
  36. data/man/man8/puppet-cert.8 +1 -1
  37. data/man/man8/puppet-certificate.8 +27 -11
  38. data/man/man8/puppet-certificate_request.8 +12 -11
  39. data/man/man8/puppet-certificate_revocation_list.8 +11 -10
  40. data/man/man8/puppet-config.8 +1 -1
  41. data/man/man8/puppet-describe.8 +1 -1
  42. data/man/man8/puppet-device.8 +2 -2
  43. data/man/man8/puppet-doc.8 +15 -3
  44. data/man/man8/puppet-facts.8 +18 -8
  45. data/man/man8/puppet-file.8 +13 -22
  46. data/man/man8/puppet-filebucket.8 +1 -1
  47. data/man/man8/puppet-help.8 +1 -1
  48. data/man/man8/puppet-inspect.8 +10 -2
  49. data/man/man8/puppet-instrumentation_data.8 +145 -0
  50. data/man/man8/puppet-instrumentation_listener.8 +222 -0
  51. data/man/man8/puppet-instrumentation_probe.8 +207 -0
  52. data/man/man8/puppet-key.8 +11 -7
  53. data/man/man8/puppet-kick.8 +35 -3
  54. data/man/man8/puppet-man.8 +1 -1
  55. data/man/man8/puppet-master.8 +1 -1
  56. data/man/man8/puppet-module.8 +451 -0
  57. data/man/man8/puppet-node.8 +64 -22
  58. data/man/man8/puppet-parser.8 +1 -1
  59. data/man/man8/puppet-plugin.8 +1 -1
  60. data/man/man8/puppet-queue.8 +1 -1
  61. data/man/man8/puppet-report.8 +12 -8
  62. data/man/man8/puppet-resource.8 +1 -1
  63. data/man/man8/puppet-resource_type.8 +11 -7
  64. data/man/man8/puppet-secret_agent.8 +1 -1
  65. data/man/man8/puppet-status.8 +11 -7
  66. data/man/man8/puppet.8 +1 -1
  67. data/man/man8/puppetca.8 +1 -1
  68. data/man/man8/puppetd.8 +17 -17
  69. data/man/man8/puppetdoc.8 +15 -3
  70. data/man/man8/puppetmasterd.8 +1 -1
  71. data/man/man8/puppetqd.8 +1 -1
  72. data/man/man8/puppetrun.8 +35 -3
  73. data/man/man8/ralsh.8 +1 -1
  74. data/spec/fixtures/unit/provider/package/gem/line-with-1.8.5-warning +14 -0
  75. data/spec/fixtures/unit/provider/package/pkg/{dummy → dummy_solaris10} +0 -0
  76. data/spec/fixtures/unit/provider/package/pkg/dummy_solaris11 +1 -0
  77. data/spec/fixtures/unit/provider/package/pkg/solaris11 +12 -0
  78. data/spec/fixtures/unit/provider/package/pkg/unknown_status +12 -0
  79. data/spec/fixtures/unit/provider/service/gentoo/rc_update_show +30 -0
  80. data/spec/integration/defaults_spec.rb +2 -7
  81. data/spec/integration/network/server/mongrel_spec.rb +16 -10
  82. data/spec/integration/network/server/webrick_spec.rb +16 -9
  83. data/spec/integration/provider/service/init_spec.rb +20 -4
  84. data/spec/integration/provider/ssh_authorized_key_spec.rb +119 -107
  85. data/spec/unit/face/module/install_spec.rb +16 -4
  86. data/spec/unit/network/http/api/v1_spec.rb +8 -0
  87. data/spec/unit/network/http_pool_spec.rb +80 -74
  88. data/spec/unit/node/environment_spec.rb +9 -4
  89. data/spec/unit/parser/ast/leaf_spec.rb +2 -2
  90. data/spec/unit/parser/ast_spec.rb +3 -3
  91. data/spec/unit/parser/compiler_spec.rb +0 -17
  92. data/spec/unit/parser/lexer_spec.rb +45 -2
  93. data/spec/unit/parser/scope_spec.rb +181 -14
  94. data/spec/unit/provider/package/gem_spec.rb +17 -1
  95. data/spec/unit/provider/package/pkg_spec.rb +70 -22
  96. data/spec/unit/provider/service/gentoo_spec.rb +237 -0
  97. data/spec/unit/provider/service/init_spec.rb +2 -2
  98. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  99. data/spec/unit/provider/service/upstart_spec.rb +414 -5
  100. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +24 -0
  101. data/spec/unit/reports/tagmail_spec.rb +50 -0
  102. data/spec/unit/type/cron_spec.rb +21 -1
  103. data/spec/unit/type/filebucket_spec.rb +39 -9
  104. data/spec/unit/util/colors_spec.rb +69 -0
  105. data/spec/unit/util/log/destinations_spec.rb +17 -9
  106. data/spec/unit/util/log_spec.rb +2 -1
  107. data/spec/unit/util_spec.rb +11 -0
  108. data/tasks/rake/gem.rake +1 -1
  109. data/tasks/rake/manpages.rake +11 -3
  110. data/test/network/handler/fileserver.rb +7 -1
  111. metadata +22 -10
@@ -161,12 +161,17 @@ describe Puppet::Node::Environment do
161
161
  end
162
162
 
163
163
  it "should be able to return an individual module that exists in its module path" do
164
+ env.stubs(:modules).returns [Puppet::Module.new('one'), Puppet::Module.new('two'), Puppet::Module.new('three')]
164
165
 
165
- mod = mock 'module'
166
- Puppet::Module.expects(:new).with("one", :environment => env).returns mod
167
- mod.expects(:exist?).returns true
166
+ mod = env.module('one')
167
+ mod.should be_a(Puppet::Module)
168
+ mod.name.should == 'one'
169
+ end
170
+
171
+ it "should not return a module if the module doesn't exist" do
172
+ env.stubs(:modules).returns [Puppet::Module.new('one'), Puppet::Module.new('two'), Puppet::Module.new('three')]
168
173
 
169
- env.module("one").should equal(mod)
174
+ env.module('four').should be_nil
170
175
  end
171
176
 
172
177
  it "should return nil if asked for a module that does not exist in its path" do
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env rspec
1
+ #!/usr/bin/env ruby -S rspec
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Puppet::Parser::AST::Leaf do
@@ -95,7 +95,7 @@ describe Puppet::Parser::AST::Undef do
95
95
  end
96
96
 
97
97
  it "should not match undef with an empty string" do
98
- @undef.evaluate_match("", @scope).should be_false
98
+ @undef.evaluate_match("", @scope).should be_true
99
99
  end
100
100
  end
101
101
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env rspec
1
+ #!/usr/bin/env ruby -S rspec
2
2
  require 'spec_helper'
3
3
 
4
4
  require 'puppet/parser/ast'
@@ -102,9 +102,9 @@ describe 'AST Generic Child' do
102
102
  @evaluateable.evaluate_match(parameter, @scope)
103
103
  end
104
104
 
105
- it "should not match '' if value is undef" do
105
+ it "should match '' if value is undef" do
106
106
  @evaluateable.value = :undef
107
- @evaluateable.evaluate_match('', @scope).should be_false
107
+ @evaluateable.evaluate_match('', @scope).should be_true
108
108
  end
109
109
  end
110
110
  end
@@ -741,23 +741,6 @@ describe Puppet::Parser::Compiler do
741
741
 
742
742
  @compiler.send(:evaluate_ast_node)
743
743
  end
744
-
745
- it "should set the node's scope as the top scope" do
746
- node_resource = stub 'node resource', :ref => "Node[c]", :evaluate => nil, :type => "node"
747
- node_class = stub 'node', :name => "c", :ensure_in_catalog => node_resource
748
-
749
- @compiler.known_resource_types.stubs(:node).with("c").returns(node_class)
750
-
751
- # The #evaluate method normally does this.
752
- scope = stub 'scope', :source => "mysource"
753
- @compiler.topscope.expects(:class_scope).with(node_class).returns(scope)
754
- node_resource.stubs(:evaluate)
755
- @compiler.stubs :create_settings_scope
756
-
757
- @compiler.compile
758
-
759
- @compiler.topscope.should equal(scope)
760
- end
761
744
  end
762
745
 
763
746
  describe "when managing resource overrides" do
@@ -406,6 +406,44 @@ describe Puppet::Parser::Lexer::TOKENS[:RETURN] do
406
406
  end
407
407
  end
408
408
 
409
+ shared_examples_for "variable names in the lexer" do |prefix|
410
+ # Watch out - a regex might match a *prefix* on these, not just the whole
411
+ # word, so make sure you don't have false positive or negative results based
412
+ # on that.
413
+ legal = %w{f foo f::b foo::b f::bar foo::bar 3 foo3 3foo}
414
+ illegal = %w{f- f-o -f f::-o f::o- f::o-o}
415
+
416
+ ["", "::"].each do |global_scope|
417
+ legal.each do |name|
418
+ var = prefix + global_scope + name
419
+ it "should accept #{var.inspect} as a valid variable name" do
420
+ (subject.regex.match(var) || [])[0].should == var
421
+ end
422
+ end
423
+
424
+ illegal.each do |name|
425
+ var = prefix + global_scope + name
426
+ it "should NOT accept #{var.inspect} as a valid variable name" do
427
+ (subject.regex.match(var) || [])[0].should_not == var
428
+ end
429
+ end
430
+ end
431
+ end
432
+
433
+ describe Puppet::Parser::Lexer::TOKENS[:DOLLAR_VAR] do
434
+ its(:skip_text) { should be_false }
435
+ its(:incr_line) { should be_false }
436
+
437
+ it_should_behave_like "variable names in the lexer", '$'
438
+ end
439
+
440
+ describe Puppet::Parser::Lexer::TOKENS[:VARIABLE] do
441
+ its(:skip_text) { should be_false }
442
+ its(:incr_line) { should be_false }
443
+
444
+ it_should_behave_like "variable names in the lexer", ''
445
+ end
446
+
409
447
  def tokens_scanned_from(s)
410
448
  lexer = Puppet::Parser::Lexer.new
411
449
  lexer.string = s
@@ -663,11 +701,16 @@ describe "Puppet::Parser::Lexer in the old tests" do
663
701
  end
664
702
 
665
703
  it "should correctly lex variables" do
666
- ["$variable", "$::variable", "$qualified::variable", "$further::qualified::variable", "$hyphenated-variable", "$-variable-with-leading-dash"].each do |string|
704
+ ["$variable", "$::variable", "$qualified::variable", "$further::qualified::variable"].each do |string|
667
705
  tokens_scanned_from(string).should be_like([:VARIABLE,string.sub(/^\$/,'')])
668
706
  end
669
707
  end
670
708
 
709
+ it "should end variables at `-`" do
710
+ tokens_scanned_from('$hyphenated-variable').
711
+ should be_like [:VARIABLE, "hyphenated"], [:MINUS, '-'], [:NAME, 'variable']
712
+ end
713
+
671
714
  it "should not include whitespace in a variable" do
672
715
  tokens_scanned_from("$foo bar").should_not be_like([:VARIABLE, "foo bar"])
673
716
  end
@@ -681,7 +724,7 @@ describe "Puppet::Parser::Lexer in the old tests when lexing example files" do
681
724
  it "should correctly lex #{file}" do
682
725
  lexer = Puppet::Parser::Lexer.new
683
726
  lexer.file = file
684
- lambda { lexer.fullscan }.should_not raise_error
727
+ expect { lexer.fullscan }.should_not raise_error
685
728
  end
686
729
  end
687
730
  end
@@ -280,6 +280,22 @@ describe Puppet::Parser::Scope do
280
280
  end
281
281
  end
282
282
 
283
+ it "finds values in its included scope for a defined type (DEPRECATED)" do
284
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
285
+ node default {
286
+ include foo
287
+ }
288
+ class foo {
289
+ $var = "foo_msg"
290
+ bar { "testing": }
291
+ }
292
+ define bar() {
293
+ notify { 'something': message => $var, }
294
+ }
295
+ MANIFEST
296
+ end
297
+ end
298
+
283
299
  it "recognizes a dynamically scoped boolean (DEPRECATED)" do
284
300
  expect_the_message_to_be(true) do <<-MANIFEST
285
301
  node default {
@@ -337,32 +353,33 @@ describe Puppet::Parser::Scope do
337
353
  end
338
354
  end
339
355
 
340
- it "finds top scope when the class is included before the node defines the var" do
341
- expect_the_message_to_be('top_msg') do <<-MANIFEST
342
- $var = "top_msg"
343
- node parent {
344
- include foo
345
- }
346
- node default inherits parent {
347
- $var = "default_msg"
356
+ it "finds values in its local scope" do
357
+ expect_the_message_to_be('local_msg') do <<-MANIFEST
358
+ node default {
359
+ include baz
348
360
  }
349
361
  class foo {
362
+ }
363
+ class bar inherits foo {
364
+ $var = "local_msg"
350
365
  notify { 'something': message => $var, }
351
366
  }
367
+ class baz {
368
+ include bar
369
+ }
352
370
  MANIFEST
353
371
  end
354
372
  end
355
373
 
356
-
357
- it "should find values in its local scope" do
358
- expect_the_message_to_be('local_msg') do <<-MANIFEST
374
+ it "finds values in its inherited scope" do
375
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
359
376
  node default {
360
377
  include baz
361
378
  }
362
379
  class foo {
380
+ $var = "foo_msg"
363
381
  }
364
382
  class bar inherits foo {
365
- $var = "local_msg"
366
383
  notify { 'something': message => $var, }
367
384
  }
368
385
  class baz {
@@ -372,7 +389,40 @@ describe Puppet::Parser::Scope do
372
389
  end
373
390
  end
374
391
 
375
- it "should find values in its inherited scope" do
392
+ it "prefers values in its local scope over values in the inherited scope" do
393
+ expect_the_message_to_be('local_msg') do <<-MANIFEST
394
+ include bar
395
+
396
+ class foo {
397
+ $var = "inherited"
398
+ }
399
+
400
+ class bar inherits foo {
401
+ $var = "local_msg"
402
+ notify { 'something': message => $var, }
403
+ }
404
+ MANIFEST
405
+ end
406
+ end
407
+
408
+ it "finds a qualified variable by following parent scopes of the specified scope" do
409
+ expect_the_message_to_be("from node") do <<-MANIFEST
410
+ class c {
411
+ notify { 'something': message => "$a::b" }
412
+ }
413
+
414
+ class a { }
415
+
416
+ node default {
417
+ $b = "from node"
418
+ include a
419
+ include c
420
+ }
421
+ MANIFEST
422
+ end
423
+ end
424
+
425
+ it "finds values in its inherited scope when the inherited class is qualified to the top" do
376
426
  expect_the_message_to_be('foo_msg') do <<-MANIFEST
377
427
  node default {
378
428
  include baz
@@ -380,7 +430,7 @@ describe Puppet::Parser::Scope do
380
430
  class foo {
381
431
  $var = "foo_msg"
382
432
  }
383
- class bar inherits foo {
433
+ class bar inherits ::foo {
384
434
  notify { 'something': message => $var, }
385
435
  }
386
436
  class baz {
@@ -390,6 +440,96 @@ describe Puppet::Parser::Scope do
390
440
  end
391
441
  end
392
442
 
443
+ it "prefers values in its local scope over values in the inherited scope when the inherited class is fully qualified" do
444
+ expect_the_message_to_be('local_msg') do <<-MANIFEST
445
+ include bar
446
+
447
+ class foo {
448
+ $var = "inherited"
449
+ }
450
+
451
+ class bar inherits ::foo {
452
+ $var = "local_msg"
453
+ notify { 'something': message => $var, }
454
+ }
455
+ MANIFEST
456
+ end
457
+ end
458
+
459
+ it "finds values in top scope when the inherited class is qualified to the top" do
460
+ expect_the_message_to_be('top msg') do <<-MANIFEST
461
+ $var = "top msg"
462
+ class foo {
463
+ }
464
+
465
+ class bar inherits ::foo {
466
+ notify { 'something': message => $var, }
467
+ }
468
+
469
+ include bar
470
+ MANIFEST
471
+ end
472
+ end
473
+
474
+ it "finds values in its inherited scope when the inherited class is a nested class that shadows another class at the top" do
475
+ expect_the_message_to_be('inner baz') do <<-MANIFEST
476
+ node default {
477
+ include foo::bar
478
+ }
479
+ class baz {
480
+ $var = "top baz"
481
+ }
482
+ class foo {
483
+ class baz {
484
+ $var = "inner baz"
485
+ }
486
+
487
+ class bar inherits baz {
488
+ notify { 'something': message => $var, }
489
+ }
490
+ }
491
+ MANIFEST
492
+ end
493
+ end
494
+
495
+ it "finds values in its inherited scope when the inherited class is qualified to a nested class and qualified to the top" do
496
+ expect_the_message_to_be('top baz') do <<-MANIFEST
497
+ node default {
498
+ include foo::bar
499
+ }
500
+ class baz {
501
+ $var = "top baz"
502
+ }
503
+ class foo {
504
+ class baz {
505
+ $var = "inner baz"
506
+ }
507
+
508
+ class bar inherits ::baz {
509
+ notify { 'something': message => $var, }
510
+ }
511
+ }
512
+ MANIFEST
513
+ end
514
+ end
515
+
516
+ it "finds values in its inherited scope when the inherited class is qualified" do
517
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
518
+ node default {
519
+ include bar
520
+ }
521
+ class foo {
522
+ class baz {
523
+ $var = "foo_msg"
524
+ }
525
+ }
526
+ class bar inherits foo::baz {
527
+ notify { 'something': message => $var, }
528
+ }
529
+ MANIFEST
530
+ end
531
+ end
532
+
393
533
  it "prefers values in its inherited scope over those in the node (with intermediate inclusion)" do
394
534
  expect_the_message_to_be('foo_msg') do <<-MANIFEST
395
535
  node default {
@@ -530,6 +670,33 @@ describe Puppet::Parser::Scope do
530
670
  MANIFEST
531
671
  end
532
672
  end
673
+
674
+ it "finds top scope variables referenced inside a defined type" do
675
+ expect_the_message_to_be('top_msg') do <<-MANIFEST
676
+ $var = "top_msg"
677
+ node default {
678
+ foo { "testing": }
679
+ }
680
+ define foo() {
681
+ notify { 'something': message => $var, }
682
+ }
683
+ MANIFEST
684
+ end
685
+ end
686
+
687
+ it "finds node scope variables referenced inside a defined type" do
688
+ expect_the_message_to_be('node_msg') do <<-MANIFEST
689
+ $var = "top_msg"
690
+ node default {
691
+ $var = "node_msg"
692
+ foo { "testing": }
693
+ }
694
+ define foo() {
695
+ notify { 'something': message => $var, }
696
+ }
697
+ MANIFEST
698
+ end
699
+ end
533
700
  end
534
701
  end
535
702
 
@@ -101,7 +101,6 @@ describe provider_class do
101
101
  end
102
102
  end
103
103
 
104
-
105
104
  describe "#instances" do
106
105
  before do
107
106
  provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
@@ -123,5 +122,22 @@ describe provider_class do
123
122
  {:ensure => ["0.8.7", "0.6.9"], :provider => :gem, :name => 'vagrant'}
124
123
  ]
125
124
  end
125
+
126
+ it "should not fail when an unmatched line is returned" do
127
+ provider_class.expects(:execute).with(%w{/my/gem list --local}).
128
+ returns(File.read(my_fixture('line-with-1.8.5-warning')))
129
+
130
+ provider_class.instances.map {|p| p.properties}.
131
+ should == [{:provider=>:gem, :ensure=>["0.3.2"], :name=>"columnize"},
132
+ {:provider=>:gem, :ensure=>["1.1.3"], :name=>"diff-lcs"},
133
+ {:provider=>:gem, :ensure=>["0.0.1"], :name=>"metaclass"},
134
+ {:provider=>:gem, :ensure=>["0.10.5"], :name=>"mocha"},
135
+ {:provider=>:gem, :ensure=>["0.8.7"], :name=>"rake"},
136
+ {:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-core"},
137
+ {:provider=>:gem, :ensure=>["2.9.1"], :name=>"rspec-expectations"},
138
+ {:provider=>:gem, :ensure=>["2.9.0"], :name=>"rspec-mocks"},
139
+ {:provider=>:gem, :ensure=>["0.9.0"], :name=>"rubygems-bundler"},
140
+ {:provider=>:gem, :ensure=>["1.11.3.3"], :name=>"rvm"}]
141
+ end
126
142
  end
127
143
  end
@@ -29,20 +29,39 @@ describe Puppet::Type.type(:package).provider(:pkg) do
29
29
  describe "when calling instances" do
30
30
  it "should correctly parse lines with preferred publisher" do
31
31
  described_class.expects(:pkg).with(:list,'-H').returns File.read(my_fixture('simple'))
32
- @instances = described_class.instances.map { |p| Hash.new(:name => p.get(:name), :ensure => p.get(:ensure)) }
32
+ @instances = described_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
33
33
  @instances.size.should == 4
34
- @instances[0].should == Hash.new(:name => 'SUNPython', :ensure => :present)
35
- @instances[1].should == Hash.new(:name => 'SUNWbind', :ensure => :present)
36
- @instances[2].should == Hash.new(:name => 'SUNWdistro-license-copyright', :ensure => :present)
37
- @instances[3].should == Hash.new(:name => 'SUNWfppd', :ensure => :present)
34
+ @instances[0].should == {:name => 'SUNPython', :ensure => :present}
35
+ @instances[1].should == {:name => 'SUNWbind', :ensure => :present}
36
+ @instances[2].should == {:name => 'SUNWdistro-license-copyright', :ensure => :present}
37
+ @instances[3].should == {:name => 'SUNWfppd', :ensure => :present}
38
38
  end
39
39
 
40
40
  it "should correctly parse lines with non preferred publisher" do
41
41
  described_class.expects(:pkg).with(:list,'-H').returns File.read(my_fixture('publisher'))
42
- @instances = described_class.instances.map { |p| Hash.new(:name => p.get(:name), :ensure => p.get(:ensure)) }
42
+ @instances = described_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure)} }
43
43
  @instances.size.should == 2
44
- @instances[0].should == Hash.new(:name => 'SUNWpcre', :ensure => :present)
45
- @instances[1].should == Hash.new(:name => 'service/network/ssh', :ensure => :present)
44
+ @instances[0].should == {:name => 'SUNWpcre', :ensure => :present}
45
+ @instances[1].should == {:name => 'service/network/ssh', :ensure => :present}
46
+ end
47
+
48
+ it "should correctly parse lines on solaris 11" do
49
+ described_class.expects(:pkg).with(:list, '-H').returns File.read(my_fixture('solaris11'))
50
+ described_class.expects(:warning).never
51
+ @instances = described_class.instances.map { |p| {:name => p.get(:name), :ensure => p.get(:ensure) }}
52
+ @instances.size.should == 12
53
+ @instances[0].should == {:name => 'compress/zip', :ensure => :present}
54
+ @instances[1].should == {:name => 'archiver/gnu-tar', :ensure => :present}
55
+ @instances[2].should == {:name => 'compress/bzip2', :ensure => :present}
56
+ @instances[3].should == {:name => 'compress/gzip', :ensure => :present}
57
+ @instances[4].should == {:name => 'compress/p7zip', :ensure => :present}
58
+ @instances[5].should == {:name => 'compress/unzip', :ensure => :present}
59
+ @instances[6].should == {:name => 'compress/zip', :ensure => :present}
60
+ @instances[7].should == {:name => 'x11/library/toolkit/libxaw7', :ensure => :present}
61
+ @instances[8].should == {:name => 'x11/library/toolkit/libxt', :ensure => :present}
62
+ @instances[9].should == {:name => 'shell/bash', :ensure => :present}
63
+ @instances[10].should == {:name => 'shell/zsh', :ensure => :present}
64
+ @instances[11].should == {:name => 'security/sudo', :ensure => :present}
46
65
  end
47
66
 
48
67
  it "should warn about incorrect lines" do
@@ -52,25 +71,54 @@ describe Puppet::Type.type(:package).provider(:pkg) do
52
71
  described_class.expects(:warning).with "Failed to match 'pkg list' line #{error_line.inspect}"
53
72
  described_class.instances
54
73
  end
74
+
75
+ it "should warn about unknown package status" do
76
+ described_class.expects(:pkg).with(:list,'-H').returns File.read(my_fixture('unknown_status'))
77
+ described_class.expects(:warning).with "unknown package state for compress/unzip: x--"
78
+ described_class.instances
79
+ end
55
80
  end
56
81
 
57
82
  describe "when query a package" do
58
- it "should find the package" do
59
- @provider.stubs(:pkg).with(:list,'-H','dummy').returns File.read(my_fixture('dummy'))
60
- @provider.query.should == {
61
- :name => 'dummy',
62
- :ensure => :present,
63
- :version => '2.5.5-0.111',
64
- :status => "installed",
65
- :provider => :pkg,
66
- }
83
+
84
+ context "on solaris 10" do
85
+ it "should find the package" do
86
+ @provider.stubs(:pkg).with(:list,'-H','dummy').returns File.read(my_fixture('dummy_solaris10'))
87
+ @provider.query.should == {
88
+ :name => 'dummy',
89
+ :ensure => :present,
90
+ :version => '2.5.5-0.111',
91
+ :status => "installed",
92
+ :provider => :pkg,
93
+ }
94
+ end
95
+
96
+ it "should return :absent when the package is not found" do
97
+ # I dont know what the acutal error looks like, but according to type/pkg.rb we're just
98
+ # reacting on the Exception anyways
99
+ @provider.expects(:pkg).with(:list, "-H", "dummy").raises Puppet::ExecutionFailure, 'Not found'
100
+ @provider.query.should == {:ensure => :absent, :name => "dummy"}
101
+ end
67
102
  end
68
103
 
69
- it "should return :absent when the package is not found" do
70
- # I dont know what the acutal error looks like, but according to type/pkg.rb we're just
71
- # reacting on the Exception anyways
72
- @provider.expects(:pkg).with(:list, "-H", "dummy").raises Puppet::ExecutionFailure, 'Not found'
73
- @provider.query.should == {:ensure => :absent, :name => "dummy"}
104
+ context "on solaris 11" do
105
+ it "should find the package" do
106
+ @provider.stubs(:pkg).with(:list,'-H','dummy').returns File.read(my_fixture('dummy_solaris11'))
107
+ @provider.query.should == {
108
+ :name => 'dummy',
109
+ :ensure => :present,
110
+ :version => '1.0.6-0.175.0.0.0.2.537',
111
+ :status => "installed",
112
+ :provider => :pkg,
113
+ }
114
+ end
115
+
116
+ it "should return :absent when the package is not found" do
117
+ # I dont know what the acutal error looks like, but according to type/pkg.rb we're just
118
+ # reacting on the Exception anyways
119
+ @provider.expects(:pkg).with(:list, "-H", "dummy").raises Puppet::ExecutionFailure, 'Not found'
120
+ @provider.query.should == {:ensure => :absent, :name => "dummy"}
121
+ end
74
122
  end
75
123
 
76
124
  it "should return :absent when the packageline cannot be parsed" do