puppet 3.7.1-x64-mingw32 → 3.7.2-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 (58) hide show
  1. data/ext/build_defaults.yaml +3 -3
  2. data/ext/debian/control +2 -0
  3. data/ext/project_data.yaml +2 -2
  4. data/lib/puppet/application.rb +1 -4
  5. data/lib/puppet/configurer.rb +6 -4
  6. data/lib/puppet/environments.rb +47 -3
  7. data/lib/puppet/indirector/node/exec.rb +1 -1
  8. data/lib/puppet/indirector/request.rb +1 -2
  9. data/lib/puppet/module.rb +1 -1
  10. data/lib/puppet/module_tool.rb +1 -1
  11. data/lib/puppet/network/http/webrick.rb +17 -7
  12. data/lib/puppet/node.rb +2 -2
  13. data/lib/puppet/parser/ast/pops_bridge.rb +1 -11
  14. data/lib/puppet/parser/compiler.rb +1 -2
  15. data/lib/puppet/parser/resource.rb +1 -3
  16. data/lib/puppet/parser/resource/param.rb +1 -1
  17. data/lib/puppet/parser/type_loader.rb +1 -1
  18. data/lib/puppet/pops/evaluator/access_operator.rb +3 -11
  19. data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
  20. data/lib/puppet/pops/evaluator/runtime3_support.rb +30 -4
  21. data/lib/puppet/pops/model/factory.rb +16 -1
  22. data/lib/puppet/pops/parser/egrammar.ra +1 -1
  23. data/lib/puppet/pops/parser/eparser.rb +1 -1
  24. data/lib/puppet/pops/parser/parser_support.rb +19 -1
  25. data/lib/puppet/pops/types/type_calculator.rb +19 -14
  26. data/lib/puppet/provider/package/pkg.rb +12 -1
  27. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +15 -16
  28. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +16 -0
  29. data/lib/puppet/resource.rb +1 -8
  30. data/lib/puppet/settings.rb +17 -0
  31. data/lib/puppet/type/user.rb +11 -1
  32. data/lib/puppet/util/autoload.rb +10 -6
  33. data/lib/puppet/util/monkey_patches.rb +2 -2
  34. data/lib/puppet/version.rb +1 -1
  35. data/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning +2 -0
  36. data/spec/fixtures/unit/type/user/authorized_keys +1 -0
  37. data/spec/integration/application/apply_spec.rb +29 -23
  38. data/spec/integration/parser/future_compiler_spec.rb +56 -0
  39. data/spec/integration/type/user_spec.rb +22 -1
  40. data/spec/lib/puppet_spec/files.rb +1 -0
  41. data/spec/unit/environments_spec.rb +99 -0
  42. data/spec/unit/network/http/webrick_spec.rb +21 -2
  43. data/spec/unit/parser/compiler_spec.rb +19 -1
  44. data/spec/unit/parser/functions/lookup_spec.rb +13 -12
  45. data/spec/unit/parser/resource/param_spec.rb +10 -22
  46. data/spec/unit/parser/resource_spec.rb +0 -4
  47. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +30 -5
  48. data/spec/unit/pops/parser/parse_calls_spec.rb +20 -5
  49. data/spec/unit/pops/types/type_calculator_spec.rb +61 -0
  50. data/spec/unit/provider/package/pkg_spec.rb +4 -0
  51. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +47 -14
  52. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +15 -0
  53. data/spec/unit/type/user_spec.rb +5 -0
  54. data/spec/unit/util/autoload_spec.rb +33 -14
  55. data/spec/unit/util/monkey_patches_spec.rb +12 -0
  56. data/tasks/memwalk.rake +195 -0
  57. metadata +3232 -3207
  58. checksums.yaml +0 -7
@@ -1,19 +1,13 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Puppet::Parser::Resource::Param do
5
- it "can be instantiated" do
6
- Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => 'foo')
7
- end
8
-
9
- it "stores the source file" do
10
- param = Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => 'foo', :file => 'foo.pp')
11
- param.file.should == 'foo.pp'
12
- end
4
+ it "has readers for all of the attributes" do
5
+ param = Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => 'foo', :file => 'foo.pp', :line => 42)
13
6
 
14
- it "stores the line number" do
15
- param = Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => 'foo', :line => 42)
16
- param.line.should == 42
7
+ expect(param.name).to eq(:myparam)
8
+ expect(param.value).to eq('foo')
9
+ expect(param.file).to eq('foo.pp')
10
+ expect(param.line).to eq(42)
17
11
  end
18
12
 
19
13
  context "parameter validation" do
@@ -23,21 +17,15 @@ describe Puppet::Parser::Resource::Param do
23
17
  }.to raise_error(Puppet::Error, /name is a required option/)
24
18
  end
25
19
 
26
- it "throws an error when instantiated without a value" do
27
- expect {
28
- Puppet::Parser::Resource::Param.new(:name => 'myparam')
29
- }.to raise_error(Puppet::Error, /value is a required option/)
30
- end
20
+ it "does not require a value" do
21
+ param = Puppet::Parser::Resource::Param.new(:name => 'myparam')
31
22
 
32
- it "throws an error when instantiated with a nil value" do
33
- expect {
34
- Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => nil)
35
- }.to raise_error(Puppet::Error, /value is a required option/)
23
+ expect(param.value).to be_nil
36
24
  end
37
25
 
38
26
  it "includes file/line context in errors" do
39
27
  expect {
40
- Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => nil, :file => 'foo.pp', :line => 42)
28
+ Puppet::Parser::Resource::Param.new(:file => 'foo.pp', :line => 42)
41
29
  }.to raise_error(Puppet::Error, /foo.pp:42/)
42
30
  end
43
31
  end
@@ -561,10 +561,6 @@ describe Puppet::Parser::Resource do
561
561
  @resource["foo"].should == "bar"
562
562
  end
563
563
 
564
- it "should fail when provided a parameter name but no value" do
565
- expect { @resource.set_parameter("myparam") }.to raise_error(ArgumentError)
566
- end
567
-
568
564
  it "should allow parameters to be set to 'false'" do
569
565
  @resource.set_parameter("myparam", false)
570
566
  @resource["myparam"].should be_false
@@ -680,12 +680,12 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
680
680
  "'abc'[x]" => "The value 'x' cannot be converted to Numeric",
681
681
  "'abc'[1.0]" => "A String[] cannot use Float where Integer is expected",
682
682
  "'abc'[1,2,3]" => "String supports [] with one or two arguments. Got 3",
683
- "Resource[0]" => 'First argument to Resource[] must be a resource type or a String. Got Fixnum',
684
- "Resource[a, 0]" => 'Error creating type specialization of a Resource-Type, Cannot use Fixnum where String is expected',
685
- "File[0]" => 'Error creating type specialization of a File-Type, Cannot use Fixnum where String is expected',
683
+ "Resource[0]" => 'First argument to Resource[] must be a resource type or a String. Got Integer',
684
+ "Resource[a, 0]" => 'Error creating type specialization of a Resource-Type, Cannot use Integer where a resource title String is expected',
685
+ "File[0]" => 'Error creating type specialization of a File-Type, Cannot use Integer where a resource title String is expected',
686
686
  "String[a]" => "A Type's size constraint arguments must be a single Integer type, or 1-2 integers (or default). Got a String",
687
- "Pattern[0]" => 'Error creating type specialization of a Pattern-Type, Cannot use Fixnum where String or Regexp or Pattern-Type or Regexp-Type is expected',
688
- "Regexp[0]" => 'Error creating type specialization of a Regexp-Type, Cannot use Fixnum where String or Regexp is expected',
687
+ "Pattern[0]" => 'Error creating type specialization of a Pattern-Type, Cannot use Integer where String or Regexp or Pattern-Type or Regexp-Type is expected',
688
+ "Regexp[0]" => 'Error creating type specialization of a Regexp-Type, Cannot use Integer where String or Regexp is expected',
689
689
  "Regexp[a,b]" => 'A Regexp-Type[] accepts 1 argument. Got 2',
690
690
  "true[0]" => "Operator '[]' is not applicable to a Boolean",
691
691
  "1[0]" => "Operator '[]' is not applicable to an Integer",
@@ -963,6 +963,31 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
963
963
  expect{parser.evaluate_string(scope, "assert_no_undef({undef => 1})")}.to_not raise_error()
964
964
  expect{parser.evaluate_string(scope, "assert_no_undef({1 => undef})")}.to_not raise_error()
965
965
  end
966
+
967
+ context 'using the 3x function api' do
968
+ it 'can call a 3x function' do
969
+ Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0] }
970
+ parser.evaluate_string(scope, "bazinga(42)", __FILE__).should == 42
971
+ end
972
+
973
+ it 'maps :undef to empty string' do
974
+ Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0] }
975
+ parser.evaluate_string(scope, "$a = {} bazinga($a[nope])", __FILE__).should == ''
976
+ parser.evaluate_string(scope, "bazinga(undef)", __FILE__).should == ''
977
+ end
978
+
979
+ it 'does not map :undef to empty string in arrays' do
980
+ Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0][0] }
981
+ parser.evaluate_string(scope, "$a = {} $b = [$a[nope]] bazinga($b)", __FILE__).should == :undef
982
+ parser.evaluate_string(scope, "bazinga([undef])", __FILE__).should == :undef
983
+ end
984
+
985
+ it 'does not map :undef to empty string in hashes' do
986
+ Puppet::Parser::Functions.newfunction("bazinga", :type => :rvalue) { |args| args[0]['a'] }
987
+ parser.evaluate_string(scope, "$a = {} $b = {a => $a[nope]} bazinga($b)", __FILE__).should == :undef
988
+ parser.evaluate_string(scope, "bazinga({a => undef})", __FILE__).should == :undef
989
+ end
990
+ end
966
991
  end
967
992
 
968
993
  context "When evaluator performs string interpolation" do
@@ -59,11 +59,6 @@ describe "egrammar parsing function calls" do
59
59
  dump(parse("$a = foo()")).should == "(= $a (call foo))"
60
60
  end
61
61
 
62
- # # For regular grammar where a bare word can not be a "statement"
63
- # it "$a = foo bar # illegal, must have parentheses" do
64
- # expect { dump(parse("$a = foo bar"))}.to raise_error(Puppet::ParseError)
65
- # end
66
-
67
62
  # For egrammar where a bare word can be a "statement"
68
63
  it "$a = foo bar # illegal, must have parentheses" do
69
64
  dump(parse("$a = foo bar")).should == "(block\n (= $a foo)\n bar\n)"
@@ -101,4 +96,24 @@ describe "egrammar parsing function calls" do
101
96
  ].join("\n")
102
97
  end
103
98
  end
99
+
100
+ context "When parsing an illegal argument list" do
101
+ it "raises an error if argument list is not for a call" do
102
+ expect do
103
+ parse("$a = 10, 3")
104
+ end.to raise_error(/illegal comma/)
105
+ end
106
+
107
+ it "raises an error if argument list is for a potential call not allowed without parentheses" do
108
+ expect do
109
+ parse("foo 10, 3")
110
+ end.to raise_error(/attempt to pass argument list to the function 'foo' which cannot be called without parentheses/)
111
+ end
112
+
113
+ it "does no raise an error for an argument list to an allowed call" do
114
+ expect do
115
+ parse("notice 10, 3")
116
+ end.to_not raise_error()
117
+ end
118
+ end
104
119
  end
@@ -10,6 +10,9 @@ describe 'The type calculator' do
10
10
  t.to = to
11
11
  t
12
12
  end
13
+ def constrained_t(t, from, to)
14
+ Puppet::Pops::Types::TypeFactory.constrain_size(t, from, to)
15
+ end
13
16
 
14
17
  def pattern_t(*patterns)
15
18
  Puppet::Pops::Types::TypeFactory.pattern(*patterns)
@@ -827,6 +830,21 @@ describe 'The type calculator' do
827
830
  calculator.assignable?(pattern, variant_t(string_t('a'), string_t('b'))).should == true
828
831
  end
829
832
 
833
+ it 'pattern representing all patterns should accept any pattern' do
834
+ calculator.assignable?(pattern_t(), pattern_t('a')).should == true
835
+ calculator.assignable?(pattern_t(), pattern_t()).should == true
836
+ end
837
+
838
+ it 'pattern representing all patterns should accept any enum' do
839
+ calculator.assignable?(pattern_t(), enum_t('a')).should == true
840
+ calculator.assignable?(pattern_t(), enum_t()).should == true
841
+ end
842
+
843
+ it 'pattern representing all patterns should accept any string' do
844
+ calculator.assignable?(pattern_t(), string_t('a')).should == true
845
+ calculator.assignable?(pattern_t(), string_t()).should == true
846
+ end
847
+
830
848
  end
831
849
 
832
850
  context 'when dealing with enums' do
@@ -842,12 +860,51 @@ describe 'The type calculator' do
842
860
  calculator.assignable?(enum_t('a', 'b'), enum_t('c')).should == false
843
861
  end
844
862
 
863
+ it 'non parameterized enum accepts any other enum but not the reverse' do
864
+ calculator.assignable?(enum_t(), enum_t('a')).should == true
865
+ calculator.assignable?(enum_t('a'), enum_t()).should == false
866
+ end
867
+
845
868
  it 'enum should accept a variant where all variants are acceptable' do
846
869
  enum = enum_t('a', 'b')
847
870
  calculator.assignable?(enum, variant_t(string_t('a'), string_t('b'))).should == true
848
871
  end
849
872
  end
850
873
 
874
+ context 'when dealing with string and enum combinations' do
875
+ it 'should accept assigning any enum to unrestricted string' do
876
+ calculator.assignable?(string_t(), enum_t('blue')).should == true
877
+ calculator.assignable?(string_t(), enum_t('blue', 'red')).should == true
878
+ end
879
+
880
+ it 'should not accept assigning longer enum value to size restricted string' do
881
+ calculator.assignable?(constrained_t(string_t(),2,2), enum_t('a','blue')).should == false
882
+ end
883
+
884
+ it 'should accept assigning any string to empty enum' do
885
+ calculator.assignable?(enum_t(), string_t()).should == true
886
+ end
887
+
888
+ it 'should accept assigning empty enum to any string' do
889
+ calculator.assignable?(string_t(), enum_t()).should == true
890
+ end
891
+
892
+ it 'should not accept assigning empty enum to size constrained string' do
893
+ calculator.assignable?(constrained_t(string_t(),2,2), enum_t()).should == false
894
+ end
895
+ end
896
+
897
+ context 'when dealing with string/pattern/enum combinations' do
898
+ it 'any string is equal to any enum is equal to any pattern' do
899
+ calculator.assignable?(string_t(), enum_t()).should == true
900
+ calculator.assignable?(string_t(), pattern_t()).should == true
901
+ calculator.assignable?(enum_t(), string_t()).should == true
902
+ calculator.assignable?(enum_t(), pattern_t()).should == true
903
+ calculator.assignable?(pattern_t(), string_t()).should == true
904
+ calculator.assignable?(pattern_t(), enum_t()).should == true
905
+ end
906
+ end
907
+
851
908
  context 'when dealing with tuples' do
852
909
  it 'matches empty tuples' do
853
910
  tuple1 = tuple_t()
@@ -1057,6 +1114,10 @@ describe 'The type calculator' do
1057
1114
  calculator.instance?(Puppet::Pops::Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => 'Symbol'), :undef).should == true
1058
1115
  end
1059
1116
 
1117
+ it "should consider :undef to be instance of an Optional type" do
1118
+ calculator.instance?(Puppet::Pops::Types::POptionalType.new(), :undef).should == true
1119
+ end
1120
+
1060
1121
  it 'should not consider undef to be an instance of any other type than Any, NilType and Data' do
1061
1122
  types_to_test = all_types - [
1062
1123
  Puppet::Pops::Types::PAnyType,
@@ -70,6 +70,10 @@ describe Puppet::Type.type(:package).provider(:pkg) do
70
70
  described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.installed'))
71
71
  provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
72
72
  end
73
+ it "should work correctly for ensure latest on solaris 11 in the presence of a certificate expiration warning" do
74
+ described_class.expects(:pkg).with(:list,'-Hn','dummy').returns File.read(my_fixture('dummy_solaris11.certificate_warning'))
75
+ provider.latest.should == "1.0.6-0.175.0.0.0.2.537"
76
+ end
73
77
  it "should work correctly for ensure latest on solaris 11(known UFOXI)" do
74
78
  Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy'], {:failonfail => false, :combine => true}).returns ''
75
79
  $CHILD_STATUS.stubs(:exitstatus).returns 0
@@ -142,14 +142,14 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
142
142
  'type' => { 'days_interval' => 2 },
143
143
  })
144
144
 
145
- resource.provider.trigger.should == {
145
+ resource.provider.trigger.should == [{
146
146
  'start_date' => '2011-9-12',
147
147
  'start_time' => '13:20',
148
148
  'schedule' => 'daily',
149
149
  'every' => '2',
150
150
  'enabled' => true,
151
151
  'index' => 0,
152
- }
152
+ }]
153
153
  end
154
154
 
155
155
  it 'should handle a single weekly trigger' do
@@ -171,7 +171,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
171
171
  }
172
172
  })
173
173
 
174
- resource.provider.trigger.should == {
174
+ resource.provider.trigger.should == [{
175
175
  'start_date' => '2011-9-12',
176
176
  'start_time' => '13:20',
177
177
  'schedule' => 'weekly',
@@ -179,7 +179,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
179
179
  'on' => ['sun', 'mon', 'wed', 'fri'],
180
180
  'enabled' => true,
181
181
  'index' => 0,
182
- }
182
+ }]
183
183
  end
184
184
 
185
185
  it 'should handle a single monthly date-based trigger' do
@@ -204,7 +204,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
204
204
  }
205
205
  })
206
206
 
207
- resource.provider.trigger.should == {
207
+ resource.provider.trigger.should == [{
208
208
  'start_date' => '2011-9-12',
209
209
  'start_time' => '13:20',
210
210
  'schedule' => 'monthly',
@@ -212,7 +212,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
212
212
  'on' => [1, 3, 5, 15, 'last'],
213
213
  'enabled' => true,
214
214
  'index' => 0,
215
- }
215
+ }]
216
216
  end
217
217
 
218
218
  it 'should handle a single monthly day-of-week-based trigger' do
@@ -240,7 +240,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
240
240
  }
241
241
  })
242
242
 
243
- resource.provider.trigger.should == {
243
+ resource.provider.trigger.should == [{
244
244
  'start_date' => '2011-9-12',
245
245
  'start_time' => '13:20',
246
246
  'schedule' => 'monthly',
@@ -249,7 +249,7 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
249
249
  'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
250
250
  'enabled' => true,
251
251
  'index' => 0,
252
- }
252
+ }]
253
253
  end
254
254
 
255
255
  it 'should handle a single one-time trigger' do
@@ -263,13 +263,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
263
263
  'flags' => 0,
264
264
  })
265
265
 
266
- resource.provider.trigger.should == {
266
+ resource.provider.trigger.should == [{
267
267
  'start_date' => '2011-9-12',
268
268
  'start_time' => '13:20',
269
269
  'schedule' => 'once',
270
270
  'enabled' => true,
271
271
  'index' => 0,
272
- }
272
+ }]
273
273
  end
274
274
  end
275
275
 
@@ -536,18 +536,18 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
536
536
  'index' => 0,
537
537
  }
538
538
 
539
- resource.provider.trigger.should == mock_task_trigger
540
- resource.provider.trigger.should == mock_task_trigger
539
+ resource.provider.trigger.should == [mock_task_trigger]
540
+ resource.provider.trigger.should == [mock_task_trigger]
541
541
 
542
542
  resource.provider.clear_task
543
543
 
544
- resource.provider.trigger.should == {
544
+ resource.provider.trigger.should == [{
545
545
  'start_date' => '2012-11-14',
546
546
  'start_time' => '15:22',
547
547
  'schedule' => 'once',
548
548
  'enabled' => true,
549
549
  'index' => 0,
550
- }
550
+ }]
551
551
  end
552
552
  end
553
553
 
@@ -635,6 +635,30 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
635
635
  describe '#triggers_same?' do
636
636
  let(:provider) { described_class.new(:name => 'foobar', :command => 'C:\Windows\System32\notepad.exe') }
637
637
 
638
+ it "should not mutate triggers" do
639
+ current = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
640
+ current.freeze
641
+
642
+ desired = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30'}
643
+ desired.freeze
644
+
645
+ expect(provider).to be_triggers_same(current, desired)
646
+ end
647
+
648
+ it "ignores 'index' in current trigger" do
649
+ current = {'index' => 0, 'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
650
+ desired = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
651
+
652
+ expect(provider).to be_triggers_same(current, desired)
653
+ end
654
+
655
+ it "ignores 'enabled' in current triggger" do
656
+ current = {'enabled' => true, 'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
657
+ desired = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
658
+
659
+ expect(provider).to be_triggers_same(current, desired)
660
+ end
661
+
638
662
  it "should not consider a disabled 'current' trigger to be the same" do
639
663
  current = {'schedule' => 'once', 'enabled' => false}
640
664
  desired = {'schedule' => 'once'}
@@ -649,6 +673,15 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
649
673
  provider.should_not be_triggers_same(current, desired)
650
674
  end
651
675
 
676
+ describe 'start_date' do
677
+ it "considers triggers to be equal when start_date is not specified in the 'desired' trigger" do
678
+ current = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
679
+ desired = {'schedule' => 'daily', 'start_time' => '15:30', 'every' => 3}
680
+
681
+ provider.should be_triggers_same(current, desired)
682
+ end
683
+ end
684
+
652
685
  describe 'comparing daily triggers' do
653
686
  it "should consider 'desired' triggers not specifying 'every' to have the same value as the 'current' trigger" do
654
687
  current = {'schedule' => 'daily', 'start_date' => '2011-09-12', 'start_time' => '15:30', 'every' => 3}
@@ -136,6 +136,21 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
136
136
  end
137
137
  end
138
138
 
139
+ describe "prefetch_hook" do
140
+ let(:path) { '/path/to/keyfile' }
141
+ let(:input) do
142
+ { :type => 'rsa',
143
+ :key => 'KEYDATA',
144
+ :name => '',
145
+ :record_type => :parsed,
146
+ :target => path,
147
+ }
148
+ end
149
+ it "adds an indexed name to unnamed resources" do
150
+ @provider_class.prefetch_hook([input])[0][:name].should =~ /^#{path}:unnamed-\d+/
151
+ end
152
+ end
153
+
139
154
  end
140
155
 
141
156
  describe provider_class, :unless => Puppet.features.microsoft_windows? do
@@ -501,6 +501,11 @@ describe Puppet::Type.type(:user) do
501
501
  names = resources.collect { |res| res.name }
502
502
  names.should_not include("keyname3")
503
503
  end
504
+ it "should generate names for unnamed keys" do
505
+ names = resources.collect { |res| res.name }
506
+ fixture_path = File.join(my_fixture_dir, 'authorized_keys')
507
+ names.should include("#{fixture_path}:unnamed-1")
508
+ end
504
509
  it "should each have a value for the user property" do
505
510
  resources.map { |res|
506
511
  res[:user]
@@ -5,10 +5,10 @@ require 'puppet/util/autoload'
5
5
 
6
6
  describe Puppet::Util::Autoload do
7
7
  include PuppetSpec::Files
8
+
8
9
  before do
9
10
  @autoload = Puppet::Util::Autoload.new("foo", "tmp")
10
11
 
11
- @autoload.stubs(:eachdir).yields make_absolute("/my/dir")
12
12
  @loaded = {}
13
13
  @autoload.class.stubs(:loaded).returns(@loaded)
14
14
  end
@@ -17,25 +17,44 @@ describe Puppet::Util::Autoload do
17
17
  before :each do
18
18
  ## modulepath/libdir can't be used until after app settings are initialized, so we need to simulate that:
19
19
  Puppet.settings.expects(:app_defaults_initialized?).returns(true).at_least_once
20
-
21
- @dira = File.expand_path('/a')
22
- @dirb = File.expand_path('/b')
23
- @dirc = File.expand_path('/c')
24
20
  end
25
21
 
26
22
  it "should collect all of the lib directories that exist in the current environment's module path" do
27
- environment = Puppet::Node::Environment.create(:foo, [@dira, @dirb, @dirc])
28
- Dir.expects(:entries).with(@dira).returns %w{. .. one two}
29
- Dir.expects(:entries).with(@dirb).returns %w{. .. one two}
23
+ dira = dir_containing('dir_a', {
24
+ "one" => {},
25
+ "two" => { "lib" => {} }
26
+ })
30
27
 
31
- Puppet::FileSystem.expects(:directory?).with(@dira).returns true
32
- Puppet::FileSystem.expects(:directory?).with(@dirb).returns true
33
- Puppet::FileSystem.expects(:directory?).with(@dirc).returns false
28
+ dirb = dir_containing('dir_a', {
29
+ "one" => {},
30
+ "two" => { "lib" => {} }
31
+ })
34
32
 
35
- FileTest.expects(:directory?).with(regexp_matches(%r{two/lib})).times(2).returns true
36
- FileTest.expects(:directory?).with(regexp_matches(%r{one/lib})).times(2).returns false
33
+ environment = Puppet::Node::Environment.create(:foo, [dira, dirb])
34
+
35
+ @autoload.class.module_directories(environment).should == ["#{dira}/two/lib", "#{dirb}/two/lib"]
36
+ end
37
+
38
+ it "ignores missing module directories" do
39
+ environment = Puppet::Node::Environment.create(:foo, [File.expand_path('does/not/exist')])
40
+
41
+ @autoload.class.module_directories(environment).should be_empty
42
+ end
37
43
 
38
- @autoload.class.module_directories(environment).should == ["#{@dira}/two/lib", "#{@dirb}/two/lib"]
44
+ it "ignores the configured environment when it doesn't exist" do
45
+ Puppet[:environment] = 'nonexistent'
46
+
47
+ Puppet.override({ :environments => Puppet::Environments::Static.new() }) do
48
+ @autoload.class.module_directories(nil).should be_empty
49
+ end
50
+ end
51
+
52
+ it "uses the configured environment when no environment is given" do
53
+ Puppet[:environment] = 'nonexistent'
54
+
55
+ Puppet.override({ :environments => Puppet::Environments::Static.new() }) do
56
+ @autoload.class.module_directories(nil).should be_empty
57
+ end
39
58
  end
40
59
 
41
60
  it "should include the module directories, the Puppet libdir, and all of the Ruby load directories" do