puppet 2.6.4 → 2.6.5

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 (221) hide show
  1. data/CHANGELOG +147 -0
  2. data/LICENSE +2 -2
  3. data/Rakefile +3 -4
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/application.rb +22 -5
  6. data/lib/puppet/application/apply.rb +2 -18
  7. data/lib/puppet/application/doc.rb +1 -4
  8. data/lib/puppet/application/inspect.rb +178 -0
  9. data/lib/puppet/configurer.rb +9 -11
  10. data/lib/puppet/configurer/plugin_handler.rb +0 -2
  11. data/lib/puppet/defaults.rb +12 -3
  12. data/lib/puppet/external/pson/pure/generator.rb +1 -22
  13. data/lib/puppet/file_bucket/dipper.rb +9 -3
  14. data/lib/puppet/file_bucket/file.rb +14 -94
  15. data/lib/puppet/indirector.rb +4 -0
  16. data/lib/puppet/indirector/catalog/active_record.rb +1 -1
  17. data/lib/puppet/indirector/file_bucket_file/file.rb +64 -75
  18. data/lib/puppet/indirector/indirection.rb +18 -8
  19. data/lib/puppet/indirector/resource/ral.rb +7 -2
  20. data/lib/puppet/indirector/rest.rb +19 -2
  21. data/lib/puppet/network/http/api/v1.rb +3 -0
  22. data/lib/puppet/network/http/handler.rb +16 -1
  23. data/lib/puppet/network/http/rack/rest.rb +1 -3
  24. data/lib/puppet/network/rest_authconfig.rb +4 -12
  25. data/lib/puppet/network/rights.rb +28 -14
  26. data/lib/puppet/parser/ast.rb +4 -0
  27. data/lib/puppet/parser/compiler.rb +18 -3
  28. data/lib/puppet/parser/functions/defined.rb +28 -6
  29. data/lib/puppet/parser/functions/fqdn_rand.rb +6 -3
  30. data/lib/puppet/parser/templatewrapper.rb +1 -0
  31. data/lib/puppet/property.rb +16 -1
  32. data/lib/puppet/property/keyvalue.rb +0 -2
  33. data/lib/puppet/property/list.rb +0 -2
  34. data/lib/puppet/provider/file/posix.rb +1 -3
  35. data/lib/puppet/provider/file/win32.rb +1 -3
  36. data/lib/puppet/provider/maillist/mailman.rb +3 -5
  37. data/lib/puppet/provider/mount.rb +2 -0
  38. data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
  39. data/lib/puppet/provider/package/freebsd.rb +2 -2
  40. data/lib/puppet/provider/zone/solaris.rb +1 -1
  41. data/lib/puppet/reference/configuration.rb +2 -2
  42. data/lib/puppet/reference/function.rb +4 -0
  43. data/lib/puppet/relationship.rb +4 -0
  44. data/lib/puppet/reports/store.rb +1 -19
  45. data/lib/puppet/resource.rb +11 -2
  46. data/lib/puppet/resource/status.rb +24 -3
  47. data/lib/puppet/resource/type.rb +24 -16
  48. data/lib/puppet/resource/type_collection.rb +4 -1
  49. data/lib/puppet/simple_graph.rb +4 -0
  50. data/lib/puppet/transaction.rb +1 -28
  51. data/lib/puppet/transaction/event.rb +9 -4
  52. data/lib/puppet/transaction/report.rb +42 -22
  53. data/lib/puppet/transaction/resource_harness.rb +99 -71
  54. data/lib/puppet/type.rb +22 -9
  55. data/lib/puppet/type/cron.rb +1 -5
  56. data/lib/puppet/type/exec.rb +4 -34
  57. data/lib/puppet/type/file.rb +19 -26
  58. data/lib/puppet/type/file/checksum.rb +1 -1
  59. data/lib/puppet/type/file/content.rb +2 -1
  60. data/lib/puppet/type/file/ctime.rb +18 -0
  61. data/lib/puppet/type/file/ensure.rb +1 -1
  62. data/lib/puppet/type/file/mode.rb +10 -44
  63. data/lib/puppet/type/file/mtime.rb +17 -0
  64. data/lib/puppet/type/file/owner.rb +1 -1
  65. data/lib/puppet/type/file/source.rb +0 -1
  66. data/lib/puppet/type/file/target.rb +1 -1
  67. data/lib/puppet/type/file/type.rb +5 -12
  68. data/lib/puppet/type/host.rb +1 -1
  69. data/lib/puppet/type/mount.rb +2 -2
  70. data/lib/puppet/type/package.rb +0 -2
  71. data/lib/puppet/type/service.rb +11 -5
  72. data/lib/puppet/type/user.rb +7 -9
  73. data/lib/puppet/type/yumrepo.rb +2 -2
  74. data/lib/puppet/type/zpool.rb +0 -4
  75. data/lib/puppet/util/checksums.rb +24 -1
  76. data/lib/puppet/util/command_line.rb +6 -2
  77. data/lib/puppet/util/command_line/puppet +5 -1
  78. data/lib/puppet/util/command_line/puppetca +2 -2
  79. data/lib/puppet/util/command_line/puppetd +11 -9
  80. data/lib/puppet/util/command_line/puppetdoc +2 -2
  81. data/lib/puppet/util/command_line/puppetmasterd +5 -0
  82. data/lib/puppet/util/log.rb +15 -8
  83. data/lib/puppet/util/log/destinations.rb +2 -0
  84. data/lib/puppet/util/log_paths.rb +1 -1
  85. data/lib/puppet/util/logging.rb +1 -1
  86. data/lib/puppet/util/metric.rb +1 -0
  87. data/lib/puppet/util/reference.rb +1 -10
  88. data/lib/puppet/util/settings.rb +1 -1
  89. data/lib/puppet/util/zaml.rb +30 -31
  90. data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +7 -0
  91. data/spec/integration/application/apply_spec.rb +1 -2
  92. data/spec/integration/defaults_spec.rb +1 -0
  93. data/spec/integration/indirector/catalog/queue_spec.rb +1 -4
  94. data/spec/integration/indirector/report/rest_spec.rb +13 -17
  95. data/spec/integration/network/formats_spec.rb +2 -5
  96. data/spec/integration/network/server/mongrel_spec.rb +1 -2
  97. data/spec/integration/provider/mailalias/aliases_spec.rb +0 -1
  98. data/spec/integration/provider/package_spec.rb +1 -3
  99. data/spec/integration/provider/service/init_spec.rb +3 -9
  100. data/spec/integration/reference/providers_spec.rb +2 -2
  101. data/spec/integration/resource/catalog_spec.rb +1 -2
  102. data/spec/integration/transaction/report_spec.rb +1 -1
  103. data/spec/monkey_patches/alias_should_to_must.rb +2 -0
  104. data/spec/shared_behaviours/file_server_terminus.rb +1 -1
  105. data/spec/shared_behaviours/file_serving.rb +1 -1
  106. data/spec/shared_behaviours/memory_terminus.rb +1 -1
  107. data/spec/spec_helper.rb +8 -6
  108. data/spec/unit/application/agent_spec.rb +1 -0
  109. data/spec/unit/application/apply_spec.rb +7 -7
  110. data/spec/unit/application/doc_spec.rb +2 -2
  111. data/spec/unit/application/filebucket_spec.rb +1 -0
  112. data/spec/unit/application/inspect_spec.rb +278 -0
  113. data/spec/unit/application/kick_spec.rb +1 -3
  114. data/spec/unit/application/master_spec.rb +1 -3
  115. data/spec/unit/application/queue_spec.rb +1 -0
  116. data/spec/unit/application_spec.rb +63 -5
  117. data/spec/unit/configurer/plugin_handler_spec.rb +5 -1
  118. data/spec/unit/configurer_spec.rb +33 -49
  119. data/spec/unit/file_bucket/dipper_spec.rb +69 -77
  120. data/spec/unit/file_bucket/file_spec.rb +12 -127
  121. data/spec/unit/file_serving/fileset_spec.rb +1 -0
  122. data/spec/unit/file_serving/metadata_spec.rb +4 -4
  123. data/spec/unit/indirector/active_record_spec.rb +1 -0
  124. data/spec/unit/indirector/catalog/active_record_spec.rb +29 -13
  125. data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
  126. data/spec/unit/indirector/facts/couch_spec.rb +1 -2
  127. data/spec/unit/indirector/file_bucket_file/file_spec.rb +202 -218
  128. data/spec/unit/indirector/file_server_spec.rb +6 -7
  129. data/spec/unit/indirector/indirection_spec.rb +71 -2
  130. data/spec/unit/indirector/ldap_spec.rb +2 -6
  131. data/spec/unit/indirector/node/active_record_spec.rb +1 -3
  132. data/spec/unit/indirector/queue_spec.rb +1 -3
  133. data/spec/unit/indirector/rest_spec.rb +37 -1
  134. data/spec/unit/indirector/ssl_file_spec.rb +5 -5
  135. data/spec/unit/indirector_spec.rb +6 -1
  136. data/spec/unit/module_spec.rb +1 -3
  137. data/spec/unit/network/formats_spec.rb +2 -5
  138. data/spec/unit/network/http/api/v1_spec.rb +4 -0
  139. data/spec/unit/network/http/compression_spec.rb +1 -3
  140. data/spec/unit/network/http/handler_spec.rb +39 -0
  141. data/spec/unit/network/http/mongrel/rest_spec.rb +1 -2
  142. data/spec/unit/network/http/mongrel_spec.rb +3 -9
  143. data/spec/unit/network/http/rack/rest_spec.rb +1 -3
  144. data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
  145. data/spec/unit/network/http/rack_spec.rb +2 -3
  146. data/spec/unit/network/http/webrick_spec.rb +1 -0
  147. data/spec/unit/network/rest_authconfig_spec.rb +1 -1
  148. data/spec/unit/network/rights_spec.rb +43 -23
  149. data/spec/unit/network/xmlrpc/client_spec.rb +1 -0
  150. data/spec/unit/parameter_spec.rb +1 -2
  151. data/spec/unit/parser/collector_spec.rb +3 -6
  152. data/spec/unit/parser/compiler_spec.rb +90 -5
  153. data/spec/unit/parser/lexer_spec.rb +3 -2
  154. data/spec/unit/parser/templatewrapper_spec.rb +1 -0
  155. data/spec/unit/property/keyvalue_spec.rb +5 -5
  156. data/spec/unit/property/list_spec.rb +7 -7
  157. data/spec/unit/provider/mount/parsed_spec.rb +1 -2
  158. data/spec/unit/provider/mount_spec.rb +8 -0
  159. data/spec/unit/provider/nameservice/directoryservice_spec.rb +38 -0
  160. data/spec/unit/provider/package/freebsd_spec.rb +55 -0
  161. data/spec/unit/provider/service/init_spec.rb +2 -0
  162. data/spec/unit/rails/host_spec.rb +1 -3
  163. data/spec/unit/rails/param_value_spec.rb +2 -3
  164. data/spec/unit/rails/resource_spec.rb +2 -3
  165. data/spec/unit/rails_spec.rb +5 -15
  166. data/spec/unit/relationship_spec.rb +2 -6
  167. data/spec/unit/reports/http_spec.rb +1 -1
  168. data/spec/unit/reports/store_spec.rb +31 -0
  169. data/spec/unit/reports/tagmail_spec.rb +1 -1
  170. data/spec/unit/resource/catalog_spec.rb +2 -6
  171. data/spec/unit/resource/status_spec.rb +53 -3
  172. data/spec/unit/resource/type_collection_spec.rb +0 -8
  173. data/spec/unit/resource/type_spec.rb +50 -4
  174. data/spec/unit/resource_spec.rb +10 -6
  175. data/spec/unit/ssl/certificate_authority/interface_spec.rb +1 -1
  176. data/spec/unit/transaction/event_spec.rb +21 -2
  177. data/spec/unit/transaction/report_spec.rb +91 -35
  178. data/spec/unit/transaction/resource_harness_spec.rb +289 -208
  179. data/spec/unit/transaction_spec.rb +1 -6
  180. data/spec/unit/type/augeas_spec.rb +1 -3
  181. data/spec/unit/type/file/content_spec.rb +63 -10
  182. data/spec/unit/type/file/ctime.rb +35 -0
  183. data/spec/unit/type/file/ensure_spec.rb +8 -7
  184. data/spec/unit/type/file/group_spec.rb +5 -5
  185. data/spec/unit/type/file/mtime.rb +35 -0
  186. data/spec/unit/type/file/owner_spec.rb +7 -7
  187. data/spec/unit/type/file/selinux_spec.rb +2 -2
  188. data/spec/unit/type/file/source_spec.rb +3 -3
  189. data/spec/unit/type/file/type.rb +20 -0
  190. data/spec/unit/type/file_spec.rb +131 -8
  191. data/spec/unit/type/mount_spec.rb +4 -4
  192. data/spec/unit/type/package_spec.rb +3 -3
  193. data/spec/unit/type/ssh_authorized_key_spec.rb +1 -1
  194. data/spec/unit/type/user_spec.rb +31 -3
  195. data/spec/unit/type/zpool_spec.rb +12 -12
  196. data/spec/unit/type_spec.rb +2 -2
  197. data/spec/unit/util/checksums_spec.rb +9 -1
  198. data/spec/unit/util/command_line_spec.rb +29 -0
  199. data/spec/unit/util/log/destinations_spec.rb +13 -0
  200. data/spec/unit/util/log_spec.rb +24 -12
  201. data/spec/unit/util/logging_spec.rb +1 -1
  202. data/spec/unit/util/metric_spec.rb +7 -7
  203. data/spec/unit/util/pson_spec.rb +15 -0
  204. data/spec/unit/util/queue/stomp_spec.rb +2 -6
  205. data/spec/unit/util/settings/file_setting_spec.rb +1 -3
  206. data/spec/unit/util/zaml_spec.rb +51 -0
  207. data/test/language/snippets.rb +3 -0
  208. data/test/lib/puppettest/fileparsing.rb +2 -0
  209. data/test/lib/puppettest/reporttesting.rb +1 -1
  210. data/test/lib/puppettest/support/utils.rb +1 -1
  211. data/test/network/server/mongrel_test.rb +0 -6
  212. data/test/other/report.rb +1 -1
  213. data/test/ral/providers/cron/crontab.rb +4 -1
  214. data/test/ral/type/file.rb +1 -1
  215. data/test/ral/type/filesources.rb +1 -4
  216. metadata +1119 -1113
  217. data/lib/puppet/transaction/change.rb +0 -87
  218. data/spec/Rakefile +0 -91
  219. data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -46
  220. data/spec/spec_specs/runnable_spec.rb +0 -95
  221. data/spec/unit/transaction/change_spec.rb +0 -193
@@ -4,6 +4,7 @@
4
4
  # Copyright (c) 2007. All rights reserved.
5
5
 
6
6
  require File.dirname(__FILE__) + '/../../../spec_helper'
7
+ require 'puppet/network/handler'
7
8
  require 'puppet/network/http'
8
9
  require 'puppet/network/http/webrick'
9
10
 
@@ -47,7 +47,7 @@ describe Puppet::Network::RestAuthConfig do
47
47
  end
48
48
 
49
49
  it "should ask for authorization to the ACL subsystem" do
50
- @acl.expects(:fail_on_deny).with("/path/to/resource", :node => "me", :ip => "127.0.0.1", :method => :save, :environment => :env, :authenticated => true)
50
+ @acl.expects(:is_request_forbidden_and_why?).with(@request).returns(nil)
51
51
 
52
52
  @authconfig.allowed?(@request)
53
53
  end
@@ -9,6 +9,26 @@ describe Puppet::Network::Rights do
9
9
  @right = Puppet::Network::Rights.new
10
10
  end
11
11
 
12
+ describe "when validating a :head request" do
13
+ [:find, :save].each do |allowed_method|
14
+ it "should allow the request if only #{allowed_method} is allowed" do
15
+ rights = Puppet::Network::Rights.new
16
+ rights.newright("/")
17
+ rights.allow("/", "*")
18
+ rights.restrict_method("/", allowed_method)
19
+ rights.restrict_authenticated("/", :any)
20
+ request = Puppet::Indirector::Request.new(:indirection_name, :head, "key")
21
+ rights.is_request_forbidden_and_why?(request).should == nil
22
+ end
23
+ end
24
+
25
+ it "should disallow the request if neither :find nor :save is allowed" do
26
+ rights = Puppet::Network::Rights.new
27
+ request = Puppet::Indirector::Request.new(:indirection_name, :head, "key")
28
+ rights.is_request_forbidden_and_why?(request).should be_instance_of(Puppet::Network::AuthorizationError)
29
+ end
30
+ end
31
+
12
32
  [:allow, :deny, :restrict_method, :restrict_environment, :restrict_authenticated].each do |m|
13
33
  it "should have a #{m} method" do
14
34
  @right.should respond_to(m)
@@ -155,19 +175,19 @@ describe Puppet::Network::Rights do
155
175
  Puppet::Network::Rights::Right.stubs(:new).returns(@pathacl)
156
176
  end
157
177
 
158
- it "should delegate to fail_on_deny" do
159
- @right.expects(:fail_on_deny).with("namespace", :node => "host.domain.com", :ip => "127.0.0.1")
178
+ it "should delegate to is_forbidden_and_why?" do
179
+ @right.expects(:is_forbidden_and_why?).with("namespace", :node => "host.domain.com", :ip => "127.0.0.1").returns(nil)
160
180
 
161
181
  @right.allowed?("namespace", "host.domain.com", "127.0.0.1")
162
182
  end
163
183
 
164
- it "should return true if fail_on_deny doesn't fail" do
165
- @right.stubs(:fail_on_deny)
184
+ it "should return true if is_forbidden_and_why? returns nil" do
185
+ @right.stubs(:is_forbidden_and_why?).returns(nil)
166
186
  @right.allowed?("namespace", :args).should be_true
167
187
  end
168
188
 
169
- it "should return false if fail_on_deny raises an AuthorizationError" do
170
- @right.stubs(:fail_on_deny).raises(Puppet::Network::AuthorizationError.new("forbidden"))
189
+ it "should return false if is_forbidden_and_why? returns an AuthorizationError" do
190
+ @right.stubs(:is_forbidden_and_why?).returns(Puppet::Network::AuthorizationError.new("forbidden"))
171
191
  @right.allowed?("namespace", :args1, :args2).should be_false
172
192
  end
173
193
 
@@ -179,7 +199,7 @@ describe Puppet::Network::Rights do
179
199
  acl.expects(:match?).returns(true)
180
200
  acl.expects(:allowed?).with { |node,ip,h| node == "node" and ip == "ip" }.returns(true)
181
201
 
182
- @right.fail_on_deny("namespace", { :node => "node", :ip => "ip" } )
202
+ @right.is_forbidden_and_why?("namespace", { :node => "node", :ip => "ip" } ).should == nil
183
203
  end
184
204
 
185
205
  it "should then check for path rights if no namespace match" do
@@ -195,7 +215,7 @@ describe Puppet::Network::Rights do
195
215
  acl.expects(:allowed?).never
196
216
  @pathacl.expects(:allowed?).returns(true)
197
217
 
198
- @right.fail_on_deny("/path/to/there", {})
218
+ @right.is_forbidden_and_why?("/path/to/there", {}).should == nil
199
219
  end
200
220
 
201
221
  it "should pass the match? return to allowed?" do
@@ -204,12 +224,12 @@ describe Puppet::Network::Rights do
204
224
  @pathacl.expects(:match?).returns(:match)
205
225
  @pathacl.expects(:allowed?).with { |node,ip,h| h[:match] == :match }.returns(true)
206
226
 
207
- @right.fail_on_deny("/path/to/there", {})
227
+ @right.is_forbidden_and_why?("/path/to/there", {}).should == nil
208
228
  end
209
229
 
210
230
  describe "with namespace acls" do
211
- it "should raise an error if this namespace right doesn't exist" do
212
- lambda{ @right.fail_on_deny("namespace") }.should raise_error
231
+ it "should return an ArgumentError if this namespace right doesn't exist" do
232
+ lambda { @right.is_forbidden_and_why?("namespace") }.should raise_error(ArgumentError)
213
233
  end
214
234
  end
215
235
 
@@ -235,7 +255,7 @@ describe Puppet::Network::Rights do
235
255
  @long_acl.expects(:allowed?).returns(true)
236
256
  @short_acl.expects(:allowed?).never
237
257
 
238
- @right.fail_on_deny("/path/to/there/and/there", {})
258
+ @right.is_forbidden_and_why?("/path/to/there/and/there", {}).should == nil
239
259
  end
240
260
 
241
261
  it "should select the first match that doesn't return :dunno" do
@@ -248,7 +268,7 @@ describe Puppet::Network::Rights do
248
268
  @long_acl.expects(:allowed?).returns(:dunno)
249
269
  @short_acl.expects(:allowed?).returns(true)
250
270
 
251
- @right.fail_on_deny("/path/to/there/and/there", {})
271
+ @right.is_forbidden_and_why?("/path/to/there/and/there", {}).should == nil
252
272
  end
253
273
 
254
274
  it "should not select an ACL that doesn't match" do
@@ -261,7 +281,7 @@ describe Puppet::Network::Rights do
261
281
  @long_acl.expects(:allowed?).never
262
282
  @short_acl.expects(:allowed?).returns(true)
263
283
 
264
- @right.fail_on_deny("/path/to/there/and/there", {})
284
+ @right.is_forbidden_and_why?("/path/to/there/and/there", {}).should == nil
265
285
  end
266
286
 
267
287
  it "should not raise an AuthorizationError if allowed" do
@@ -270,7 +290,7 @@ describe Puppet::Network::Rights do
270
290
  @long_acl.stubs(:match?).returns(true)
271
291
  @long_acl.stubs(:allowed?).returns(true)
272
292
 
273
- lambda { @right.fail_on_deny("/path/to/there/and/there", {}) }.should_not raise_error(Puppet::Network::AuthorizationError)
293
+ @right.is_forbidden_and_why?("/path/to/there/and/there", {}).should == nil
274
294
  end
275
295
 
276
296
  it "should raise an AuthorizationError if the match is denied" do
@@ -279,11 +299,11 @@ describe Puppet::Network::Rights do
279
299
  @long_acl.stubs(:match?).returns(true)
280
300
  @long_acl.stubs(:allowed?).returns(false)
281
301
 
282
- lambda{ @right.fail_on_deny("/path/to/there", {}) }.should raise_error(Puppet::Network::AuthorizationError)
302
+ @right.is_forbidden_and_why?("/path/to/there", {}).should be_instance_of(Puppet::Network::AuthorizationError)
283
303
  end
284
304
 
285
305
  it "should raise an AuthorizationError if no path match" do
286
- lambda { @right.fail_on_deny("/nomatch", {}) }.should raise_error(Puppet::Network::AuthorizationError)
306
+ @right.is_forbidden_and_why?("/nomatch", {}).should be_instance_of(Puppet::Network::AuthorizationError)
287
307
  end
288
308
  end
289
309
 
@@ -309,7 +329,7 @@ describe Puppet::Network::Rights do
309
329
  @regex_acl1.expects(:allowed?).returns(true)
310
330
  @regex_acl2.expects(:allowed?).never
311
331
 
312
- @right.fail_on_deny("/files/repository/myfile/other", {})
332
+ @right.is_forbidden_and_why?("/files/repository/myfile/other", {}).should == nil
313
333
  end
314
334
 
315
335
  it "should select the first match that doesn't return :dunno" do
@@ -322,7 +342,7 @@ describe Puppet::Network::Rights do
322
342
  @regex_acl1.expects(:allowed?).returns(:dunno)
323
343
  @regex_acl2.expects(:allowed?).returns(true)
324
344
 
325
- @right.fail_on_deny("/files/repository/myfile/other", {})
345
+ @right.is_forbidden_and_why?("/files/repository/myfile/other", {}).should == nil
326
346
  end
327
347
 
328
348
  it "should not select an ACL that doesn't match" do
@@ -335,7 +355,7 @@ describe Puppet::Network::Rights do
335
355
  @regex_acl1.expects(:allowed?).never
336
356
  @regex_acl2.expects(:allowed?).returns(true)
337
357
 
338
- @right.fail_on_deny("/files/repository/myfile/other", {})
358
+ @right.is_forbidden_and_why?("/files/repository/myfile/other", {}).should == nil
339
359
  end
340
360
 
341
361
  it "should not raise an AuthorizationError if allowed" do
@@ -344,15 +364,15 @@ describe Puppet::Network::Rights do
344
364
  @regex_acl1.stubs(:match?).returns(true)
345
365
  @regex_acl1.stubs(:allowed?).returns(true)
346
366
 
347
- lambda { @right.fail_on_deny("/files/repository/myfile/other", {}) }.should_not raise_error(Puppet::Network::AuthorizationError)
367
+ @right.is_forbidden_and_why?("/files/repository/myfile/other", {}).should == nil
348
368
  end
349
369
 
350
370
  it "should raise an error if no regex acl match" do
351
- lambda{ @right.fail_on_deny("/path", {}) }.should raise_error(Puppet::Network::AuthorizationError)
371
+ @right.is_forbidden_and_why?("/path", {}).should be_instance_of(Puppet::Network::AuthorizationError)
352
372
  end
353
373
 
354
374
  it "should raise an AuthorizedError on deny" do
355
- lambda { @right.fail_on_deny("/path", {}) }.should raise_error(Puppet::Network::AuthorizationError)
375
+ @right.is_forbidden_and_why?("/path", {}).should be_instance_of(Puppet::Network::AuthorizationError)
356
376
  end
357
377
 
358
378
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'puppet/network/client'
2
3
 
3
4
  Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
4
5
 
@@ -52,8 +52,7 @@ describe Puppet::Parameter do
52
52
  @resource.expects(:line).returns 10
53
53
  @resource.expects(:file).returns "file"
54
54
  @resource.expects(:tags).returns %w{one two}
55
- @resource.expects(:version).returns 50
56
- @parameter.source_descriptors.should == {:tags=>["one", "two", "foo"], :path=>"//foo", :version=>50, :file => "file", :line => 10}
55
+ @parameter.source_descriptors.should == {:tags=>["one", "two", "foo"], :path=>"//foo", :file => "file", :line => 10}
57
56
  end
58
57
 
59
58
  describe "when returning the value" do
@@ -2,6 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
4
 
5
+ require 'puppet/rails'
5
6
  require 'puppet/parser/collector'
6
7
 
7
8
  describe Puppet::Parser::Collector, "when initializing" do
@@ -262,9 +263,7 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
262
263
  end
263
264
  end
264
265
 
265
- describe Puppet::Parser::Collector, "when collecting exported resources" do
266
- confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails?
267
-
266
+ describe Puppet::Parser::Collector, "when collecting exported resources", :if => Puppet.features.rails? do
268
267
  before do
269
268
  @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
270
269
  @scope = Puppet::Parser::Scope.new :compiler => @compiler
@@ -468,9 +467,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
468
467
  end
469
468
  end
470
469
 
471
- describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources" do
472
- confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails?
473
-
470
+ describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources", :if => Puppet.features.rails? do
474
471
  before do
475
472
  @scope = stub 'scope', :host => "myhost", :debug => nil
476
473
  @compiler = mock 'compile'
@@ -105,8 +105,15 @@ describe Puppet::Parser::Compiler do
105
105
  node.classes = %w{foo bar}
106
106
  compiler = Puppet::Parser::Compiler.new(node)
107
107
 
108
- compiler.classlist.should include("foo")
109
- compiler.classlist.should include("bar")
108
+ compiler.classlist.should =~ ['foo', 'bar']
109
+ end
110
+
111
+ it "should transform node class hashes into a class list" do
112
+ node = Puppet::Node.new("mynode")
113
+ node.classes = {'foo'=>{'one'=>'1'}, 'bar'=>{'two'=>'2'}}
114
+ compiler = Puppet::Parser::Compiler.new(node)
115
+
116
+ compiler.classlist.should =~ ['foo', 'bar']
110
117
  end
111
118
 
112
119
  it "should add a 'main' stage to the catalog" do
@@ -185,6 +192,14 @@ describe Puppet::Parser::Compiler do
185
192
  @compiler.class.publicize_methods(:evaluate_node_classes) { @compiler.evaluate_node_classes }
186
193
  end
187
194
 
195
+ it "should evaluate any parameterized classes named in the node" do
196
+ classes = {'foo'=>{'1'=>'one'}, 'bar'=>{'2'=>'two'}}
197
+ @node.stubs(:classes).returns(classes)
198
+ @compiler.expects(:evaluate_classes).with(classes, @compiler.topscope)
199
+ @compiler.compile
200
+ end
201
+
202
+
188
203
  it "should evaluate the main class if it exists" do
189
204
  compile_stub(:evaluate_main)
190
205
  main_class = @known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
@@ -532,7 +547,7 @@ describe Puppet::Parser::Compiler do
532
547
 
533
548
  @compiler.add_collection(coll)
534
549
 
535
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
550
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources something'
536
551
  end
537
552
 
538
553
  it "should fail when there are unevaluated resource collections that refer to multiple specific resources" do
@@ -541,7 +556,7 @@ describe Puppet::Parser::Compiler do
541
556
 
542
557
  @compiler.add_collection(coll)
543
558
 
544
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
559
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources one, two'
545
560
  end
546
561
  end
547
562
 
@@ -566,6 +581,14 @@ describe Puppet::Parser::Compiler do
566
581
  @scope.expects(:find_hostclass).with("notfound").returns(nil)
567
582
  @compiler.evaluate_classes(%w{notfound}, @scope)
568
583
  end
584
+ # I wish it would fail
585
+ it "should log when it can't find class" do
586
+ klasses = {'foo'=>nil}
587
+ @node.classes = klasses
588
+ @compiler.topscope.stubs(:find_hostclass).with('foo').returns(nil)
589
+ Puppet.expects(:info).with('Could not find class foo for testnode')
590
+ @compiler.compile
591
+ end
569
592
  end
570
593
 
571
594
  describe "when evaluating found classes" do
@@ -586,6 +609,68 @@ describe Puppet::Parser::Compiler do
586
609
  @compiler.evaluate_classes(%w{myclass}, @scope)
587
610
  end
588
611
 
612
+ it "should ensure each node class hash is in catalog and have appropriate parameters" do
613
+ klasses = {'foo'=>{'1'=>'one'}, 'bar::foo'=>{'2'=>'two'}, 'bar'=>{'1'=> [1,2,3], '2'=>{'foo'=>'bar'}}}
614
+ @node.classes = klasses
615
+ ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
616
+ klasses.each do |name, params|
617
+ klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
618
+ @compiler.topscope.known_resource_types.add klass
619
+ end
620
+ catalog = @compiler.compile
621
+ catalog.classes.should =~ ['foo', 'bar::foo', 'settings', 'bar']
622
+
623
+ r1 = catalog.resources.detect {|r| r.title == 'Foo' }
624
+ r1.to_hash.should == {:'1' => 'one', :'2' => 'foo'}
625
+ r1.tags. should =~ ['class', 'foo']
626
+
627
+ r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
628
+ r2.to_hash.should == {:'1' => 'foo', :'2' => 'two'}
629
+ r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
630
+
631
+ r2 = catalog.resources.detect {|r| r.title == 'Bar' }
632
+ r2.to_hash.should == {:'1' => [1,2,3], :'2' => {'foo'=>'bar'}}
633
+ r2.tags.should =~ ['class', 'bar']
634
+ end
635
+
636
+ it "should ensure each node class is in catalog and has appropriate tags" do
637
+ klasses = ['bar::foo']
638
+ @node.classes = klasses
639
+ ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
640
+ klasses.each do |name|
641
+ klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
642
+ @compiler.topscope.known_resource_types.add klass
643
+ end
644
+ catalog = @compiler.compile
645
+
646
+ r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
647
+ r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
648
+ end
649
+
650
+ it "should fail if required parameters are missing" do
651
+ klass = {'foo'=>{'1'=>'one'}}
652
+ @node.classes = klass
653
+ klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
654
+ @compiler.topscope.known_resource_types.add klass
655
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Must pass 2 to Class[Foo]"
656
+ end
657
+
658
+ it "should fail if invalid parameters are passed" do
659
+ klass = {'foo'=>{'3'=>'one'}}
660
+ @node.classes = klass
661
+ klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
662
+ @compiler.topscope.known_resource_types.add klass
663
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Invalid parameter 3"
664
+ end
665
+
666
+ it "should ensure class is in catalog without params" do
667
+ @node.classes = klasses = {'foo'=>nil}
668
+ foo = Puppet::Resource::Type.new(:hostclass, 'foo')
669
+ @compiler.topscope.known_resource_types.add foo
670
+ catalog = @compiler.compile
671
+ catalog.classes.should include 'foo'
672
+ end
673
+
589
674
  it "should not evaluate the resources created for found classes unless asked" do
590
675
  @compiler.catalog.stubs(:tag)
591
676
 
@@ -759,7 +844,7 @@ describe Puppet::Parser::Compiler do
759
844
  it "should fail if the compile is finished and resource overrides have not been applied" do
760
845
  @compiler.add_override(@override)
761
846
 
762
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
847
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Could not find resource(s) File[/foo] for overriding'
763
848
  end
764
849
  end
765
850
  end
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
5
5
  require 'puppet/parser/lexer'
6
6
 
7
7
  # This is a special matcher to match easily lexer output
8
- Spec::Matchers.define :be_like do |*expected|
8
+ RSpec::Matchers.define :be_like do |*expected|
9
9
  match do |actual|
10
10
  expected.zip(actual).all? { |e,a| !e or a[0] == e or (e.is_a? Array and a[0] == e[0] and (a[1] == e[1] or (a[1].is_a?(Hash) and a[1][:value] == e[1]))) }
11
11
  end
@@ -651,7 +651,8 @@ describe "Puppet::Parser::Lexer in the old tests" do
651
651
  end
652
652
  end
653
653
 
654
- require 'puppettest/support/utils'
654
+ require File.dirname(__FILE__) + '/../../../test/lib/puppettest'
655
+ require File.dirname(__FILE__) + '/../../../test/lib/puppettest/support/utils'
655
656
  describe "Puppet::Parser::Lexer in the old tests when lexing example files" do
656
657
  extend PuppetTest::Support::Utils
657
658
  textfiles do |file|
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
+ require 'puppet/parser/templatewrapper'
4
5
 
5
6
  describe Puppet::Parser::TemplateWrapper do
6
7
  before(:each) do
@@ -134,7 +134,7 @@ describe klass do
134
134
  end
135
135
  end
136
136
 
137
- describe "when calling insync?" do
137
+ describe "when calling safe_insync?" do
138
138
  before do
139
139
  @provider = mock("provider")
140
140
  @property.stubs(:provider).returns(@provider)
@@ -142,26 +142,26 @@ describe klass do
142
142
  end
143
143
 
144
144
  it "should return true unless @should is defined and not nil" do
145
- @property.insync?("foo") == true
145
+ @property.safe_insync?("foo") == true
146
146
  end
147
147
 
148
148
  it "should return true if the passed in values is nil" do
149
149
  @property.should = "foo"
150
- @property.insync?(nil) == true
150
+ @property.safe_insync?(nil) == true
151
151
  end
152
152
 
153
153
  it "should return true if hashified should value == (retrieved) value passed in" do
154
154
  @provider.stubs(:prop_name).returns({ :foo => "baz", :bar => "boo" })
155
155
  @property.should = ["foo=baz", "bar=boo"]
156
156
  @property.expects(:inclusive?).returns(true)
157
- @property.insync?({ :foo => "baz", :bar => "boo" }).must == true
157
+ @property.safe_insync?({ :foo => "baz", :bar => "boo" }).must == true
158
158
  end
159
159
 
160
160
  it "should return false if prepared value != should value" do
161
161
  @provider.stubs(:prop_name).returns({ "foo" => "bee", "bar" => "boo" })
162
162
  @property.should = ["foo=baz", "bar=boo"]
163
163
  @property.expects(:inclusive?).returns(true)
164
- @property.insync?({ "foo" => "bee", "bar" => "boo" }).must == false
164
+ @property.safe_insync?({ "foo" => "bee", "bar" => "boo" }).must == false
165
165
  end
166
166
  end
167
167
  end