puppet 0.25.1 → 0.25.2

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 (198) hide show
  1. data/CHANGELOG +159 -135
  2. data/Rakefile +4 -1
  3. data/conf/gentoo/conf.d/puppetmaster +1 -1
  4. data/conf/osx/createpackage.sh +12 -0
  5. data/conf/osx/preflight +4 -0
  6. data/conf/redhat/puppet.spec +12 -2
  7. data/conf/redhat/server.init +1 -0
  8. data/conf/redhat/server.sysconfig +1 -1
  9. data/ext/ldap/puppet.schema +5 -9
  10. data/ext/puppetlast +2 -1
  11. data/ext/rack/README +2 -2
  12. data/ext/regexp_nodes/classes/databases +2 -0
  13. data/ext/regexp_nodes/classes/webservers +2 -0
  14. data/ext/regexp_nodes/parameters/environment/prod +1 -0
  15. data/ext/regexp_nodes/parameters/environment/qa +3 -0
  16. data/ext/regexp_nodes/regexp_nodes.rb +215 -0
  17. data/lib/puppet.rb +1 -1
  18. data/lib/puppet/agent.rb +2 -2
  19. data/lib/puppet/application/puppet.rb +1 -1
  20. data/lib/puppet/application/puppetd.rb +1 -1
  21. data/lib/puppet/application/puppetdoc.rb +4 -3
  22. data/lib/puppet/application/puppetrun.rb +5 -14
  23. data/lib/puppet/application/ralsh.rb +9 -25
  24. data/lib/puppet/configurer.rb +2 -1
  25. data/lib/puppet/configurer/fact_handler.rb +8 -6
  26. data/lib/puppet/daemon.rb +2 -2
  27. data/lib/puppet/defaults.rb +21 -2
  28. data/lib/puppet/external/pson/common.rb +1 -1
  29. data/lib/puppet/external/pson/pure.rb +3 -3
  30. data/lib/puppet/feature/base.rb +3 -0
  31. data/lib/puppet/feature/selinux.rb +3 -0
  32. data/lib/puppet/feature/zlib.rb +6 -0
  33. data/lib/puppet/file_serving/base.rb +16 -1
  34. data/lib/puppet/file_serving/metadata.rb +46 -9
  35. data/lib/puppet/file_serving/mount/file.rb +4 -1
  36. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  37. data/lib/puppet/indirector/envelope.rb +1 -3
  38. data/lib/puppet/indirector/indirection.rb +13 -16
  39. data/lib/puppet/indirector/node/ldap.rb +7 -4
  40. data/lib/puppet/indirector/ssl_file.rb +1 -1
  41. data/lib/puppet/network/authstore.rb +48 -118
  42. data/lib/puppet/network/client/resource.rb +2 -15
  43. data/lib/puppet/network/format.rb +2 -12
  44. data/lib/puppet/network/format_handler.rb +15 -1
  45. data/lib/puppet/network/formats.rb +19 -4
  46. data/lib/puppet/network/handler/fileserver.rb +1 -0
  47. data/lib/puppet/network/http/handler.rb +1 -0
  48. data/lib/puppet/network/http/rack/httphandler.rb +0 -18
  49. data/lib/puppet/network/http/rack/rest.rb +4 -4
  50. data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
  51. data/lib/puppet/network/http/webrick.rb +2 -1
  52. data/lib/puppet/network/server.rb +1 -1
  53. data/lib/puppet/node/environment.rb +20 -9
  54. data/lib/puppet/parameter.rb +17 -1
  55. data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
  56. data/lib/puppet/parser/ast/leaf.rb +5 -1
  57. data/lib/puppet/parser/ast/resourceparam.rb +4 -0
  58. data/lib/puppet/parser/ast/selector.rb +4 -0
  59. data/lib/puppet/parser/functions/generate.rb +2 -2
  60. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  61. data/lib/puppet/property.rb +3 -11
  62. data/lib/puppet/provider/cron/crontab.rb +2 -0
  63. data/lib/puppet/provider/host/parsed.rb +9 -9
  64. data/lib/puppet/provider/package/blastwave.rb +7 -6
  65. data/lib/puppet/provider/package/portage.rb +23 -27
  66. data/lib/puppet/provider/package/rug.rb +1 -1
  67. data/lib/puppet/provider/package/sun.rb +5 -3
  68. data/lib/puppet/provider/service/daemontools.rb +1 -1
  69. data/lib/puppet/provider/service/debian.rb +1 -1
  70. data/lib/puppet/provider/service/runit.rb +1 -1
  71. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
  72. data/lib/puppet/provider/sshkey/parsed.rb +3 -5
  73. data/lib/puppet/provider/zone/solaris.rb +1 -1
  74. data/lib/puppet/rails.rb +9 -2
  75. data/lib/puppet/rails/benchmark.rb +1 -1
  76. data/lib/puppet/rails/host.rb +2 -7
  77. data/lib/puppet/rails/resource.rb +20 -26
  78. data/lib/puppet/resource/catalog.rb +3 -3
  79. data/lib/puppet/resource/reference.rb +13 -25
  80. data/lib/puppet/ssl/certificate.rb +3 -2
  81. data/lib/puppet/ssl/host.rb +14 -33
  82. data/lib/puppet/sslcertificates.rb +1 -5
  83. data/lib/puppet/sslcertificates/ca.rb +8 -7
  84. data/lib/puppet/transaction.rb +15 -12
  85. data/lib/puppet/type.rb +12 -5
  86. data/lib/puppet/type/file.rb +26 -32
  87. data/lib/puppet/type/file/content.rb +5 -5
  88. data/lib/puppet/type/file/ensure.rb +6 -17
  89. data/lib/puppet/type/file/mode.rb +18 -1
  90. data/lib/puppet/type/file/source.rb +12 -12
  91. data/lib/puppet/type/host.rb +6 -9
  92. data/lib/puppet/type/k5login.rb +1 -1
  93. data/lib/puppet/type/maillist.rb +4 -7
  94. data/lib/puppet/type/port.rb +6 -5
  95. data/lib/puppet/type/resources.rb +12 -12
  96. data/lib/puppet/type/sshkey.rb +5 -5
  97. data/lib/puppet/type/tidy.rb +9 -2
  98. data/lib/puppet/type/yumrepo.rb +3 -1
  99. data/lib/puppet/util.rb +64 -56
  100. data/lib/puppet/util/backups.rb +2 -1
  101. data/lib/puppet/util/filetype.rb +46 -0
  102. data/lib/puppet/util/log.rb +10 -18
  103. data/lib/puppet/util/log_paths.rb +14 -0
  104. data/lib/puppet/util/methodhelper.rb +3 -4
  105. data/lib/puppet/util/monkey_patches.rb +8 -0
  106. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
  107. data/lib/puppet/util/rdoc/parser.rb +32 -16
  108. data/lib/puppet/util/reference.rb +6 -3
  109. data/lib/puppet/util/selinux.rb +21 -14
  110. data/lib/puppet/util/settings.rb +30 -25
  111. data/lib/puppet/util/settings/file_setting.rb +7 -4
  112. data/lib/puppet/util/subclass_loader.rb +1 -1
  113. data/lib/puppet/util/suidmanager.rb +11 -1
  114. data/lib/puppet/util/tagging.rb +22 -4
  115. data/man/man8/filebucket.8 +23 -18
  116. data/man/man8/pi.8 +42 -20
  117. data/man/man8/puppet.8 +47 -32
  118. data/man/man8/puppet.conf.8 +807 -764
  119. data/man/man8/puppetca.8 +24 -14
  120. data/man/man8/puppetd.8 +33 -16
  121. data/man/man8/puppetdoc.8 +71 -18
  122. data/man/man8/puppetmasterd.8 +18 -25
  123. data/man/man8/puppetqd.8 +60 -0
  124. data/man/man8/puppetrun.8 +27 -14
  125. data/man/man8/ralsh.8 +33 -40
  126. data/spec/integration/bin/puppetmasterd.rb +3 -2
  127. data/spec/integration/defaults.rb +11 -0
  128. data/spec/integration/file_serving/metadata.rb +1 -0
  129. data/spec/integration/indirector/file_content/file_server.rb +2 -1
  130. data/spec/integration/ssl/certificate_request.rb +2 -0
  131. data/spec/integration/type/file.rb +20 -1
  132. data/spec/shared_behaviours/file_serving.rb +1 -1
  133. data/spec/spec_helper.rb +1 -1
  134. data/spec/unit/application/puppet.rb +11 -30
  135. data/spec/unit/application/puppetd.rb +1 -0
  136. data/spec/unit/application/puppetdoc.rb +13 -4
  137. data/spec/unit/application/puppetmasterd.rb +1 -0
  138. data/spec/unit/application/puppetrun.rb +12 -2
  139. data/spec/unit/application/ralsh.rb +39 -22
  140. data/spec/unit/configurer.rb +6 -0
  141. data/spec/unit/configurer/fact_handler.rb +15 -1
  142. data/spec/unit/file_serving/metadata.rb +128 -16
  143. data/spec/unit/file_serving/mount/file.rb +8 -0
  144. data/spec/unit/indirector/catalog/active_record.rb +20 -1
  145. data/spec/unit/indirector/catalog/compiler.rb +2 -1
  146. data/spec/unit/indirector/indirection.rb +29 -18
  147. data/spec/unit/indirector/node/ldap.rb +20 -6
  148. data/spec/unit/network/authstore.rb +197 -0
  149. data/spec/unit/network/format_handler.rb +28 -8
  150. data/spec/unit/network/formats.rb +31 -0
  151. data/spec/unit/network/http/handler.rb +10 -0
  152. data/spec/unit/network/http/webrick.rb +2 -2
  153. data/spec/unit/network/rest_authconfig.rb +2 -2
  154. data/spec/unit/network/rights.rb +1 -1
  155. data/spec/unit/node/environment.rb +39 -23
  156. data/spec/unit/other/selinux.rb +2 -2
  157. data/spec/unit/parameter.rb +8 -0
  158. data/spec/unit/parser/ast/leaf.rb +9 -0
  159. data/spec/unit/parser/ast/selector.rb +8 -1
  160. data/spec/unit/parser/lexer.rb +1 -1
  161. data/spec/unit/parser/resource.rb +11 -0
  162. data/spec/unit/parser/resource/reference.rb +13 -1
  163. data/spec/unit/property.rb +6 -0
  164. data/spec/unit/provider/mount/parsed.rb +3 -1
  165. data/spec/unit/provider/service/debian.rb +1 -1
  166. data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
  167. data/spec/unit/provider/sshkey/parsed.rb +19 -0
  168. data/spec/unit/rails.rb +22 -9
  169. data/spec/unit/rails/resource.rb +20 -0
  170. data/spec/unit/ssl/host.rb +19 -57
  171. data/spec/unit/transaction.rb +39 -4
  172. data/spec/unit/type.rb +9 -0
  173. data/spec/unit/type/file/content.rb +29 -0
  174. data/spec/unit/type/maillist.rb +42 -0
  175. data/spec/unit/type/resources.rb +66 -1
  176. data/spec/unit/type/tidy.rb +14 -1
  177. data/spec/unit/util/autoload.rb +2 -0
  178. data/spec/unit/util/ldap/connection.rb +1 -1
  179. data/spec/unit/util/log.rb +14 -0
  180. data/spec/unit/util/monkey_patches.rb +103 -0
  181. data/spec/unit/util/queue.rb +10 -2
  182. data/spec/unit/util/selinux.rb +61 -2
  183. data/spec/unit/util/settings.rb +19 -0
  184. data/spec/unit/util/settings/file_setting.rb +25 -0
  185. data/spec/unit/util/tagging.rb +10 -0
  186. data/tasks/rake/changelog.rake +15 -0
  187. data/tasks/rake/ci.rake +22 -0
  188. data/tasks/rake/dailybuild.rake +9 -0
  189. data/tasks/rake/gem.rake +46 -0
  190. data/tasks/rake/git_workflow.rake +121 -0
  191. data/tasks/rake/metrics.rake +6 -0
  192. data/tasks/rake/sign.rake +14 -0
  193. data/tasks/rake/testbranch.rake +16 -0
  194. data/tasks/rake/tracdocs.rake +8 -0
  195. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
  196. metadata +1042 -1288
  197. data/ext/bin/sleeper +0 -67
  198. data/ext/module_puppet +0 -209
@@ -61,7 +61,7 @@ describe Puppet::Resource::Catalog::Compiler do
61
61
  describe "when finding catalogs" do
62
62
  before do
63
63
  Facter.stubs(:value).returns("whatever")
64
- env = stub 'environment', :name => "yay"
64
+ env = stub 'environment', :name => "yay", :modulepath => []
65
65
  Puppet::Node::Environment.stubs(:new).returns(env)
66
66
 
67
67
  @compiler = Puppet::Resource::Catalog::Compiler.new
@@ -111,6 +111,7 @@ describe Puppet::Resource::Catalog::Compiler do
111
111
  end
112
112
 
113
113
  it "should extract and save any facts from the request" do
114
+ Puppet::Node.expects(:find).with(@name).returns @node
114
115
  @compiler.expects(:extract_facts_from_request).with(@request)
115
116
  @compiler.interpreter.stubs(:compile)
116
117
  @compiler.find(@request)
@@ -536,7 +536,7 @@ describe Puppet::Indirector::Indirection do
536
536
  @indirection.expire("/my/key")
537
537
  end
538
538
 
539
- it "should log that it is expiring any found instance" do
539
+ it "should log when expiring a found instance" do
540
540
  @cache.expects(:find).returns @cached
541
541
  @cache.stubs(:save)
542
542
 
@@ -545,33 +545,44 @@ describe Puppet::Indirector::Indirection do
545
545
  @indirection.expire("/my/key")
546
546
  end
547
547
 
548
- it "should set the cached instance's expiration to a time in the past" do
549
- @cache.expects(:find).returns @cached
550
- @cache.stubs(:save)
548
+ describe "and the terminus supports removal of cache items with destroy" do
549
+ it "should destroy the cached instance" do
550
+ @cache.expects(:find).returns @cached
551
+ @cache.expects(:destroy).with { |r| r.method == :destroy and r.key == "/my/key" }
552
+ @cache.expects(:save).never
553
+ @indirection.expire("/my/key")
554
+ end
555
+ end
551
556
 
552
- @cached.expects(:expiration=).with { |t| t < Time.now }
557
+ describe "and the terminus does not support removal of cache items with destroy" do
558
+ it "should set the cached instance's expiration to a time in the past" do
559
+ @cache.expects(:find).returns @cached
560
+ @cache.stubs(:save)
553
561
 
554
- @indirection.expire("/my/key")
555
- end
562
+ @cached.expects(:expiration=).with { |t| t < Time.now }
556
563
 
557
- it "should save the now expired instance back into the cache" do
558
- @cache.expects(:find).returns @cached
564
+ @indirection.expire("/my/key")
565
+ end
559
566
 
560
- @cached.expects(:expiration=).with { |t| t < Time.now }
567
+ it "should save the now expired instance back into the cache" do
568
+ @cache.expects(:find).returns @cached
561
569
 
562
- @cache.expects(:save)
570
+ @cached.expects(:expiration=).with { |t| t < Time.now }
563
571
 
564
- @indirection.expire("/my/key")
565
- end
572
+ @cache.expects(:save)
566
573
 
567
- it "should use a request to save the expired resource to the cache" do
568
- @cache.expects(:find).returns @cached
574
+ @indirection.expire("/my/key")
575
+ end
569
576
 
570
- @cached.expects(:expiration=).with { |t| t < Time.now }
577
+ it "should use a request to save the expired resource to the cache" do
578
+ @cache.expects(:find).returns @cached
571
579
 
572
- @cache.expects(:save).with { |r| r.is_a?(Puppet::Indirector::Request) and r.instance == @cached and r.method == :save }.returns(@cached)
580
+ @cached.expects(:expiration=).with { |t| t < Time.now }
573
581
 
574
- @indirection.expire("/my/key")
582
+ @cache.expects(:save).with { |r| r.is_a?(Puppet::Indirector::Request) and r.instance == @cached and r.method == :save }.returns(@cached)
583
+
584
+ @indirection.expire("/my/key")
585
+ end
575
586
  end
576
587
  end
577
588
  end
@@ -38,7 +38,7 @@ describe Puppet::Node::Ldap do
38
38
  # This heavily tests our entry2hash method, so we don't have to stub out the stupid entry information any more.
39
39
  describe "when an ldap entry is found" do
40
40
  before do
41
- @entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
41
+ @entry = stub 'entry', :dn => 'cn=mynode,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
42
42
  @searcher.stubs(:ldapsearch).yields @entry
43
43
  end
44
44
 
@@ -46,8 +46,12 @@ describe Puppet::Node::Ldap do
46
46
  @searcher.entry2hash(@entry).should be_instance_of(Hash)
47
47
  end
48
48
 
49
- it "should add the entry's common name to the hash" do
50
- @searcher.entry2hash(@entry)[:name].should == "mynode.domain.com"
49
+ it "should add the entry's common name to the hash if fqdn if false" do
50
+ @searcher.entry2hash(@entry,fqdn = false)[:name].should == "mynode"
51
+ end
52
+
53
+ it "should add the entry's fqdn name to the hash if fqdn if true" do
54
+ @searcher.entry2hash(@entry,fqdn = true)[:name].should == "mynode.madstop.com"
51
55
  end
52
56
 
53
57
  it "should add all of the entry's classes to the hash" do
@@ -341,13 +345,13 @@ describe Puppet::Node::Ldap do
341
345
  it "should process each found entry" do
342
346
  # .yields can't be used to yield multiple values :/
343
347
  @searcher.expects(:ldapsearch).yields("one")
344
- @searcher.expects(:entry2hash).with("one").returns(:name => "foo")
348
+ @searcher.expects(:entry2hash).with("one",nil).returns(:name => "foo")
345
349
  @searcher.search @request
346
350
  end
347
351
 
348
352
  it "should return a node for each processed entry with the name from the entry" do
349
353
  @searcher.expects(:ldapsearch).yields("whatever")
350
- @searcher.expects(:entry2hash).with("whatever").returns(:name => "foo")
354
+ @searcher.expects(:entry2hash).with("whatever",nil).returns(:name => "foo")
351
355
  result = @searcher.search(@request)
352
356
  result[0].should be_instance_of(Puppet::Node)
353
357
  result[0].name.should == "foo"
@@ -358,7 +362,17 @@ describe Puppet::Node::Ldap do
358
362
  Puppet::Node.expects(:new).with("foo").returns node
359
363
  node.expects(:fact_merge)
360
364
  @searcher.stubs(:ldapsearch).yields("one")
361
- @searcher.stubs(:entry2hash).with("one").returns(:name => "foo")
365
+ @searcher.stubs(:entry2hash).with("one",nil).returns(:name => "foo")
366
+ @searcher.search(@request)
367
+ end
368
+
369
+ it "should pass the request's fqdn option to entry2hash" do
370
+ node = mock 'node'
371
+ @options[:fqdn] = :hello
372
+ Puppet::Node.stubs(:new).with("foo").returns node
373
+ node.stubs(:fact_merge)
374
+ @searcher.stubs(:ldapsearch).yields("one")
375
+ @searcher.expects(:entry2hash).with("one",:hello).returns(:name => "foo")
362
376
  @searcher.search(@request)
363
377
  end
364
378
  end
@@ -83,6 +83,181 @@ describe Puppet::Network::AuthStore::Declaration do
83
83
  end
84
84
  end
85
85
 
86
+ [
87
+ "02001:0000:1234:0000:0000:C1C0:ABCD:0876",
88
+ "2001:0000:1234:0000:00001:C1C0:ABCD:0876",
89
+ " 2001:0000:1234:0000:0000:C1C0:ABCD:0876  0",
90
+ "2001:0000:1234: 0000:0000:C1C0:ABCD:0876",
91
+ "3ffe:0b00:0000:0001:0000:0000:000a",
92
+ "FF02:0000:0000:0000:0000:0000:0000:0000:0001",
93
+ "3ffe:b00::1::a",
94
+ "1:2:3::4:5::7:8",
95
+ "12345::6:7:8",
96
+ "1::5:400.2.3.4",
97
+ "1::5:260.2.3.4",
98
+ "1::5:256.2.3.4",
99
+ "1::5:1.256.3.4",
100
+ "1::5:1.2.256.4",
101
+ "1::5:1.2.3.256",
102
+ "1::5:300.2.3.4",
103
+ "1::5:1.300.3.4",
104
+ "1::5:1.2.300.4",
105
+ "1::5:1.2.3.300",
106
+ "1::5:900.2.3.4",
107
+ "1::5:1.900.3.4",
108
+ "1::5:1.2.900.4",
109
+ "1::5:1.2.3.900",
110
+ "1::5:300.300.300.300",
111
+ "1::5:3000.30.30.30",
112
+ "1::400.2.3.4",
113
+ "1::260.2.3.4",
114
+ "1::256.2.3.4",
115
+ "1::1.256.3.4",
116
+ "1::1.2.256.4",
117
+ "1::1.2.3.256",
118
+ "1::300.2.3.4",
119
+ "1::1.300.3.4",
120
+ "1::1.2.300.4",
121
+ "1::1.2.3.300",
122
+ "1::900.2.3.4",
123
+ "1::1.900.3.4",
124
+ "1::1.2.900.4",
125
+ "1::1.2.3.900",
126
+ "1::300.300.300.300",
127
+ "1::3000.30.30.30",
128
+ "::400.2.3.4",
129
+ "::260.2.3.4",
130
+ "::256.2.3.4",
131
+ "::1.256.3.4",
132
+ "::1.2.256.4",
133
+ "::1.2.3.256",
134
+ "::300.2.3.4",
135
+ "::1.300.3.4",
136
+ "::1.2.300.4",
137
+ "::1.2.3.300",
138
+ "::900.2.3.4",
139
+ "::1.900.3.4",
140
+ "::1.2.900.4",
141
+ "::1.2.3.900",
142
+ "::300.300.300.300",
143
+ "::3000.30.30.30",
144
+ "2001:DB8:0:0:8:800:200C:417A:221", # unicast, full
145
+ "FF01::101::2" # multicast, compressed
146
+ ].each { |invalid_ip|
147
+ describe "when the pattern is an invalid IPv6 address such as #{invalid_ip}" do
148
+ it "should raise an exception" do
149
+ lambda { Puppet::Network::AuthStore::Declaration.new(:allow,invalid_ip) }.should raise_error
150
+ end
151
+ end
152
+ }
153
+
154
+ [
155
+ "1.2.3.4",
156
+ "2001:0000:1234:0000:0000:C1C0:ABCD:0876",
157
+ "3ffe:0b00:0000:0000:0001:0000:0000:000a",
158
+ "FF02:0000:0000:0000:0000:0000:0000:0001",
159
+ "0000:0000:0000:0000:0000:0000:0000:0001",
160
+ "0000:0000:0000:0000:0000:0000:0000:0000",
161
+ "::ffff:192.168.1.26",
162
+ "2::10",
163
+ "ff02::1",
164
+ "fe80::",
165
+ "2002::",
166
+ "2001:db8::",
167
+ "2001:0db8:1234::",
168
+ "::ffff:0:0",
169
+ "::1",
170
+ "::ffff:192.168.1.1",
171
+ "1:2:3:4:5:6:7:8",
172
+ "1:2:3:4:5:6::8",
173
+ "1:2:3:4:5::8",
174
+ "1:2:3:4::8",
175
+ "1:2:3::8",
176
+ "1:2::8",
177
+ "1::8",
178
+ "1::2:3:4:5:6:7",
179
+ "1::2:3:4:5:6",
180
+ "1::2:3:4:5",
181
+ "1::2:3:4",
182
+ "1::2:3",
183
+ "1::8",
184
+ "::2:3:4:5:6:7:8",
185
+ "::2:3:4:5:6:7",
186
+ "::2:3:4:5:6",
187
+ "::2:3:4:5",
188
+ "::2:3:4",
189
+ "::2:3",
190
+ "::8",
191
+ "1:2:3:4:5:6::",
192
+ "1:2:3:4:5::",
193
+ "1:2:3:4::",
194
+ "1:2:3::",
195
+ "1:2::",
196
+ "1::",
197
+ "1:2:3:4:5::7:8",
198
+ "1:2:3:4::7:8",
199
+ "1:2:3::7:8",
200
+ "1:2::7:8",
201
+ "1::7:8",
202
+ "1:2:3:4:5:6:1.2.3.4",
203
+ "1:2:3:4:5::1.2.3.4",
204
+ "1:2:3:4::1.2.3.4",
205
+ "1:2:3::1.2.3.4",
206
+ "1:2::1.2.3.4",
207
+ "1::1.2.3.4",
208
+ "1:2:3:4::5:1.2.3.4",
209
+ "1:2:3::5:1.2.3.4",
210
+ "1:2::5:1.2.3.4",
211
+ "1::5:1.2.3.4",
212
+ "1::5:11.22.33.44",
213
+ "fe80::217:f2ff:254.7.237.98",
214
+ "fe80::217:f2ff:fe07:ed62",
215
+ "2001:DB8:0:0:8:800:200C:417A", # unicast, full
216
+ "FF01:0:0:0:0:0:0:101", # multicast, full
217
+ "0:0:0:0:0:0:0:1", # loopback, full
218
+ "0:0:0:0:0:0:0:0", # unspecified, full
219
+ "2001:DB8::8:800:200C:417A", # unicast, compressed
220
+ "FF01::101", # multicast, compressed
221
+ "::1", # loopback, compressed, non-routable
222
+ "::", # unspecified, compressed, non-routable
223
+ "0:0:0:0:0:0:13.1.68.3", # IPv4-compatible IPv6 address, full, deprecated
224
+ "0:0:0:0:0:FFFF:129.144.52.38", # IPv4-mapped IPv6 address, full
225
+ "::13.1.68.3", # IPv4-compatible IPv6 address, compressed, deprecated
226
+ "::FFFF:129.144.52.38", # IPv4-mapped IPv6 address, compressed
227
+ "2001:0DB8:0000:CD30:0000:0000:0000:0000/60", # full, with prefix
228
+ "2001:0DB8::CD30:0:0:0:0/60", # compressed, with prefix
229
+ "2001:0DB8:0:CD30::/60", # compressed, with prefix #2
230
+ "::/128", # compressed, unspecified address type, non-routable
231
+ "::1/128", # compressed, loopback address type, non-routable
232
+ "FF00::/8", # compressed, multicast address type
233
+ "FE80::/10", # compressed, link-local unicast, non-routable
234
+ "FEC0::/10", # compressed, site-local unicast, deprecated
235
+ "127.0.0.1", # standard IPv4, loopback, non-routable
236
+ "0.0.0.0", # standard IPv4, unspecified, non-routable
237
+ "255.255.255.255", # standard IPv4
238
+ "fe80:0000:0000:0000:0204:61ff:fe9d:f156",
239
+ "fe80:0:0:0:204:61ff:fe9d:f156",
240
+ "fe80::204:61ff:fe9d:f156",
241
+ "fe80:0000:0000:0000:0204:61ff:254.157.241.086",
242
+ "fe80:0:0:0:204:61ff:254.157.241.86",
243
+ "fe80::204:61ff:254.157.241.86",
244
+ "::1",
245
+ "fe80::",
246
+ "fe80::1"
247
+ ].each { |ip|
248
+ describe "when the pattern is a valid IP such as #{ip}" do
249
+ before :each do
250
+ @declaration = Puppet::Network::AuthStore::Declaration.new(:allow,ip)
251
+ end
252
+ it "should match the specified IP" do
253
+ @declaration.should be_match('www.testsite.org',ip)
254
+ end
255
+ it "should not match other IPs" do
256
+ @declaration.should_not be_match('www.testsite.org','200.101.99.98')
257
+ end
258
+ end unless ip =~ /:.*\./ # Hybrid IPs aren't supported by ruby's ipaddr
259
+ }
260
+
86
261
  {
87
262
  'spirit.mars.nasa.gov' => 'a PQDN',
88
263
  'ratchet.2ndsiteinc.com' => 'a PQDN with digits',
@@ -103,6 +278,28 @@ describe Puppet::Network::AuthStore::Declaration do
103
278
  end
104
279
  }
105
280
 
281
+ ['abc.12seps.edu.phisher.biz','www.google.com','slashdot.org'].each { |host|
282
+ (1...(host.split('.').length)).each { |n|
283
+ describe "when the pattern is #{"*."+host.split('.')[-n,n].join('.')}" do
284
+ before :each do
285
+ @pattern = "*."+host.split('.')[-n,n].join('.')
286
+ @declaration = Puppet::Network::AuthStore::Declaration.new(:allow,@pattern)
287
+ end
288
+ it "should match #{host}" do
289
+ @declaration.should be_match(host,'1.2.3.4')
290
+ end
291
+ it "should not match www.testsite.gov" do
292
+ @declaration.should_not be_match('www.testsite.gov','200.101.99.98')
293
+ end
294
+ it "should not match hosts that differ in the first non-wildcard segment" do
295
+ other = host.split('.')
296
+ other[-n].succ!
297
+ @declaration.should_not be_match(other.join('.'),'1.2.3.4')
298
+ end
299
+ end
300
+ }
301
+ }
302
+
106
303
  describe "when the pattern is a FQDN" do
107
304
  before :each do
108
305
  @host = 'spirit.mars.nasa.gov.'
@@ -49,15 +49,35 @@ describe Puppet::Network::FormatHandler do
49
49
  FormatTester.supported_formats.should == [:four, :two, :three, :one]
50
50
  end
51
51
 
52
- it "should always put the preferred serialization format first if it is supported" do
53
- one = stub 'supported', :supported? => true, :name => :one, :weight => 1
54
- two = stub 'supported', :supported? => true, :name => :two, :weight => 6
55
52
 
56
- Puppet.settings.expects(:value).with(:preferred_serialization_format).returns :one
57
- Puppet::Network::FormatHandler.stubs(:formats).returns [:one, :two]
58
- Puppet::Network::FormatHandler.stubs(:format).with(:one).returns one
59
- Puppet::Network::FormatHandler.stubs(:format).with(:two).returns two
60
- FormatTester.supported_formats.should == [:one, :two]
53
+ describe "with a preferred serialization format setting" do
54
+ before do
55
+ one = stub 'supported', :supported? => true, :name => :one, :weight => 1
56
+ two = stub 'supported', :supported? => true, :name => :two, :weight => 6
57
+ Puppet::Network::FormatHandler.stubs(:formats).returns [:one, :two]
58
+ Puppet::Network::FormatHandler.stubs(:format).with(:one).returns one
59
+ Puppet::Network::FormatHandler.stubs(:format).with(:two).returns two
60
+ end
61
+ describe "that is supported" do
62
+ before do
63
+ Puppet.settings.expects(:value).with(:preferred_serialization_format).returns :one
64
+ end
65
+ it "should return the preferred serialization format first" do
66
+ FormatTester.supported_formats.should == [:one, :two]
67
+ end
68
+ end
69
+ describe "that is not supported" do
70
+ before do
71
+ Puppet.settings.expects(:value).with(:preferred_serialization_format).returns :unsupported
72
+ end
73
+ it "should still return the default format first" do
74
+ FormatTester.supported_formats.should == [:two, :one]
75
+ end
76
+ it "should log a warning" do
77
+ Puppet.expects(:warning)
78
+ FormatTester.supported_formats
79
+ end
80
+ end
61
81
  end
62
82
 
63
83
  it "should return the first format as the default format" do
@@ -91,6 +91,9 @@ describe "Puppet Network Format" do
91
91
  end
92
92
 
93
93
  describe "base64 compressed yaml" do
94
+ yaml = Puppet::Network::FormatHandler.format(:b64_zlib_yaml)
95
+ confine "We must have zlib" => Puppet.features.zlib?
96
+
94
97
  before do
95
98
  @yaml = Puppet::Network::FormatHandler.format(:b64_zlib_yaml)
96
99
  end
@@ -173,6 +176,34 @@ describe "Puppet Network Format" do
173
176
  it "should fixup incorrect yaml to correct" do
174
177
  @yaml.fixup("&id004 !ruby/object:Puppet::Relationship ?").should == "? &id004 !ruby/object:Puppet::Relationship"
175
178
  end
179
+
180
+ describe "when zlib is disabled" do
181
+ before do
182
+ Puppet[:zlib] = false
183
+ end
184
+
185
+ it "use_zlib? should return false" do
186
+ @yaml.use_zlib?.should == false
187
+ end
188
+
189
+ it "should refuse to encode" do
190
+ lambda{ @yaml.encode("foo") }.should raise_error
191
+ end
192
+
193
+ it "should refuse to decode" do
194
+ lambda{ @yaml.decode("foo") }.should raise_error
195
+ end
196
+ end
197
+
198
+ describe "when zlib is not installed" do
199
+ it "use_zlib? should return false" do
200
+ Puppet[:zlib] = true
201
+ Puppet.features.expects(:zlib?).returns(false)
202
+
203
+ @yaml.use_zlib?.should == false
204
+ end
205
+ end
206
+
176
207
  end
177
208
 
178
209
  it "should include a marshal format" do
@@ -230,6 +230,16 @@ describe Puppet::Network::HTTP::Handler do
230
230
  @handler.do_find(@irequest, @request, @response)
231
231
  end
232
232
 
233
+ it "should write a log message when no model instance can be found" do
234
+ @model_class.stubs(:name).returns "my name"
235
+ @model_class.stubs(:find).returns(nil)
236
+
237
+ Puppet.expects(:info).with("Could not find my_handler for 'my_result'")
238
+
239
+ @handler.do_find(@irequest, @request, @response)
240
+ end
241
+
242
+
233
243
  it "should serialize the result in with the appropriate format" do
234
244
  @model_instance = stub('model instance')
235
245