puppet 2.7.9 → 2.7.11

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 (187) hide show
  1. data/CHANGELOG +413 -0
  2. data/README_DEVELOPER.md +28 -0
  3. data/conf/redhat/puppet.spec +10 -1
  4. data/conf/solaris/pkginfo +1 -1
  5. data/conf/suse/puppet.spec +7 -4
  6. data/ext/envpuppet.bat +13 -0
  7. data/ext/rack/files/apache2.conf +4 -0
  8. data/install.rb +4 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/agent.rb +7 -0
  11. data/lib/puppet/agent/disabler.rb +27 -0
  12. data/lib/puppet/agent/locker.rb +0 -10
  13. data/lib/puppet/application.rb +3 -0
  14. data/lib/puppet/application/agent.rb +13 -3
  15. data/lib/puppet/application/apply.rb +6 -6
  16. data/lib/puppet/application/cert.rb +5 -5
  17. data/lib/puppet/application/instrumentation_data.rb +4 -0
  18. data/lib/puppet/application/instrumentation_listener.rb +4 -0
  19. data/lib/puppet/application/instrumentation_probe.rb +4 -0
  20. data/lib/puppet/configurer.rb +3 -1
  21. data/lib/puppet/configurer/downloader.rb +4 -2
  22. data/lib/puppet/configurer/fact_handler.rb +0 -21
  23. data/lib/puppet/daemon.rb +3 -4
  24. data/lib/puppet/defaults.rb +2 -2
  25. data/lib/puppet/face/instrumentation_data.rb +28 -0
  26. data/lib/puppet/face/instrumentation_listener.rb +96 -0
  27. data/lib/puppet/face/instrumentation_probe.rb +77 -0
  28. data/lib/puppet/face/module/list.rb +64 -0
  29. data/lib/puppet/face/module/uninstall.rb +50 -0
  30. data/lib/puppet/face/node/clean.rb +1 -4
  31. data/lib/puppet/feature/base.rb +1 -0
  32. data/lib/puppet/file_serving/content.rb +1 -1
  33. data/lib/puppet/indirector/facts/facter.rb +20 -7
  34. data/lib/puppet/indirector/facts/inventory_active_record.rb +14 -11
  35. data/lib/puppet/indirector/indirection.rb +7 -0
  36. data/lib/puppet/indirector/instrumentation_data.rb +3 -0
  37. data/lib/puppet/indirector/instrumentation_data/local.rb +19 -0
  38. data/lib/puppet/indirector/instrumentation_data/rest.rb +5 -0
  39. data/lib/puppet/indirector/instrumentation_listener.rb +3 -0
  40. data/lib/puppet/indirector/instrumentation_listener/local.rb +23 -0
  41. data/lib/puppet/indirector/instrumentation_listener/rest.rb +5 -0
  42. data/lib/puppet/indirector/instrumentation_probe.rb +3 -0
  43. data/lib/puppet/indirector/instrumentation_probe/local.rb +24 -0
  44. data/lib/puppet/indirector/instrumentation_probe/rest.rb +5 -0
  45. data/lib/puppet/indirector/rest.rb +1 -1
  46. data/lib/puppet/module.rb +13 -17
  47. data/lib/puppet/module_tool/applications.rb +1 -0
  48. data/lib/puppet/module_tool/applications/uninstaller.rb +33 -0
  49. data/lib/puppet/module_tool/contents_description.rb +1 -1
  50. data/lib/puppet/network/server.rb +2 -3
  51. data/lib/puppet/node/environment.rb +16 -3
  52. data/lib/puppet/parser/ast/leaf.rb +1 -1
  53. data/lib/puppet/parser/functions/create_resources.rb +1 -1
  54. data/lib/puppet/parser/type_loader.rb +1 -1
  55. data/lib/puppet/property.rb +46 -14
  56. data/lib/puppet/provider.rb +13 -4
  57. data/lib/puppet/provider/augeas/augeas.rb +6 -4
  58. data/lib/puppet/provider/group/pw.rb +24 -10
  59. data/lib/puppet/provider/nameservice/directoryservice.rb +146 -37
  60. data/lib/puppet/provider/package/pip.rb +1 -1
  61. data/lib/puppet/provider/package/yum.rb +1 -2
  62. data/lib/puppet/provider/service/debian.rb +14 -0
  63. data/lib/puppet/provider/service/launchd.rb +1 -1
  64. data/lib/puppet/provider/service/smf.rb +2 -2
  65. data/lib/puppet/provider/user/pw.rb +56 -2
  66. data/lib/puppet/provider/user/user_role_add.rb +32 -22
  67. data/lib/puppet/provider/user/windows_adsi.rb +1 -0
  68. data/lib/puppet/rails/benchmark.rb +1 -1
  69. data/lib/puppet/reports/store.rb +8 -1
  70. data/lib/puppet/resource/catalog.rb +5 -1
  71. data/lib/puppet/simple_graph.rb +11 -14
  72. data/lib/puppet/transaction.rb +10 -4
  73. data/lib/puppet/transaction/report.rb +9 -3
  74. data/lib/puppet/type.rb +19 -7
  75. data/lib/puppet/type/exec.rb +1 -1
  76. data/lib/puppet/type/file.rb +4 -1
  77. data/lib/puppet/type/file/ensure.rb +5 -1
  78. data/lib/puppet/type/file/mode.rb +45 -10
  79. data/lib/puppet/type/file/source.rb +4 -0
  80. data/lib/puppet/type/host.rb +17 -3
  81. data/lib/puppet/type/k5login.rb +3 -2
  82. data/lib/puppet/type/schedule.rb +3 -2
  83. data/lib/puppet/util.rb +83 -27
  84. data/lib/puppet/util/anonymous_filelock.rb +36 -0
  85. data/lib/puppet/util/docs.rb +18 -2
  86. data/lib/puppet/util/instrumentation.rb +173 -0
  87. data/lib/puppet/util/instrumentation/data.rb +34 -0
  88. data/lib/puppet/util/instrumentation/indirection_probe.rb +29 -0
  89. data/lib/puppet/util/instrumentation/instrumentable.rb +143 -0
  90. data/lib/puppet/util/instrumentation/listener.rb +60 -0
  91. data/lib/puppet/util/instrumentation/listeners/log.rb +29 -0
  92. data/lib/puppet/util/instrumentation/listeners/performance.rb +30 -0
  93. data/lib/puppet/util/monkey_patches.rb +8 -0
  94. data/lib/puppet/util/pidlock.rb +21 -25
  95. data/lib/puppet/util/rdoc/parser.rb +2 -2
  96. data/lib/puppet/util/reference.rb +8 -23
  97. data/lib/puppet/util/retryaction.rb +48 -0
  98. data/lib/puppet/util/suidmanager.rb +70 -39
  99. data/lib/puppet/util/symbolic_file_mode.rb +140 -0
  100. data/spec/integration/configurer_spec.rb +5 -0
  101. data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
  102. data/spec/integration/indirector/file_content/file_server_spec.rb +7 -7
  103. data/spec/integration/provider/package_spec.rb +7 -0
  104. data/spec/unit/agent/disabler_spec.rb +60 -0
  105. data/spec/unit/agent/locker_spec.rb +0 -12
  106. data/spec/unit/agent_spec.rb +8 -0
  107. data/spec/unit/application/agent_spec.rb +38 -1
  108. data/spec/unit/application/apply_spec.rb +34 -40
  109. data/spec/unit/application/cert_spec.rb +1 -1
  110. data/spec/unit/application_spec.rb +6 -0
  111. data/spec/unit/configurer/downloader_spec.rb +29 -10
  112. data/spec/unit/configurer/fact_handler_spec.rb +5 -29
  113. data/spec/unit/configurer_spec.rb +8 -8
  114. data/spec/unit/daemon_spec.rb +12 -26
  115. data/spec/unit/face/instrumentation_data.rb +7 -0
  116. data/spec/unit/face/instrumentation_listener.rb +38 -0
  117. data/spec/unit/face/instrumentation_probe.rb +21 -0
  118. data/spec/unit/face/node_spec.rb +111 -111
  119. data/spec/unit/file_serving/content_spec.rb +2 -2
  120. data/spec/unit/indirector/facts/facter_spec.rb +25 -3
  121. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +14 -4
  122. data/spec/unit/indirector/instrumentation_data/local_spec.rb +52 -0
  123. data/spec/unit/indirector/instrumentation_data/rest_spec.rb +11 -0
  124. data/spec/unit/indirector/instrumentation_listener/local_spec.rb +65 -0
  125. data/spec/unit/indirector/instrumentation_listener/rest_spec.rb +11 -0
  126. data/spec/unit/indirector/instrumentation_probe/local_spec.rb +65 -0
  127. data/spec/unit/indirector/instrumentation_probe/rest_spec.rb +11 -0
  128. data/spec/unit/module_spec.rb +39 -125
  129. data/spec/unit/module_tool/uninstaller_spec.rb +44 -0
  130. data/spec/unit/network/server_spec.rb +2 -20
  131. data/spec/unit/node/environment_spec.rb +76 -58
  132. data/spec/unit/parser/ast/asthash_spec.rb +1 -2
  133. data/spec/unit/parser/ast/leaf_spec.rb +16 -0
  134. data/spec/unit/property/keyvalue_spec.rb +5 -2
  135. data/spec/unit/property_spec.rb +260 -159
  136. data/spec/unit/provider/augeas/augeas_spec.rb +2 -2
  137. data/spec/unit/provider/group/pw_spec.rb +81 -0
  138. data/spec/unit/provider/nameservice/directoryservice_spec.rb +102 -0
  139. data/spec/unit/provider/package/pip_spec.rb +7 -0
  140. data/spec/unit/provider/package/yum_spec.rb +45 -1
  141. data/spec/unit/provider/service/debian_spec.rb +15 -0
  142. data/spec/unit/provider/service/launchd_spec.rb +48 -43
  143. data/spec/unit/provider/service/smf_spec.rb +3 -3
  144. data/spec/unit/provider/user/pw_spec.rb +183 -0
  145. data/spec/unit/provider/user/user_role_add_spec.rb +46 -39
  146. data/spec/unit/provider/user/windows_adsi_spec.rb +1 -0
  147. data/spec/unit/provider_spec.rb +32 -0
  148. data/spec/unit/reports/store_spec.rb +19 -1
  149. data/spec/unit/simple_graph_spec.rb +34 -19
  150. data/spec/unit/ssl/certificate_factory_spec.rb +3 -3
  151. data/spec/unit/transaction/report_spec.rb +29 -1
  152. data/spec/unit/transaction_spec.rb +32 -46
  153. data/spec/unit/type/file/mode_spec.rb +1 -1
  154. data/spec/unit/type/file/source_spec.rb +28 -3
  155. data/spec/unit/type/file_spec.rb +17 -16
  156. data/spec/unit/type/host_spec.rb +527 -0
  157. data/spec/unit/type/k5login_spec.rb +115 -0
  158. data/spec/unit/type/schedule_spec.rb +6 -6
  159. data/spec/unit/type_spec.rb +51 -0
  160. data/spec/unit/util/anonymous_filelock_spec.rb +78 -0
  161. data/spec/unit/util/execution_stub_spec.rb +2 -1
  162. data/spec/unit/util/instrumentation/data_spec.rb +44 -0
  163. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +19 -0
  164. data/spec/unit/util/instrumentation/instrumentable_spec.rb +186 -0
  165. data/spec/unit/util/instrumentation/listener_spec.rb +100 -0
  166. data/spec/unit/util/instrumentation/listeners/log_spec.rb +34 -0
  167. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +36 -0
  168. data/spec/unit/util/instrumentation_spec.rb +181 -0
  169. data/spec/unit/util/pidlock_spec.rb +208 -0
  170. data/spec/unit/util/rdoc/parser_spec.rb +1 -1
  171. data/spec/unit/util/reference_spec.rb +16 -6
  172. data/spec/unit/util/retryaction_spec.rb +62 -0
  173. data/spec/unit/util/suidmanager_spec.rb +101 -83
  174. data/spec/unit/util/symbolic_file_mode_spec.rb +182 -0
  175. data/spec/unit/util_spec.rb +126 -0
  176. data/tasks/rake/apple.rake +176 -0
  177. data/tasks/rake/templates/prototype.plist.erb +38 -0
  178. metadata +61 -13
  179. data/lib/puppet/application/module.rb +0 -3
  180. data/lib/puppet/face/module.rb +0 -12
  181. data/spec/unit/face/module/build_spec.rb +0 -30
  182. data/spec/unit/face/module/changes_spec.rb +0 -30
  183. data/spec/unit/face/module/clean_spec.rb +0 -30
  184. data/spec/unit/face/module/generate_spec.rb +0 -30
  185. data/spec/unit/face/module/install_spec.rb +0 -75
  186. data/spec/unit/face/module/search_spec.rb +0 -40
  187. data/test/util/pidlock.rb +0 -126
@@ -52,19 +52,19 @@ describe Puppet::SSL::CertificateFactory do
52
52
 
53
53
  it "should have 24 hours grace on the start of the cert" do
54
54
  cert = subject.build(:server, csr, issuer, serial)
55
- cert.not_before.should be_within(1).of(Time.now - 24*60*60)
55
+ cert.not_before.should be_within(30).of(Time.now - 24*60*60)
56
56
  end
57
57
 
58
58
  it "should set the default TTL of the certificate" do
59
59
  ttl = Puppet::SSL::CertificateFactory.ttl
60
60
  cert = subject.build(:server, csr, issuer, serial)
61
- cert.not_after.should be_within(1).of(Time.now + ttl)
61
+ cert.not_after.should be_within(30).of(Time.now + ttl)
62
62
  end
63
63
 
64
64
  it "should respect a custom TTL for the CA" do
65
65
  Puppet[:ca_ttl] = 12
66
66
  cert = subject.build(:server, csr, issuer, serial)
67
- cert.not_after.should be_within(1).of(Time.now + 12)
67
+ cert.not_after.should be_within(30).of(Time.now + 12)
68
68
  end
69
69
 
70
70
  it "should build extensions for the certificate" do
@@ -179,6 +179,11 @@ describe Puppet::Transaction::Report do
179
179
  @report.finalize_report
180
180
  metric(:resources, state.to_s).should == 3
181
181
  end
182
+
183
+ it "should provide 0 for states not in status" do
184
+ @report.finalize_report
185
+ metric(:resources, state.to_s).should == 0
186
+ end
182
187
  end
183
188
 
184
189
  it "should mark the report as 'failed' if there are failing resources" do
@@ -274,13 +279,14 @@ describe Puppet::Transaction::Report do
274
279
  resource = Puppet::Type.type(:notify).new(:name => "testing")
275
280
  catalog = Puppet::Resource::Catalog.new
276
281
  catalog.add_resource resource
282
+ catalog.version = 1234567
277
283
  trans = catalog.apply
278
284
 
279
285
  @report = trans.report
280
286
  @report.finalize_report
281
287
  end
282
288
 
283
- %w{changes time resources events}.each do |main|
289
+ %w{changes time resources events version}.each do |main|
284
290
  it "should include the key #{main} in the raw summary hash" do
285
291
  @report.raw_summary.should be_key main
286
292
  end
@@ -291,6 +297,28 @@ describe Puppet::Transaction::Report do
291
297
  @report.raw_summary["time"]["last_run"].should == 1289390424
292
298
  end
293
299
 
300
+ it "should include all resource statuses" do
301
+ resources_report = @report.raw_summary["resources"]
302
+ Puppet::Resource::Status::STATES.each do |state|
303
+ resources_report.should be_include(state.to_s)
304
+ end
305
+ end
306
+
307
+ %w{total failure success}.each do |r|
308
+ it "should include event #{r}" do
309
+ events_report = @report.raw_summary["events"]
310
+ events_report.should be_include(r)
311
+ end
312
+ end
313
+
314
+ it "should include config version" do
315
+ @report.raw_summary["version"]["config"].should == 1234567
316
+ end
317
+
318
+ it "should include puppet version" do
319
+ @report.raw_summary["version"]["puppet"].should == Puppet.version
320
+ end
321
+
294
322
  %w{Changes Total Resources Time Events}.each do |main|
295
323
  it "should include information on #{main} in the textual summary" do
296
324
  @report.summary.should be_include(main)
@@ -436,6 +436,10 @@ describe Puppet::Transaction do
436
436
 
437
437
  @transaction.catalog.add_resource(dependent, dependent2)
438
438
 
439
+ # We enqueue them here just so we can check their blockers. This is done
440
+ # again in traverse.
441
+ graph.enqueue_roots
442
+
439
443
  graph.blockers[dependent].should == 1
440
444
  graph.blockers[dependent2].should == 1
441
445
 
@@ -453,6 +457,8 @@ describe Puppet::Transaction do
453
457
 
454
458
  @transaction.catalog.add_resource(dependent, dependent2)
455
459
 
460
+ graph.enqueue_roots
461
+
456
462
  graph.blockers[dependent].should == 1
457
463
  graph.blockers[dependent2].should == 1
458
464
 
@@ -510,70 +516,50 @@ describe Puppet::Transaction do
510
516
  end
511
517
  end
512
518
 
513
- describe "when generating resources" do
514
- it "should call 'generate' on all created resources" do
515
- first = Puppet::Type.type(:notify).new(:name => "first")
516
- second = Puppet::Type.type(:notify).new(:name => "second")
517
- third = Puppet::Type.type(:notify).new(:name => "third")
519
+ describe "when generating resources before traversal" do
520
+ let(:catalog) { Puppet::Resource::Catalog.new }
521
+ let(:transaction) { Puppet::Transaction.new(catalog) }
522
+ let(:generator) { Puppet::Type.type(:notify).create :title => "generator" }
523
+ let(:generated) do
524
+ %w[a b c].map { |name| Puppet::Type.type(:notify).new(:name => name) }
525
+ end
518
526
 
519
- @catalog = Puppet::Resource::Catalog.new
520
- @transaction = Puppet::Transaction.new(@catalog)
527
+ before :each do
528
+ catalog.add_resource generator
529
+ generator.stubs(:generate).returns generated
530
+ end
521
531
 
522
- first.expects(:generate).returns [second]
523
- second.expects(:generate).returns [third]
524
- third.expects(:generate)
532
+ it "should call 'generate' on all created resources" do
533
+ generated.each { |res| res.expects(:generate) }
525
534
 
526
- @transaction.generate_additional_resources(first)
535
+ transaction.add_dynamically_generated_resources
527
536
  end
528
537
 
529
538
  it "should finish all resources" do
530
- generator = stub 'generator', :depthfirst? => true, :tags => [], :ref => "Some[resource]"
531
- resource = stub 'resource', :tag => nil
532
-
533
- @catalog = Puppet::Resource::Catalog.new
534
- @transaction = Puppet::Transaction.new(@catalog)
535
-
536
- generator.expects(:generate).returns [resource]
537
-
538
- @catalog.expects(:add_resource).yields(resource)
539
-
540
- resource.expects(:finish)
539
+ generated.each { |res| res.expects(:finish) }
541
540
 
542
- @transaction.generate_additional_resources(generator)
541
+ transaction.add_dynamically_generated_resources
543
542
  end
544
543
 
545
544
  it "should skip generated resources that conflict with existing resources" do
546
- generator = mock 'generator', :tags => []
547
- resource = stub 'resource', :tag => nil
548
-
549
- @catalog = Puppet::Resource::Catalog.new
550
- @transaction = Puppet::Transaction.new(@catalog)
545
+ duplicate = generated.first
546
+ catalog.add_resource(duplicate)
551
547
 
552
- generator.expects(:generate).returns [resource]
548
+ duplicate.expects(:finish).never
553
549
 
554
- @catalog.expects(:add_resource).raises(Puppet::Resource::Catalog::DuplicateResourceError.new("foo"))
550
+ duplicate.expects(:info).with { |msg| msg =~ /Duplicate generated resource/ }
555
551
 
556
- resource.expects(:finish).never
557
- resource.expects(:info) # log that it's skipped
558
-
559
- @transaction.generate_additional_resources(generator)
552
+ transaction.add_dynamically_generated_resources
560
553
  end
561
554
 
562
555
  it "should copy all tags to the newly generated resources" do
563
- child = stub 'child', :ref => "Some[child_resource]"
564
- generator = stub 'resource', :tags => ["one", "two"], :ref => "Some[resource]"
565
-
566
- @catalog = Puppet::Resource::Catalog.new
567
- @transaction = Puppet::Transaction.new(@catalog)
568
-
569
- generator.stubs(:generate).returns [child]
570
- @catalog.stubs(:add_resource)
556
+ generator.tag('one', 'two')
571
557
 
572
- child.expects(:tag).with("one", "two")
573
- child.expects(:finish)
574
- generator.expects(:depthfirst?)
558
+ transaction.add_dynamically_generated_resources
575
559
 
576
- @transaction.generate_additional_resources(generator)
560
+ generated.each do |res|
561
+ res.should be_tagged(generator.tags)
562
+ end
577
563
  end
578
564
  end
579
565
 
@@ -21,7 +21,7 @@ describe Puppet::Type.type(:file).attrclass(:mode) do
21
21
  it "should not accept strings other than octal numbers" do
22
22
  expect do
23
23
  mode.value = 'readable please!'
24
- end.to raise_error(Puppet::Error, /File modes can only be octal numbers/)
24
+ end.to raise_error(Puppet::Error, /The file mode specification is invalid/)
25
25
  end
26
26
  end
27
27
 
@@ -156,8 +156,10 @@ describe Puppet::Type.type(:file).attrclass(:source) do
156
156
  @resource = Puppet::Type.type(:file).new :path => @foobar
157
157
 
158
158
  @source = source.new(:resource => @resource)
159
- @metadata = stub 'metadata', :owner => 100, :group => 200, :mode => 123, :checksum => "{md5}asdfasdf", :ftype => "file"
159
+ @metadata = stub 'metadata', :owner => 100, :group => 200, :mode => 123, :checksum => "{md5}asdfasdf", :ftype => "file", :source => @foobar
160
160
  @source.stubs(:metadata).returns @metadata
161
+
162
+ Puppet.features.stubs(:root?).returns true
161
163
  end
162
164
 
163
165
  it "should fail if there is no metadata" do
@@ -184,11 +186,10 @@ describe Puppet::Type.type(:file).attrclass(:source) do
184
186
  describe "and the source is a file" do
185
187
  before do
186
188
  @metadata.stubs(:ftype).returns "file"
189
+ Puppet.features.stubs(:microsoft_windows?).returns false
187
190
  end
188
191
 
189
192
  it "should copy the metadata's owner, group, checksum, and mode to the resource if they are not set on the resource" do
190
- Puppet.features.expects(:root?).returns true
191
-
192
193
  @source.copy_source_values
193
194
 
194
195
  @resource[:owner].must == 100
@@ -221,6 +222,30 @@ describe Puppet::Type.type(:file).attrclass(:source) do
221
222
  @resource[:owner].should be_nil
222
223
  end
223
224
  end
225
+
226
+ describe "on Windows" do
227
+ before :each do
228
+ Puppet.features.stubs(:microsoft_windows?).returns true
229
+ end
230
+
231
+ it "should not copy owner and group from remote sources" do
232
+ @source.stubs(:local?).returns false
233
+
234
+ @source.copy_source_values
235
+
236
+ @resource[:owner].must be_nil
237
+ @resource[:group].must be_nil
238
+ end
239
+
240
+ it "should copy owner and group from local sources" do
241
+ @source.stubs(:local?).returns true
242
+
243
+ @source.copy_source_values
244
+
245
+ @resource[:owner].must == 100
246
+ @resource[:group].must == 200
247
+ end
248
+ end
224
249
  end
225
250
 
226
251
  describe "and the source is a link" do
@@ -500,8 +500,9 @@ describe Puppet::Type.type(:file) do
500
500
  end
501
501
 
502
502
  it "should not copy values to the child which were set by the source" do
503
- file[:source] = File.expand_path(__FILE__)
504
- metadata = stub 'metadata', :owner => "root", :group => "root", :mode => 0755, :ftype => "file", :checksum => "{md5}whatever"
503
+ source = File.expand_path(__FILE__)
504
+ file[:source] = source
505
+ metadata = stub 'metadata', :owner => "root", :group => "root", :mode => 0755, :ftype => "file", :checksum => "{md5}whatever", :source => source
505
506
  file.parameter(:source).stubs(:metadata).returns metadata
506
507
 
507
508
  file.parameter(:source).copy_source_values
@@ -841,7 +842,7 @@ describe Puppet::Type.type(:file) do
841
842
  describe "and multiple sources are provided" do
842
843
  let(:sources) do
843
844
  h = {}
844
- %w{/one /two /three /four}.each do |key|
845
+ %w{/a /b /c /d}.each do |key|
845
846
  h[key] = URI.unescape(Puppet::Util.path_to_uri(File.expand_path(key)).to_s)
846
847
  end
847
848
  h
@@ -850,11 +851,11 @@ describe Puppet::Type.type(:file) do
850
851
  describe "and :sourceselect is set to :first" do
851
852
  it "should create file instances for the results for the first source to return any values" do
852
853
  data = Puppet::FileServing::Metadata.new("/whatever", :relative_path => "foobar")
853
- file[:source] = sources.keys.map { |key| File.expand_path(key) }
854
- file.expects(:perform_recursion).with(sources['/one']).returns nil
855
- file.expects(:perform_recursion).with(sources['/two']).returns []
856
- file.expects(:perform_recursion).with(sources['/three']).returns [data]
857
- file.expects(:perform_recursion).with(sources['/four']).never
854
+ file[:source] = sources.keys.sort.map { |key| File.expand_path(key) }
855
+ file.expects(:perform_recursion).with(sources['/a']).returns nil
856
+ file.expects(:perform_recursion).with(sources['/b']).returns []
857
+ file.expects(:perform_recursion).with(sources['/c']).returns [data]
858
+ file.expects(:perform_recursion).with(sources['/d']).never
858
859
  file.expects(:newchild).with("foobar").returns @resource
859
860
  file.recurse_remote({})
860
861
  end
@@ -867,22 +868,22 @@ describe Puppet::Type.type(:file) do
867
868
 
868
869
  it "should return every found file that is not in a previous source" do
869
870
  klass = Puppet::FileServing::Metadata
870
- file[:source] = %w{/one /two /three /four}.map {|f| File.expand_path(f) }
871
+ file[:source] = %w{/a /b /c /d}.map {|f| File.expand_path(f) }
871
872
  file.stubs(:newchild).returns @resource
872
873
 
873
- one = [klass.new("/one", :relative_path => "a")]
874
- file.expects(:perform_recursion).with(sources['/one']).returns one
874
+ one = [klass.new("/a", :relative_path => "a")]
875
+ file.expects(:perform_recursion).with(sources['/a']).returns one
875
876
  file.expects(:newchild).with("a").returns @resource
876
877
 
877
- two = [klass.new("/two", :relative_path => "a"), klass.new("/two", :relative_path => "b")]
878
- file.expects(:perform_recursion).with(sources['/two']).returns two
878
+ two = [klass.new("/b", :relative_path => "a"), klass.new("/b", :relative_path => "b")]
879
+ file.expects(:perform_recursion).with(sources['/b']).returns two
879
880
  file.expects(:newchild).with("b").returns @resource
880
881
 
881
- three = [klass.new("/three", :relative_path => "a"), klass.new("/three", :relative_path => "c")]
882
- file.expects(:perform_recursion).with(sources['/three']).returns three
882
+ three = [klass.new("/c", :relative_path => "a"), klass.new("/c", :relative_path => "c")]
883
+ file.expects(:perform_recursion).with(sources['/c']).returns three
883
884
  file.expects(:newchild).with("c").returns @resource
884
885
 
885
- file.expects(:perform_recursion).with(sources['/four']).returns []
886
+ file.expects(:perform_recursion).with(sources['/d']).returns []
886
887
 
887
888
  file.recurse_remote({})
888
889
  end
@@ -70,10 +70,537 @@ describe host do
70
70
  proc { @class.new(:name => "foo", :ip => '192.168.0.300') }.should raise_error
71
71
  end
72
72
 
73
+ it "should reject over-long IPv4 addresses" do
74
+ expect { @class.new(:name => "foo", :ip => '10.10.10.10.10') }.to raise_error
75
+ end
76
+
73
77
  it "should not accept malformed IP addresses like 2001:0dg8:85a3:08d3:1319:8a2e:0370:7344" do
74
78
  proc { @class.new(:name => "foo", :ip => '2001:0dg8:85a3:08d3:1319:8a2e:0370:7344') }.should raise_error
75
79
  end
76
80
 
81
+ # Assorted, annotated IPv6 passes.
82
+ ["::1", # loopback, compressed, non-routable
83
+ "::", # unspecified, compressed, non-routable
84
+ "0:0:0:0:0:0:0:1", # loopback, full
85
+ "0:0:0:0:0:0:0:0", # unspecified, full
86
+ "2001:DB8:0:0:8:800:200C:417A", # unicast, full
87
+ "FF01:0:0:0:0:0:0:101", # multicast, full
88
+ "2001:DB8::8:800:200C:417A", # unicast, compressed
89
+ "FF01::101", # multicast, compressed
90
+ # Some more test cases that should pass.
91
+ "2001:0000:1234:0000:0000:C1C0:ABCD:0876",
92
+ "3ffe:0b00:0000:0000:0001:0000:0000:000a",
93
+ "FF02:0000:0000:0000:0000:0000:0000:0001",
94
+ "0000:0000:0000:0000:0000:0000:0000:0001",
95
+ "0000:0000:0000:0000:0000:0000:0000:0000",
96
+ # Assorted valid, compressed IPv6 addresses.
97
+ "2::10",
98
+ "ff02::1",
99
+ "fe80::",
100
+ "2002::",
101
+ "2001:db8::",
102
+ "2001:0db8:1234::",
103
+ "::ffff:0:0",
104
+ "::1",
105
+ "1:2:3:4:5:6:7:8",
106
+ "1:2:3:4:5:6::8",
107
+ "1:2:3:4:5::8",
108
+ "1:2:3:4::8",
109
+ "1:2:3::8",
110
+ "1:2::8",
111
+ "1::8",
112
+ "1::2:3:4:5:6:7",
113
+ "1::2:3:4:5:6",
114
+ "1::2:3:4:5",
115
+ "1::2:3:4",
116
+ "1::2:3",
117
+ "1::8",
118
+ "::2:3:4:5:6:7:8",
119
+ "::2:3:4:5:6:7",
120
+ "::2:3:4:5:6",
121
+ "::2:3:4:5",
122
+ "::2:3:4",
123
+ "::2:3",
124
+ "::8",
125
+ "1:2:3:4:5:6::",
126
+ "1:2:3:4:5::",
127
+ "1:2:3:4::",
128
+ "1:2:3::",
129
+ "1:2::",
130
+ "1::",
131
+ "1:2:3:4:5::7:8",
132
+ "1:2:3:4::7:8",
133
+ "1:2:3::7:8",
134
+ "1:2::7:8",
135
+ "1::7:8",
136
+ # IPv4 addresses as dotted-quads
137
+ "1:2:3:4:5:6:1.2.3.4",
138
+ "1:2:3:4:5::1.2.3.4",
139
+ "1:2:3:4::1.2.3.4",
140
+ "1:2:3::1.2.3.4",
141
+ "1:2::1.2.3.4",
142
+ "1::1.2.3.4",
143
+ "1:2:3:4::5:1.2.3.4",
144
+ "1:2:3::5:1.2.3.4",
145
+ "1:2::5:1.2.3.4",
146
+ "1::5:1.2.3.4",
147
+ "1::5:11.22.33.44",
148
+ "fe80::217:f2ff:254.7.237.98",
149
+ "::ffff:192.168.1.26",
150
+ "::ffff:192.168.1.1",
151
+ "0:0:0:0:0:0:13.1.68.3", # IPv4-compatible IPv6 address, full, deprecated
152
+ "0:0:0:0:0:FFFF:129.144.52.38", # IPv4-mapped IPv6 address, full
153
+ "::13.1.68.3", # IPv4-compatible IPv6 address, compressed, deprecated
154
+ "::FFFF:129.144.52.38", # IPv4-mapped IPv6 address, compressed
155
+ "fe80:0:0:0:204:61ff:254.157.241.86",
156
+ "fe80::204:61ff:254.157.241.86",
157
+ "::ffff:12.34.56.78",
158
+ "::ffff:192.0.2.128", # this is OK, since there's a single zero digit in IPv4
159
+ "fe80:0000:0000:0000:0204:61ff:fe9d:f156",
160
+ "fe80:0:0:0:204:61ff:fe9d:f156",
161
+ "fe80::204:61ff:fe9d:f156",
162
+ "::1",
163
+ "fe80::",
164
+ "fe80::1",
165
+ "::ffff:c000:280",
166
+
167
+ # Additional test cases from http://rt.cpan.org/Public/Bug/Display.html?id=50693
168
+ "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
169
+ "2001:db8:85a3:0:0:8a2e:370:7334",
170
+ "2001:db8:85a3::8a2e:370:7334",
171
+ "2001:0db8:0000:0000:0000:0000:1428:57ab",
172
+ "2001:0db8:0000:0000:0000::1428:57ab",
173
+ "2001:0db8:0:0:0:0:1428:57ab",
174
+ "2001:0db8:0:0::1428:57ab",
175
+ "2001:0db8::1428:57ab",
176
+ "2001:db8::1428:57ab",
177
+ "0000:0000:0000:0000:0000:0000:0000:0001",
178
+ "::1",
179
+ "::ffff:0c22:384e",
180
+ "2001:0db8:1234:0000:0000:0000:0000:0000",
181
+ "2001:0db8:1234:ffff:ffff:ffff:ffff:ffff",
182
+ "2001:db8:a::123",
183
+ "fe80::",
184
+
185
+ "1111:2222:3333:4444:5555:6666:7777:8888",
186
+ "1111:2222:3333:4444:5555:6666:7777::",
187
+ "1111:2222:3333:4444:5555:6666::",
188
+ "1111:2222:3333:4444:5555::",
189
+ "1111:2222:3333:4444::",
190
+ "1111:2222:3333::",
191
+ "1111:2222::",
192
+ "1111::",
193
+ "1111:2222:3333:4444:5555:6666::8888",
194
+ "1111:2222:3333:4444:5555::8888",
195
+ "1111:2222:3333:4444::8888",
196
+ "1111:2222:3333::8888",
197
+ "1111:2222::8888",
198
+ "1111::8888",
199
+ "::8888",
200
+ "1111:2222:3333:4444:5555::7777:8888",
201
+ "1111:2222:3333:4444::7777:8888",
202
+ "1111:2222:3333::7777:8888",
203
+ "1111:2222::7777:8888",
204
+ "1111::7777:8888",
205
+ "::7777:8888",
206
+ "1111:2222:3333:4444::6666:7777:8888",
207
+ "1111:2222:3333::6666:7777:8888",
208
+ "1111:2222::6666:7777:8888",
209
+ "1111::6666:7777:8888",
210
+ "::6666:7777:8888",
211
+ "1111:2222:3333::5555:6666:7777:8888",
212
+ "1111:2222::5555:6666:7777:8888",
213
+ "1111::5555:6666:7777:8888",
214
+ "::5555:6666:7777:8888",
215
+ "1111:2222::4444:5555:6666:7777:8888",
216
+ "1111::4444:5555:6666:7777:8888",
217
+ "::4444:5555:6666:7777:8888",
218
+ "1111::3333:4444:5555:6666:7777:8888",
219
+ "::3333:4444:5555:6666:7777:8888",
220
+ "::2222:3333:4444:5555:6666:7777:8888",
221
+ "1111:2222:3333:4444:5555:6666:123.123.123.123",
222
+ "1111:2222:3333:4444:5555::123.123.123.123",
223
+ "1111:2222:3333:4444::123.123.123.123",
224
+ "1111:2222:3333::123.123.123.123",
225
+ "1111:2222::123.123.123.123",
226
+ "1111::123.123.123.123",
227
+ "::123.123.123.123",
228
+ "1111:2222:3333:4444::6666:123.123.123.123",
229
+ "1111:2222:3333::6666:123.123.123.123",
230
+ "1111:2222::6666:123.123.123.123",
231
+ "1111::6666:123.123.123.123",
232
+ "::6666:123.123.123.123",
233
+ "1111:2222:3333::5555:6666:123.123.123.123",
234
+ "1111:2222::5555:6666:123.123.123.123",
235
+ "1111::5555:6666:123.123.123.123",
236
+ "::5555:6666:123.123.123.123",
237
+ "1111:2222::4444:5555:6666:123.123.123.123",
238
+ "1111::4444:5555:6666:123.123.123.123",
239
+ "::4444:5555:6666:123.123.123.123",
240
+ "1111::3333:4444:5555:6666:123.123.123.123",
241
+ "::2222:3333:4444:5555:6666:123.123.123.123",
242
+
243
+ # Playing with combinations of "0" and "::"; these are all sytactically
244
+ # correct, but are bad form because "0" adjacent to "::" should be
245
+ # combined into "::"
246
+ "::0:0:0:0:0:0:0",
247
+ "::0:0:0:0:0:0",
248
+ "::0:0:0:0:0",
249
+ "::0:0:0:0",
250
+ "::0:0:0",
251
+ "::0:0",
252
+ "::0",
253
+ "0:0:0:0:0:0:0::",
254
+ "0:0:0:0:0:0::",
255
+ "0:0:0:0:0::",
256
+ "0:0:0:0::",
257
+ "0:0:0::",
258
+ "0:0::",
259
+ "0::",
260
+
261
+ # Additional cases: http://crisp.tweakblogs.net/blog/2031/ipv6-validation-%28and-caveats%29.html
262
+ "0:a:b:c:d:e:f::",
263
+ "::0:a:b:c:d:e:f", # syntactically correct, but bad form (::0:... could be combined)
264
+ "a:b:c:d:e:f:0::",
265
+ ].each do |ip|
266
+ it "should accept #{ip.inspect} as an IPv6 address" do
267
+ expect { @class.new(:name => "foo", :ip => ip) }.not_to raise_error
268
+ end
269
+ end
270
+
271
+ # ...aaaand, some failure cases.
272
+ [":",
273
+ "02001:0000:1234:0000:0000:C1C0:ABCD:0876", # extra 0 not allowed!
274
+ "2001:0000:1234:0000:00001:C1C0:ABCD:0876", # extra 0 not allowed!
275
+ "2001:0000:1234:0000:0000:C1C0:ABCD:0876 0", # junk after valid address
276
+ "2001:0000:1234: 0000:0000:C1C0:ABCD:0876", # internal space
277
+ "3ffe:0b00:0000:0001:0000:0000:000a", # seven segments
278
+ "FF02:0000:0000:0000:0000:0000:0000:0000:0001", # nine segments
279
+ "3ffe:b00::1::a", # double "::"
280
+ "::1111:2222:3333:4444:5555:6666::", # double "::"
281
+ "1:2:3::4:5::7:8", # Double "::"
282
+ "12345::6:7:8",
283
+ # IPv4 embedded, but bad...
284
+ "1::5:400.2.3.4", "1::5:260.2.3.4", "1::5:256.2.3.4", "1::5:1.256.3.4",
285
+ "1::5:1.2.256.4", "1::5:1.2.3.256", "1::5:300.2.3.4", "1::5:1.300.3.4",
286
+ "1::5:1.2.300.4", "1::5:1.2.3.300", "1::5:900.2.3.4", "1::5:1.900.3.4",
287
+ "1::5:1.2.900.4", "1::5:1.2.3.900", "1::5:300.300.300.300", "1::5:3000.30.30.30",
288
+ "1::400.2.3.4", "1::260.2.3.4", "1::256.2.3.4", "1::1.256.3.4",
289
+ "1::1.2.256.4", "1::1.2.3.256", "1::300.2.3.4", "1::1.300.3.4",
290
+ "1::1.2.300.4", "1::1.2.3.300", "1::900.2.3.4", "1::1.900.3.4",
291
+ "1::1.2.900.4", "1::1.2.3.900", "1::300.300.300.300", "1::3000.30.30.30",
292
+ "::400.2.3.4", "::260.2.3.4", "::256.2.3.4", "::1.256.3.4",
293
+ "::1.2.256.4", "::1.2.3.256", "::300.2.3.4", "::1.300.3.4",
294
+ "::1.2.300.4", "::1.2.3.300", "::900.2.3.4", "::1.900.3.4",
295
+ "::1.2.900.4", "::1.2.3.900", "::300.300.300.300", "::3000.30.30.30",
296
+ "2001:1:1:1:1:1:255Z255X255Y255", # garbage instead of "." in IPv4
297
+ "::ffff:192x168.1.26", # ditto
298
+ "::ffff:2.3.4",
299
+ "::ffff:257.1.2.3",
300
+ "1.2.3.4:1111:2222:3333:4444::5555",
301
+ "1.2.3.4:1111:2222:3333::5555",
302
+ "1.2.3.4:1111:2222::5555",
303
+ "1.2.3.4:1111::5555",
304
+ "1.2.3.4::5555",
305
+ "1.2.3.4::",
306
+
307
+ # Testing IPv4 addresses represented as dotted-quads Leading zero's in
308
+ # IPv4 addresses not allowed: some systems treat the leading "0" in
309
+ # ".086" as the start of an octal number Update: The BNF in RFC-3986
310
+ # explicitly defines the dec-octet (for IPv4 addresses) not to have a
311
+ # leading zero
312
+ "fe80:0000:0000:0000:0204:61ff:254.157.241.086",
313
+ "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4",
314
+ "1111:2222:3333:4444:5555:6666:00.00.00.00",
315
+ "1111:2222:3333:4444:5555:6666:000.000.000.000",
316
+ "1111:2222:3333:4444:5555:6666:256.256.256.256",
317
+
318
+ "1111:2222:3333:4444::5555:",
319
+ "1111:2222:3333::5555:",
320
+ "1111:2222::5555:",
321
+ "1111::5555:",
322
+ "::5555:",
323
+ ":::",
324
+ "1111:",
325
+ ":",
326
+
327
+ ":1111:2222:3333:4444::5555",
328
+ ":1111:2222:3333::5555",
329
+ ":1111:2222::5555",
330
+ ":1111::5555",
331
+ ":::5555",
332
+ ":::",
333
+
334
+ # Additional test cases from http://rt.cpan.org/Public/Bug/Display.html?id=50693
335
+ "123",
336
+ "ldkfj",
337
+ "2001::FFD3::57ab",
338
+ "2001:db8:85a3::8a2e:37023:7334",
339
+ "2001:db8:85a3::8a2e:370k:7334",
340
+ "1:2:3:4:5:6:7:8:9",
341
+ "1::2::3",
342
+ "1:::3:4:5",
343
+ "1:2:3::4:5:6:7:8:9",
344
+
345
+ # Invalid data
346
+ "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX",
347
+
348
+ # Too many components
349
+ "1111:2222:3333:4444:5555:6666:7777:8888:9999",
350
+ "1111:2222:3333:4444:5555:6666:7777:8888::",
351
+ "::2222:3333:4444:5555:6666:7777:8888:9999",
352
+
353
+ # Too few components
354
+ "1111:2222:3333:4444:5555:6666:7777",
355
+ "1111:2222:3333:4444:5555:6666",
356
+ "1111:2222:3333:4444:5555",
357
+ "1111:2222:3333:4444",
358
+ "1111:2222:3333",
359
+ "1111:2222",
360
+ "1111",
361
+
362
+ # Missing :
363
+ "11112222:3333:4444:5555:6666:7777:8888",
364
+ "1111:22223333:4444:5555:6666:7777:8888",
365
+ "1111:2222:33334444:5555:6666:7777:8888",
366
+ "1111:2222:3333:44445555:6666:7777:8888",
367
+ "1111:2222:3333:4444:55556666:7777:8888",
368
+ "1111:2222:3333:4444:5555:66667777:8888",
369
+ "1111:2222:3333:4444:5555:6666:77778888",
370
+
371
+ # Missing : intended for ::
372
+ "1111:2222:3333:4444:5555:6666:7777:8888:",
373
+ "1111:2222:3333:4444:5555:6666:7777:",
374
+ "1111:2222:3333:4444:5555:6666:",
375
+ "1111:2222:3333:4444:5555:",
376
+ "1111:2222:3333:4444:",
377
+ "1111:2222:3333:",
378
+ "1111:2222:",
379
+ "1111:",
380
+ ":",
381
+ ":8888",
382
+ ":7777:8888",
383
+ ":6666:7777:8888",
384
+ ":5555:6666:7777:8888",
385
+ ":4444:5555:6666:7777:8888",
386
+ ":3333:4444:5555:6666:7777:8888",
387
+ ":2222:3333:4444:5555:6666:7777:8888",
388
+ ":1111:2222:3333:4444:5555:6666:7777:8888",
389
+
390
+ # :::
391
+ ":::2222:3333:4444:5555:6666:7777:8888",
392
+ "1111:::3333:4444:5555:6666:7777:8888",
393
+ "1111:2222:::4444:5555:6666:7777:8888",
394
+ "1111:2222:3333:::5555:6666:7777:8888",
395
+ "1111:2222:3333:4444:::6666:7777:8888",
396
+ "1111:2222:3333:4444:5555:::7777:8888",
397
+ "1111:2222:3333:4444:5555:6666:::8888",
398
+ "1111:2222:3333:4444:5555:6666:7777:::",
399
+
400
+ # Double ::",
401
+ "::2222::4444:5555:6666:7777:8888",
402
+ "::2222:3333::5555:6666:7777:8888",
403
+ "::2222:3333:4444::6666:7777:8888",
404
+ "::2222:3333:4444:5555::7777:8888",
405
+ "::2222:3333:4444:5555:7777::8888",
406
+ "::2222:3333:4444:5555:7777:8888::",
407
+
408
+ "1111::3333::5555:6666:7777:8888",
409
+ "1111::3333:4444::6666:7777:8888",
410
+ "1111::3333:4444:5555::7777:8888",
411
+ "1111::3333:4444:5555:6666::8888",
412
+ "1111::3333:4444:5555:6666:7777::",
413
+
414
+ "1111:2222::4444::6666:7777:8888",
415
+ "1111:2222::4444:5555::7777:8888",
416
+ "1111:2222::4444:5555:6666::8888",
417
+ "1111:2222::4444:5555:6666:7777::",
418
+
419
+ "1111:2222:3333::5555::7777:8888",
420
+ "1111:2222:3333::5555:6666::8888",
421
+ "1111:2222:3333::5555:6666:7777::",
422
+
423
+ "1111:2222:3333:4444::6666::8888",
424
+ "1111:2222:3333:4444::6666:7777::",
425
+
426
+ "1111:2222:3333:4444:5555::7777::",
427
+
428
+
429
+ # Too many components"
430
+ "1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4",
431
+ "1111:2222:3333:4444:5555:6666:7777:1.2.3.4",
432
+ "1111:2222:3333:4444:5555:6666::1.2.3.4",
433
+ "::2222:3333:4444:5555:6666:7777:1.2.3.4",
434
+ "1111:2222:3333:4444:5555:6666:1.2.3.4.5",
435
+
436
+ # Too few components
437
+ "1111:2222:3333:4444:5555:1.2.3.4",
438
+ "1111:2222:3333:4444:1.2.3.4",
439
+ "1111:2222:3333:1.2.3.4",
440
+ "1111:2222:1.2.3.4",
441
+ "1111:1.2.3.4",
442
+
443
+ # Missing :
444
+ "11112222:3333:4444:5555:6666:1.2.3.4",
445
+ "1111:22223333:4444:5555:6666:1.2.3.4",
446
+ "1111:2222:33334444:5555:6666:1.2.3.4",
447
+ "1111:2222:3333:44445555:6666:1.2.3.4",
448
+ "1111:2222:3333:4444:55556666:1.2.3.4",
449
+ "1111:2222:3333:4444:5555:66661.2.3.4",
450
+
451
+ # Missing .
452
+ "1111:2222:3333:4444:5555:6666:255255.255.255",
453
+ "1111:2222:3333:4444:5555:6666:255.255255.255",
454
+ "1111:2222:3333:4444:5555:6666:255.255.255255",
455
+
456
+ # Missing : intended for ::
457
+ ":1.2.3.4",
458
+ ":6666:1.2.3.4",
459
+ ":5555:6666:1.2.3.4",
460
+ ":4444:5555:6666:1.2.3.4",
461
+ ":3333:4444:5555:6666:1.2.3.4",
462
+ ":2222:3333:4444:5555:6666:1.2.3.4",
463
+ ":1111:2222:3333:4444:5555:6666:1.2.3.4",
464
+
465
+ # :::
466
+ ":::2222:3333:4444:5555:6666:1.2.3.4",
467
+ "1111:::3333:4444:5555:6666:1.2.3.4",
468
+ "1111:2222:::4444:5555:6666:1.2.3.4",
469
+ "1111:2222:3333:::5555:6666:1.2.3.4",
470
+ "1111:2222:3333:4444:::6666:1.2.3.4",
471
+ "1111:2222:3333:4444:5555:::1.2.3.4",
472
+
473
+ # Double ::
474
+ "::2222::4444:5555:6666:1.2.3.4",
475
+ "::2222:3333::5555:6666:1.2.3.4",
476
+ "::2222:3333:4444::6666:1.2.3.4",
477
+ "::2222:3333:4444:5555::1.2.3.4",
478
+
479
+ "1111::3333::5555:6666:1.2.3.4",
480
+ "1111::3333:4444::6666:1.2.3.4",
481
+ "1111::3333:4444:5555::1.2.3.4",
482
+
483
+ "1111:2222::4444::6666:1.2.3.4",
484
+ "1111:2222::4444:5555::1.2.3.4",
485
+
486
+ "1111:2222:3333::5555::1.2.3.4",
487
+
488
+ # Missing parts
489
+ "::.",
490
+ "::..",
491
+ "::...",
492
+ "::1...",
493
+ "::1.2..",
494
+ "::1.2.3.",
495
+ "::.2..",
496
+ "::.2.3.",
497
+ "::.2.3.4",
498
+ "::..3.",
499
+ "::..3.4",
500
+ "::...4",
501
+
502
+ # Extra : in front
503
+ ":1111:2222:3333:4444:5555:6666:7777::",
504
+ ":1111:2222:3333:4444:5555:6666::",
505
+ ":1111:2222:3333:4444:5555::",
506
+ ":1111:2222:3333:4444::",
507
+ ":1111:2222:3333::",
508
+ ":1111:2222::",
509
+ ":1111::",
510
+ ":::",
511
+ ":1111:2222:3333:4444:5555:6666::8888",
512
+ ":1111:2222:3333:4444:5555::8888",
513
+ ":1111:2222:3333:4444::8888",
514
+ ":1111:2222:3333::8888",
515
+ ":1111:2222::8888",
516
+ ":1111::8888",
517
+ ":::8888",
518
+ ":1111:2222:3333:4444:5555::7777:8888",
519
+ ":1111:2222:3333:4444::7777:8888",
520
+ ":1111:2222:3333::7777:8888",
521
+ ":1111:2222::7777:8888",
522
+ ":1111::7777:8888",
523
+ ":::7777:8888",
524
+ ":1111:2222:3333:4444::6666:7777:8888",
525
+ ":1111:2222:3333::6666:7777:8888",
526
+ ":1111:2222::6666:7777:8888",
527
+ ":1111::6666:7777:8888",
528
+ ":::6666:7777:8888",
529
+ ":1111:2222:3333::5555:6666:7777:8888",
530
+ ":1111:2222::5555:6666:7777:8888",
531
+ ":1111::5555:6666:7777:8888",
532
+ ":::5555:6666:7777:8888",
533
+ ":1111:2222::4444:5555:6666:7777:8888",
534
+ ":1111::4444:5555:6666:7777:8888",
535
+ ":::4444:5555:6666:7777:8888",
536
+ ":1111::3333:4444:5555:6666:7777:8888",
537
+ ":::3333:4444:5555:6666:7777:8888",
538
+ ":::2222:3333:4444:5555:6666:7777:8888",
539
+ ":1111:2222:3333:4444:5555:6666:1.2.3.4",
540
+ ":1111:2222:3333:4444:5555::1.2.3.4",
541
+ ":1111:2222:3333:4444::1.2.3.4",
542
+ ":1111:2222:3333::1.2.3.4",
543
+ ":1111:2222::1.2.3.4",
544
+ ":1111::1.2.3.4",
545
+ ":::1.2.3.4",
546
+ ":1111:2222:3333:4444::6666:1.2.3.4",
547
+ ":1111:2222:3333::6666:1.2.3.4",
548
+ ":1111:2222::6666:1.2.3.4",
549
+ ":1111::6666:1.2.3.4",
550
+ ":::6666:1.2.3.4",
551
+ ":1111:2222:3333::5555:6666:1.2.3.4",
552
+ ":1111:2222::5555:6666:1.2.3.4",
553
+ ":1111::5555:6666:1.2.3.4",
554
+ ":::5555:6666:1.2.3.4",
555
+ ":1111:2222::4444:5555:6666:1.2.3.4",
556
+ ":1111::4444:5555:6666:1.2.3.4",
557
+ ":::4444:5555:6666:1.2.3.4",
558
+ ":1111::3333:4444:5555:6666:1.2.3.4",
559
+ ":::2222:3333:4444:5555:6666:1.2.3.4",
560
+
561
+ # Extra : at end
562
+ "1111:2222:3333:4444:5555:6666:7777:::",
563
+ "1111:2222:3333:4444:5555:6666:::",
564
+ "1111:2222:3333:4444:5555:::",
565
+ "1111:2222:3333:4444:::",
566
+ "1111:2222:3333:::",
567
+ "1111:2222:::",
568
+ "1111:::",
569
+ ":::",
570
+ "1111:2222:3333:4444:5555:6666::8888:",
571
+ "1111:2222:3333:4444:5555::8888:",
572
+ "1111:2222:3333:4444::8888:",
573
+ "1111:2222:3333::8888:",
574
+ "1111:2222::8888:",
575
+ "1111::8888:",
576
+ "::8888:",
577
+ "1111:2222:3333:4444:5555::7777:8888:",
578
+ "1111:2222:3333:4444::7777:8888:",
579
+ "1111:2222:3333::7777:8888:",
580
+ "1111:2222::7777:8888:",
581
+ "1111::7777:8888:",
582
+ "::7777:8888:",
583
+ "1111:2222:3333:4444::6666:7777:8888:",
584
+ "1111:2222:3333::6666:7777:8888:",
585
+ "1111:2222::6666:7777:8888:",
586
+ "1111::6666:7777:8888:",
587
+ "::6666:7777:8888:",
588
+ "1111:2222:3333::5555:6666:7777:8888:",
589
+ "1111:2222::5555:6666:7777:8888:",
590
+ "1111::5555:6666:7777:8888:",
591
+ "::5555:6666:7777:8888:",
592
+ "1111:2222::4444:5555:6666:7777:8888:",
593
+ "1111::4444:5555:6666:7777:8888:",
594
+ "::4444:5555:6666:7777:8888:",
595
+ "1111::3333:4444:5555:6666:7777:8888:",
596
+ "::3333:4444:5555:6666:7777:8888:",
597
+ "::2222:3333:4444:5555:6666:7777:8888:",
598
+ ].each do |ip|
599
+ it "should reject #{ip.inspect} as an IPv6 address" do
600
+ expect { @class.new(:name => "foo", :ip => ip) }.to raise_error
601
+ end
602
+ end
603
+
77
604
  it "should not accept spaces in resourcename" do
78
605
  proc { @class.new(:name => "foo bar") }.should raise_error
79
606
  end