puppet 2.7.18 → 2.7.19

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 (137) hide show
  1. data/CHANGELOG +82 -0
  2. data/CONTRIBUTING.md +114 -171
  3. data/README.md +8 -0
  4. data/README_DEVELOPER.md +38 -3
  5. data/Rakefile +19 -3
  6. data/conf/osx/createpackage.sh +3 -1
  7. data/conf/redhat/logrotate +1 -1
  8. data/conf/redhat/puppet.spec +35 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/application/agent.rb +2 -0
  11. data/lib/puppet/application/master.rb +2 -0
  12. data/lib/puppet/configurer.rb +2 -3
  13. data/lib/puppet/defaults.rb +6 -5
  14. data/lib/puppet/face/module/install.rb +2 -1
  15. data/lib/puppet/file_bucket/dipper.rb +1 -1
  16. data/lib/puppet/indirector/file_content.rb +2 -2
  17. data/lib/puppet/indirector/file_metadata.rb +2 -2
  18. data/lib/puppet/indirector/indirection.rb +3 -4
  19. data/lib/puppet/indirector/rest.rb +12 -6
  20. data/lib/puppet/interface/action_manager.rb +1 -2
  21. data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
  22. data/lib/puppet/network/handler/fileserver.rb +2 -2
  23. data/lib/puppet/parser/ast/resource.rb +9 -2
  24. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
  25. data/lib/puppet/parser/functions/md5.rb +2 -2
  26. data/lib/puppet/parser/functions/sha1.rb +2 -2
  27. data/lib/puppet/parser/functions/template.rb +0 -2
  28. data/lib/puppet/parser/type_loader.rb +1 -2
  29. data/lib/puppet/provider/augeas/augeas.rb +19 -1
  30. data/lib/puppet/provider/confine.rb +1 -1
  31. data/lib/puppet/provider/package/msi.rb +97 -51
  32. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
  33. data/lib/puppet/provider/service/gentoo.rb +0 -2
  34. data/lib/puppet/provider/service/openrc.rb +69 -0
  35. data/lib/puppet/provider/service/windows.rb +6 -4
  36. data/lib/puppet/provider/user/aix.rb +8 -4
  37. data/lib/puppet/provider/user/useradd.rb +6 -0
  38. data/lib/puppet/rails/benchmark.rb +2 -2
  39. data/lib/puppet/reports/store.rb +9 -9
  40. data/lib/puppet/resource/catalog.rb +2 -1
  41. data/lib/puppet/resource/type_collection.rb +2 -1
  42. data/lib/puppet/ssl/base.rb +1 -2
  43. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
  44. data/lib/puppet/test/test_helper.rb +2 -1
  45. data/lib/puppet/type.rb +1 -1
  46. data/lib/puppet/type/augeas.rb +1 -1
  47. data/lib/puppet/type/file.rb +4 -2
  48. data/lib/puppet/type/scheduled_task.rb +8 -10
  49. data/lib/puppet/type/tidy.rb +1 -1
  50. data/lib/puppet/util.rb +63 -25
  51. data/lib/puppet/util/autoload.rb +6 -4
  52. data/lib/puppet/util/checksums.rb +3 -8
  53. data/lib/puppet/util/diff.rb +2 -1
  54. data/lib/puppet/util/filetype.rb +1 -3
  55. data/lib/puppet/util/run_mode.rb +2 -1
  56. data/lib/puppet/util/suidmanager.rb +1 -1
  57. data/lib/puppet/util/windows.rb +1 -0
  58. data/lib/puppet/util/windows/file.rb +27 -0
  59. data/lib/puppet/util/windows/user.rb +1 -2
  60. data/man/man8/puppet-agent.8 +4 -0
  61. data/man/man8/puppet-master.8 +4 -0
  62. data/man/man8/puppetmasterd.8 +4 -0
  63. data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
  64. data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
  65. data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
  66. data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
  67. data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
  68. data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
  69. data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
  70. data/spec/integration/defaults_spec.rb +3 -3
  71. data/spec/integration/network/server/mongrel_spec.rb +8 -6
  72. data/spec/integration/parser/parser_spec.rb +1 -1
  73. data/spec/integration/type/file_spec.rb +49 -12
  74. data/spec/lib/puppet_spec/database.rb +5 -3
  75. data/spec/lib/puppet_spec/files.rb +2 -1
  76. data/spec/monkey_patches/alias_should_to_must.rb +15 -2
  77. data/spec/shared_behaviours/file_serving_model.rb +9 -6
  78. data/spec/shared_behaviours/path_parameters.rb +5 -5
  79. data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
  80. data/spec/unit/application/facts_spec.rb +1 -1
  81. data/spec/unit/application_spec.rb +10 -8
  82. data/spec/unit/configurer_spec.rb +11 -2
  83. data/spec/unit/face/ca_spec.rb +15 -15
  84. data/spec/unit/face/help_spec.rb +5 -5
  85. data/spec/unit/face/module/install_spec.rb +13 -2
  86. data/spec/unit/face/node_spec.rb +7 -6
  87. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
  88. data/spec/unit/indirector/envelope_spec.rb +0 -13
  89. data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
  90. data/spec/unit/indirector/queue_spec.rb +3 -3
  91. data/spec/unit/indirector/rest_spec.rb +31 -20
  92. data/spec/unit/indirector_spec.rb +5 -5
  93. data/spec/unit/interface/action_builder_spec.rb +3 -2
  94. data/spec/unit/interface/action_manager_spec.rb +1 -1
  95. data/spec/unit/interface/action_spec.rb +4 -3
  96. data/spec/unit/interface/face_collection_spec.rb +1 -1
  97. data/spec/unit/interface/option_spec.rb +13 -9
  98. data/spec/unit/interface_spec.rb +5 -5
  99. data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
  100. data/spec/unit/network/handler/fileserver_spec.rb +3 -3
  101. data/spec/unit/other/transbucket_spec.rb +6 -9
  102. data/spec/unit/parser/ast/resource_spec.rb +27 -0
  103. data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
  104. data/spec/unit/parser/lexer_spec.rb +5 -5
  105. data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
  106. data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
  107. data/spec/unit/provider/package/freebsd_spec.rb +2 -2
  108. data/spec/unit/provider/package/msi_spec.rb +181 -114
  109. data/spec/unit/provider/package/openbsd_spec.rb +1 -0
  110. data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
  111. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
  112. data/spec/unit/provider/service/openrc_spec.rb +209 -0
  113. data/spec/unit/provider/service/windows_spec.rb +57 -59
  114. data/spec/unit/provider/user/useradd_spec.rb +7 -0
  115. data/spec/unit/reports/store_spec.rb +13 -13
  116. data/spec/unit/resource/catalog_spec.rb +29 -24
  117. data/spec/unit/resource_spec.rb +13 -13
  118. data/spec/unit/simple_graph_spec.rb +12 -12
  119. data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
  120. data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
  121. data/spec/unit/transaction_spec.rb +3 -3
  122. data/spec/unit/type/cron_spec.rb +171 -171
  123. data/spec/unit/type/exec_spec.rb +29 -27
  124. data/spec/unit/type/file_spec.rb +22 -13
  125. data/spec/unit/type/interface_spec.rb +1 -1
  126. data/spec/unit/type/scheduled_task_spec.rb +15 -14
  127. data/spec/unit/type/tidy_spec.rb +2 -2
  128. data/spec/unit/type/user_spec.rb +15 -15
  129. data/spec/unit/type/vlan_spec.rb +1 -1
  130. data/spec/unit/type_spec.rb +22 -25
  131. data/spec/unit/util/autoload_spec.rb +13 -7
  132. data/spec/unit/util/backups_spec.rb +36 -67
  133. data/spec/unit/util/storage_spec.rb +2 -9
  134. data/spec/unit/util/suidmanager_spec.rb +1 -1
  135. data/spec/unit/util_spec.rb +20 -28
  136. data/test/ral/manager/attributes.rb +1 -1
  137. metadata +1553 -1542
@@ -1,14 +1,13 @@
1
1
  require 'puppet/util/windows'
2
2
 
3
3
  require 'win32/security'
4
+ require 'facter'
4
5
 
5
6
  module Puppet::Util::Windows::User
6
7
  include Windows::Security
7
8
  extend Windows::Security
8
9
 
9
10
  def admin?
10
- require 'facter'
11
-
12
11
  majversion = Facter.value(:kernelmajversion)
13
12
  return false unless majversion
14
13
 
@@ -147,6 +147,10 @@ Shut down the puppet agent daemon\.
147
147
  SIGUSR1
148
148
  Immediately retrieve and apply configurations from the puppet master\.
149
149
  .
150
+ .TP
151
+ SIGUSR2
152
+ Close file descriptors for log files and reopen them\. Used with logrotate\.
153
+ .
150
154
  .SH "AUTHOR"
151
155
  Luke Kanies
152
156
  .
@@ -67,6 +67,10 @@ Restart the puppet master server\.
67
67
  SIGINT and SIGTERM
68
68
  Shut down the puppet master server\.
69
69
  .
70
+ .TP
71
+ SIGUSR2
72
+ Close file descriptors for log files and reopen them\. Used with logrotate\.
73
+ .
70
74
  .SH "AUTHOR"
71
75
  Luke Kanies
72
76
  .
@@ -67,6 +67,10 @@ Restart the puppet master server\.
67
67
  SIGINT and SIGTERM
68
68
  Shut down the puppet master server\.
69
69
  .
70
+ .TP
71
+ SIGUSR2
72
+ Close file descriptors for log files and reopen them\. Used with logrotate\.
73
+ .
70
74
  .SH "AUTHOR"
71
75
  Luke Kanies
72
76
  .
@@ -0,0 +1,13 @@
1
+ (*
2
+ Simple lens, written to be distributed with Puppet unit tests.
3
+
4
+ Author: Dominic Cleal <dcleal@redhat.com>
5
+
6
+ About: License:
7
+ This file is licensed under the Apache 2.0 licence, like the rest of Puppet.
8
+ *)
9
+
10
+ module Test = autoload xfm
11
+ let lns = [ seq "line" . store /[^\n]+/ . del "\n" "\n" ]*
12
+ let filter = incl "/etc/test"
13
+ let xfm = transform lns filter
@@ -0,0 +1,10 @@
1
+ /dev/vg00/lv00 / ext3 defaults 1 1
2
+ LABEL=/boot /boot ext3 defaults 1 2
3
+ devpts /dev/pts devpts gid=5,mode=620 0 0
4
+ tmpfs /dev/shm tmpfs defaults 0 0
5
+ /dev/vg00/home /home ext3 defaults 1 2
6
+ proc /proc proc defaults 0 0
7
+ sysfs /sys sysfs defaults 0 0
8
+ /dev/vg00/local /local ext3 defaults 1 2
9
+ /dev/vg00/images /var/lib/xen/images ext3 defaults 1 2
10
+ /dev/vg00/swap swap swap defaults 0 0
@@ -0,0 +1,6 @@
1
+ # Do not remove the following line, or various programs
2
+ # that require network functionality will fail.
3
+ 127.0.0.1 localhost.localdomain localhost galia.watzmann.net galia
4
+ #172.31.122.254 granny.watzmann.net granny puppet
5
+ #172.31.122.1 galia.watzmann.net galia
6
+ 172.31.122.14 orange.watzmann.net orange
@@ -0,0 +1,3 @@
1
+ foo
2
+ bar
3
+ baz
@@ -0,0 +1,13 @@
1
+ (*
2
+ Simple lens, written to be distributed with Puppet unit tests.
3
+
4
+ Author: Dominic Cleal <dcleal@redhat.com>
5
+
6
+ About: License:
7
+ This file is licensed under the Apache 2.0 licence, like the rest of Puppet.
8
+ *)
9
+
10
+ module Test = autoload xfm
11
+ let lns = [ seq "line" . store /[^\n]+/ . del "\n" "\n" ]*
12
+ let filter = incl "/etc/test"
13
+ let xfm = transform lns filter
@@ -0,0 +1,8 @@
1
+ alsasound
2
+ consolefont
3
+ lvm-monitoring
4
+ pydoc-2.7
5
+ pydoc-3.2
6
+ wpa_supplicant
7
+ xdm
8
+ xdm-setup
@@ -0,0 +1,43 @@
1
+ Runlevel: boot
2
+ hwclock [ started ]
3
+ modules [ started ]
4
+ dmcrypt [ started ]
5
+ lvm [ started ]
6
+ fsck [ started ]
7
+ root [ started ]
8
+ mtab [ started ]
9
+ swap [ started ]
10
+ localmount [ started ]
11
+ sysctl [ started ]
12
+ bootmisc [ started ]
13
+ hostname [ started ]
14
+ termencoding [ started ]
15
+ keymaps [ started ]
16
+ net.lo [ started ]
17
+ procfs [ started ]
18
+ rsyslog [ started ]
19
+ swapfiles [ started ]
20
+ urandom [ started ]
21
+ Runlevel: default
22
+ netmount [ started ]
23
+ foo_with_very_very_long_servicename_no_still_not_the_end_wait_for_it_almost_there_almost_there_now_finally_the_end [ started ]
24
+ xdm [ started ]
25
+ alsasound [ started ]
26
+ udev-postmount [ started ]
27
+ local [ started ]
28
+ Runlevel: shutdown
29
+ killprocs [ stopped ]
30
+ savecache [ stopped ]
31
+ mount-ro [ stopped ]
32
+ Runlevel: sysinit
33
+ dmesg [ started ]
34
+ udev [ started ]
35
+ devfs [ started ]
36
+ Dynamic Runlevel: hotplugged
37
+ net.eth0 [ started ]
38
+ pcscd [ started ]
39
+ Dynamic Runlevel: needed
40
+ sysfs [ started ]
41
+ udev-mount [ started ]
42
+ Dynamic Runlevel: manual
43
+ sshd [ started ]
@@ -18,7 +18,7 @@ describe "Puppet defaults" do
18
18
 
19
19
  describe "when setting the :certname" do
20
20
  it "should fail if the certname is not downcased" do
21
- lambda { Puppet.settings[:certname] = "Host.Domain.Com" }.should raise_error(ArgumentError)
21
+ expect { Puppet.settings[:certname] = "Host.Domain.Com" }.to raise_error(ArgumentError)
22
22
  end
23
23
  end
24
24
 
@@ -46,7 +46,7 @@ describe "Puppet defaults" do
46
46
 
47
47
  describe "when :certdnsnames is set" do
48
48
  it "should not fail" do
49
- expect { Puppet[:certdnsnames] = 'fred:wilma' }.should_not raise_error
49
+ expect { Puppet[:certdnsnames] = 'fred:wilma' }.to_not raise_error
50
50
  end
51
51
 
52
52
  it "should warn the value is ignored" do
@@ -300,7 +300,7 @@ describe "Puppet defaults" do
300
300
  end
301
301
 
302
302
  it "should raise an error if set to true" do
303
- lambda { Puppet.settings[:daemonize] = true }.should raise_error(/Cannot daemonize on Windows/)
303
+ expect { Puppet.settings[:daemonize] = true }.to raise_error(/Cannot daemonize on Windows/)
304
304
  end
305
305
  end
306
306
  end
@@ -25,15 +25,16 @@ describe Puppet::Network::Server, :'fails_on_ruby_1.9.2' => true do
25
25
 
26
26
  describe "before listening" do
27
27
  it "should not be reachable at the specified address and port" do
28
- lambda { Net::HTTP.get('127.0.0.1', '/', port) }.
29
- should raise_error(Errno::ECONNREFUSED)
28
+ expect {
29
+ Net::HTTP.get('127.0.0.1', '/', port)
30
+ }.to raise_error(Errno::ECONNREFUSED)
30
31
  end
31
32
  end
32
33
 
33
34
  describe "when listening" do
34
35
  it "should be reachable on the specified address and port" do
35
36
  @server.listen
36
- expect { Net::HTTP.get('127.0.0.1', '/', port) }.should_not raise_error
37
+ expect { Net::HTTP.get('127.0.0.1', '/', port) }.to_not raise_error
37
38
  end
38
39
 
39
40
  it "should default to '127.0.0.1' as its bind address" do
@@ -54,7 +55,7 @@ describe Puppet::Network::Server, :'fails_on_ruby_1.9.2' => true do
54
55
  it "should not allow multiple servers to listen on the same address and port" do
55
56
  @server.listen
56
57
  @server2 = Puppet::Network::Server.new(@params)
57
- lambda { @server2.listen }.should raise_error
58
+ expect { @server2.listen }.to raise_error
58
59
  end
59
60
  end
60
61
 
@@ -62,8 +63,9 @@ describe Puppet::Network::Server, :'fails_on_ruby_1.9.2' => true do
62
63
  it "should not be reachable on the port and address assigned" do
63
64
  @server.listen
64
65
  @server.unlisten
65
- expect { Net::HTTP.get('127.0.0.1', '/', port) }.
66
- should raise_error Errno::ECONNREFUSED
66
+ expect {
67
+ Net::HTTP.get('127.0.0.1', '/', port)
68
+ }.to raise_error Errno::ECONNREFUSED
67
69
  end
68
70
  end
69
71
  end
@@ -119,7 +119,7 @@ describe Puppet::Parser::Parser do
119
119
  end
120
120
 
121
121
  it "should fail if asked to parse '$foo::::bar'" do
122
- expect { @parser.parse("$foo::::bar") }.should raise_error(Puppet::ParseError, /Syntax error at ':'/)
122
+ expect { @parser.parse("$foo::::bar") }.to raise_error(Puppet::ParseError, /Syntax error at ':'/)
123
123
  end
124
124
 
125
125
  describe "function calls" do
@@ -14,7 +14,12 @@ describe Puppet::Type.type(:file) do
14
14
  include PuppetSpec::Files
15
15
 
16
16
  let(:catalog) { Puppet::Resource::Catalog.new }
17
- let(:path) { tmpfile('file_testing') }
17
+ let(:path) do
18
+ # we create a directory first so backups of :path that are stored in
19
+ # the same directory will also be removed after the tests
20
+ parent = tmpdir('file_spec')
21
+ File.join(parent, 'file_testing')
22
+ end
18
23
 
19
24
  if Puppet.features.posix?
20
25
  def set_mode(mode, file)
@@ -65,11 +70,37 @@ describe Puppet::Type.type(:file) do
65
70
 
66
71
  file.parameter(:mode).expects(:retrieve).never
67
72
 
68
- report = catalog.apply.report
69
- report.resource_statuses["File[#{path}]"].should_not be_failed
73
+ status = catalog.apply.report.resource_statuses["File[#{path}]"]
74
+ status.should_not be_failed
75
+ status.should_not be_changed
70
76
  File.should_not be_exist(path)
71
77
  end
72
78
 
79
+ describe "when ensure is absent" do
80
+ it "should remove the file if present" do
81
+ FileUtils.touch(path)
82
+ catalog.add_resource(described_class.new(:path => path, :ensure => :absent, :backup => :false))
83
+ report = catalog.apply.report
84
+ report.resource_statuses["File[#{path}]"].should_not be_failed
85
+ File.should_not be_exist(path)
86
+ end
87
+
88
+ it "should do nothing if file is not present" do
89
+ catalog.add_resource(described_class.new(:path => path, :ensure => :absent, :backup => :false))
90
+ report = catalog.apply.report
91
+ report.resource_statuses["File[#{path}]"].should_not be_failed
92
+ File.should_not be_exist(path)
93
+ end
94
+
95
+ # issue #14599
96
+ it "should not fail if parts of path aren't directories" do
97
+ FileUtils.touch(path)
98
+ catalog.add_resource(described_class.new(:path => File.join(path,'no_such_file'), :ensure => :absent, :backup => :false))
99
+ report = catalog.apply.report
100
+ report.resource_statuses["File[#{File.join(path,'no_such_file')}]"].should_not be_failed
101
+ end
102
+ end
103
+
73
104
  describe "when setting permissions" do
74
105
  it "should set the owner" do
75
106
  FileUtils.touch(path)
@@ -182,14 +213,11 @@ describe Puppet::Type.type(:file) do
182
213
  describe "when managing links" do
183
214
  let(:target) { tmpfile('target') }
184
215
 
185
- before :each do
216
+ it "should not set the executable bit on the link nor the target" do
186
217
  FileUtils.touch(target)
187
218
  File.chmod(0444, target)
188
-
189
219
  File.symlink(target, link)
190
- end
191
220
 
192
- it "should not set the executable bit on the link nor the target" do
193
221
  catalog.add_resource described_class.new(:path => link, :ensure => :link, :mode => 0666, :target => target, :links => :manage)
194
222
  catalog.apply
195
223
 
@@ -198,13 +226,23 @@ describe Puppet::Type.type(:file) do
198
226
  end
199
227
 
200
228
  it "should ignore dangling symlinks (#6856)" do
201
- File.delete(target)
229
+ File.symlink(target, link)
202
230
 
203
231
  catalog.add_resource described_class.new(:path => link, :ensure => :link, :mode => 0666, :target => target, :links => :manage)
204
232
  catalog.apply
205
233
 
206
234
  File.should_not be_exist(link)
207
235
  end
236
+
237
+ it "should create a link to the target if ensure is omitted" do
238
+ FileUtils.touch(target)
239
+ catalog.add_resource described_class.new(:path => link, :target => target)
240
+ catalog.apply
241
+
242
+ File.should be_exist link
243
+ File.lstat(link).ftype.should == 'link'
244
+ File.readlink(link).should == target
245
+ end
208
246
  end
209
247
 
210
248
  describe "when following links" do
@@ -381,8 +419,7 @@ describe Puppet::Type.type(:file) do
381
419
  end
382
420
 
383
421
  it "should fail if no backup can be performed" do
384
- dir = tmpfile("backups")
385
- Dir.mkdir(dir)
422
+ dir = tmpdir("backups")
386
423
 
387
424
  file = described_class.new :path => File.join(dir, "testfile"), :backup => ".bak", :content => "foo"
388
425
  catalog.add_resource file
@@ -839,8 +876,8 @@ describe Puppet::Type.type(:file) do
839
876
 
840
877
  it "should add each generated resource to the catalog" do
841
878
  catalog.apply do |trans|
842
- catalog.resource(:file, File.join(path, "one")).should be_a(described_class)
843
- catalog.resource(:file, File.join(path, "two")).should be_a(described_class)
879
+ catalog.resource(:file, File.join(path, "one")).must be_a(described_class)
880
+ catalog.resource(:file, File.join(path, "two")).must be_a(described_class)
844
881
  end
845
882
  end
846
883
 
@@ -22,9 +22,11 @@ end
22
22
  # ready to roll with a serious database and all. Cleanup is handled
23
23
  # automatically for you. Nothing to do there.
24
24
  def setup_scratch_database
25
- dir = PuppetSpec::Files.tmpdir('puppet-sqlite')
26
- Puppet[:dbadapter] = 'sqlite3'
27
- Puppet[:dblocation] = (dir + 'storeconfigs.sqlite').to_s
25
+ Puppet::Rails.stubs(:database_arguments).returns(
26
+ :adapter => 'sqlite3',
27
+ :log_level => Puppet[:rails_loglevel],
28
+ :database => ':memory:'
29
+ )
28
30
  Puppet[:railslog] = '/dev/null'
29
31
  Puppet::Rails.init
30
32
  end
@@ -29,7 +29,8 @@ module PuppetSpec::Files
29
29
  end
30
30
  end
31
31
 
32
- def make_absolute(path)
32
+ def make_absolute(path) PuppetSpec::Files.make_absolute(path) end
33
+ def self.make_absolute(path)
33
34
  path = File.expand_path(path)
34
35
  path[0] = 'c' if Puppet.features.microsoft_windows?
35
36
  path
@@ -1,8 +1,21 @@
1
1
  require 'rspec'
2
2
 
3
+ # This is necessary because the RAL has a 'should' method.
3
4
  class Object
4
- # This is necessary because the RAL has a 'should'
5
- # method.
6
5
  alias :must :should
7
6
  alias :must_not :should_not
8
7
  end
8
+
9
+ # ...and this is because we want to make sure we don't ignore that change
10
+ # above. Gotta love overwriting functions, but the performance cost at
11
+ # runtime is pretty terrible if we don't.
12
+ require 'puppet/type'
13
+ class Puppet::Type
14
+ alias :should_native :should
15
+ def should(value)
16
+ unless value.is_a? String or value.is_a? Symbol
17
+ raise "you need to call .must rather than .should on Puppet::Type instances"
18
+ end
19
+ should_native(value)
20
+ end
21
+ end
@@ -4,6 +4,9 @@ shared_examples_for "a file_serving model" do
4
4
  include PuppetSpec::Files
5
5
 
6
6
  describe "#indirection" do
7
+ localpath = PuppetSpec::Files.make_absolute("/etc/sudoers")
8
+ localurl = "file://" + localpath
9
+
7
10
  before :each do
8
11
  # Never connect to the network, no matter what
9
12
  described_class.indirection.terminus(:rest).class.any_instance.stubs(:find)
@@ -15,8 +18,8 @@ shared_examples_for "a file_serving model" do
15
18
  end
16
19
 
17
20
  {
18
- "/etc/sudoers" => :file_server,
19
- "file:///etc/sudoers" => :file_server,
21
+ localpath => :file_server,
22
+ localurl => :file_server,
20
23
  "puppet:///modules/foo/bar" => :file_server,
21
24
  "puppet://server/modules/foo/bar" => :file_server,
22
25
  }.each do |key, terminus|
@@ -36,8 +39,8 @@ shared_examples_for "a file_serving model" do
36
39
  end
37
40
 
38
41
  {
39
- "/etc/sudoers" => :file,
40
- "file:///etc/sudoers" => :file,
42
+ localpath => :file,
43
+ localurl => :file,
41
44
  "puppet:///modules/foo/bar" => :file_server,
42
45
  "puppet://server/modules/foo/bar" => :rest,
43
46
  }.each do |key, terminus|
@@ -57,8 +60,8 @@ shared_examples_for "a file_serving model" do
57
60
  end
58
61
 
59
62
  {
60
- "/etc/sudoers" => :file,
61
- "file:///etc/sudoers" => :file,
63
+ localpath => :file,
64
+ localurl => :file,
62
65
  "puppet:///modules/foo/bar" => :rest,
63
66
  "puppet://server/modules/foo/bar" => :rest,
64
67
  }.each do |key, terminus|