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.
- data/CHANGELOG +159 -135
- data/Rakefile +4 -1
- data/conf/gentoo/conf.d/puppetmaster +1 -1
- data/conf/osx/createpackage.sh +12 -0
- data/conf/osx/preflight +4 -0
- data/conf/redhat/puppet.spec +12 -2
- data/conf/redhat/server.init +1 -0
- data/conf/redhat/server.sysconfig +1 -1
- data/ext/ldap/puppet.schema +5 -9
- data/ext/puppetlast +2 -1
- data/ext/rack/README +2 -2
- data/ext/regexp_nodes/classes/databases +2 -0
- data/ext/regexp_nodes/classes/webservers +2 -0
- data/ext/regexp_nodes/parameters/environment/prod +1 -0
- data/ext/regexp_nodes/parameters/environment/qa +3 -0
- data/ext/regexp_nodes/regexp_nodes.rb +215 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +1 -1
- data/lib/puppet/application/puppetd.rb +1 -1
- data/lib/puppet/application/puppetdoc.rb +4 -3
- data/lib/puppet/application/puppetrun.rb +5 -14
- data/lib/puppet/application/ralsh.rb +9 -25
- data/lib/puppet/configurer.rb +2 -1
- data/lib/puppet/configurer/fact_handler.rb +8 -6
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +21 -2
- data/lib/puppet/external/pson/common.rb +1 -1
- data/lib/puppet/external/pson/pure.rb +3 -3
- data/lib/puppet/feature/base.rb +3 -0
- data/lib/puppet/feature/selinux.rb +3 -0
- data/lib/puppet/feature/zlib.rb +6 -0
- data/lib/puppet/file_serving/base.rb +16 -1
- data/lib/puppet/file_serving/metadata.rb +46 -9
- data/lib/puppet/file_serving/mount/file.rb +4 -1
- data/lib/puppet/indirector/catalog/active_record.rb +5 -0
- data/lib/puppet/indirector/envelope.rb +1 -3
- data/lib/puppet/indirector/indirection.rb +13 -16
- data/lib/puppet/indirector/node/ldap.rb +7 -4
- data/lib/puppet/indirector/ssl_file.rb +1 -1
- data/lib/puppet/network/authstore.rb +48 -118
- data/lib/puppet/network/client/resource.rb +2 -15
- data/lib/puppet/network/format.rb +2 -12
- data/lib/puppet/network/format_handler.rb +15 -1
- data/lib/puppet/network/formats.rb +19 -4
- data/lib/puppet/network/handler/fileserver.rb +1 -0
- data/lib/puppet/network/http/handler.rb +1 -0
- data/lib/puppet/network/http/rack/httphandler.rb +0 -18
- data/lib/puppet/network/http/rack/rest.rb +4 -4
- data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/server.rb +1 -1
- data/lib/puppet/node/environment.rb +20 -9
- data/lib/puppet/parameter.rb +17 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
- data/lib/puppet/parser/ast/leaf.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +4 -0
- data/lib/puppet/parser/ast/selector.rb +4 -0
- data/lib/puppet/parser/functions/generate.rb +2 -2
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/property.rb +3 -11
- data/lib/puppet/provider/cron/crontab.rb +2 -0
- data/lib/puppet/provider/host/parsed.rb +9 -9
- data/lib/puppet/provider/package/blastwave.rb +7 -6
- data/lib/puppet/provider/package/portage.rb +23 -27
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +5 -3
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
- data/lib/puppet/provider/sshkey/parsed.rb +3 -5
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails.rb +9 -2
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/rails/host.rb +2 -7
- data/lib/puppet/rails/resource.rb +20 -26
- data/lib/puppet/resource/catalog.rb +3 -3
- data/lib/puppet/resource/reference.rb +13 -25
- data/lib/puppet/ssl/certificate.rb +3 -2
- data/lib/puppet/ssl/host.rb +14 -33
- data/lib/puppet/sslcertificates.rb +1 -5
- data/lib/puppet/sslcertificates/ca.rb +8 -7
- data/lib/puppet/transaction.rb +15 -12
- data/lib/puppet/type.rb +12 -5
- data/lib/puppet/type/file.rb +26 -32
- data/lib/puppet/type/file/content.rb +5 -5
- data/lib/puppet/type/file/ensure.rb +6 -17
- data/lib/puppet/type/file/mode.rb +18 -1
- data/lib/puppet/type/file/source.rb +12 -12
- data/lib/puppet/type/host.rb +6 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/maillist.rb +4 -7
- data/lib/puppet/type/port.rb +6 -5
- data/lib/puppet/type/resources.rb +12 -12
- data/lib/puppet/type/sshkey.rb +5 -5
- data/lib/puppet/type/tidy.rb +9 -2
- data/lib/puppet/type/yumrepo.rb +3 -1
- data/lib/puppet/util.rb +64 -56
- data/lib/puppet/util/backups.rb +2 -1
- data/lib/puppet/util/filetype.rb +46 -0
- data/lib/puppet/util/log.rb +10 -18
- data/lib/puppet/util/log_paths.rb +14 -0
- data/lib/puppet/util/methodhelper.rb +3 -4
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
- data/lib/puppet/util/rdoc/parser.rb +32 -16
- data/lib/puppet/util/reference.rb +6 -3
- data/lib/puppet/util/selinux.rb +21 -14
- data/lib/puppet/util/settings.rb +30 -25
- data/lib/puppet/util/settings/file_setting.rb +7 -4
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +11 -1
- data/lib/puppet/util/tagging.rb +22 -4
- data/man/man8/filebucket.8 +23 -18
- data/man/man8/pi.8 +42 -20
- data/man/man8/puppet.8 +47 -32
- data/man/man8/puppet.conf.8 +807 -764
- data/man/man8/puppetca.8 +24 -14
- data/man/man8/puppetd.8 +33 -16
- data/man/man8/puppetdoc.8 +71 -18
- data/man/man8/puppetmasterd.8 +18 -25
- data/man/man8/puppetqd.8 +60 -0
- data/man/man8/puppetrun.8 +27 -14
- data/man/man8/ralsh.8 +33 -40
- data/spec/integration/bin/puppetmasterd.rb +3 -2
- data/spec/integration/defaults.rb +11 -0
- data/spec/integration/file_serving/metadata.rb +1 -0
- data/spec/integration/indirector/file_content/file_server.rb +2 -1
- data/spec/integration/ssl/certificate_request.rb +2 -0
- data/spec/integration/type/file.rb +20 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/puppet.rb +11 -30
- data/spec/unit/application/puppetd.rb +1 -0
- data/spec/unit/application/puppetdoc.rb +13 -4
- data/spec/unit/application/puppetmasterd.rb +1 -0
- data/spec/unit/application/puppetrun.rb +12 -2
- data/spec/unit/application/ralsh.rb +39 -22
- data/spec/unit/configurer.rb +6 -0
- data/spec/unit/configurer/fact_handler.rb +15 -1
- data/spec/unit/file_serving/metadata.rb +128 -16
- data/spec/unit/file_serving/mount/file.rb +8 -0
- data/spec/unit/indirector/catalog/active_record.rb +20 -1
- data/spec/unit/indirector/catalog/compiler.rb +2 -1
- data/spec/unit/indirector/indirection.rb +29 -18
- data/spec/unit/indirector/node/ldap.rb +20 -6
- data/spec/unit/network/authstore.rb +197 -0
- data/spec/unit/network/format_handler.rb +28 -8
- data/spec/unit/network/formats.rb +31 -0
- data/spec/unit/network/http/handler.rb +10 -0
- data/spec/unit/network/http/webrick.rb +2 -2
- data/spec/unit/network/rest_authconfig.rb +2 -2
- data/spec/unit/network/rights.rb +1 -1
- data/spec/unit/node/environment.rb +39 -23
- data/spec/unit/other/selinux.rb +2 -2
- data/spec/unit/parameter.rb +8 -0
- data/spec/unit/parser/ast/leaf.rb +9 -0
- data/spec/unit/parser/ast/selector.rb +8 -1
- data/spec/unit/parser/lexer.rb +1 -1
- data/spec/unit/parser/resource.rb +11 -0
- data/spec/unit/parser/resource/reference.rb +13 -1
- data/spec/unit/property.rb +6 -0
- data/spec/unit/provider/mount/parsed.rb +3 -1
- data/spec/unit/provider/service/debian.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
- data/spec/unit/provider/sshkey/parsed.rb +19 -0
- data/spec/unit/rails.rb +22 -9
- data/spec/unit/rails/resource.rb +20 -0
- data/spec/unit/ssl/host.rb +19 -57
- data/spec/unit/transaction.rb +39 -4
- data/spec/unit/type.rb +9 -0
- data/spec/unit/type/file/content.rb +29 -0
- data/spec/unit/type/maillist.rb +42 -0
- data/spec/unit/type/resources.rb +66 -1
- data/spec/unit/type/tidy.rb +14 -1
- data/spec/unit/util/autoload.rb +2 -0
- data/spec/unit/util/ldap/connection.rb +1 -1
- data/spec/unit/util/log.rb +14 -0
- data/spec/unit/util/monkey_patches.rb +103 -0
- data/spec/unit/util/queue.rb +10 -2
- data/spec/unit/util/selinux.rb +61 -2
- data/spec/unit/util/settings.rb +19 -0
- data/spec/unit/util/settings/file_setting.rb +25 -0
- data/spec/unit/util/tagging.rb +10 -0
- data/tasks/rake/changelog.rake +15 -0
- data/tasks/rake/ci.rake +22 -0
- data/tasks/rake/dailybuild.rake +9 -0
- data/tasks/rake/gem.rake +46 -0
- data/tasks/rake/git_workflow.rake +121 -0
- data/tasks/rake/metrics.rake +6 -0
- data/tasks/rake/sign.rake +14 -0
- data/tasks/rake/testbranch.rake +16 -0
- data/tasks/rake/tracdocs.rake +8 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
- metadata +1042 -1288
- data/ext/bin/sleeper +0 -67
- data/ext/module_puppet +0 -209
@@ -173,6 +173,7 @@ describe "puppetd" do
|
|
173
173
|
Puppet.stubs(:info)
|
174
174
|
FileTest.stubs(:exists?).returns(true)
|
175
175
|
Puppet.stubs(:[])
|
176
|
+
Puppet.stubs(:[]).with(:libdir).returns("/dev/null/lib")
|
176
177
|
Puppet.settings.stubs(:print_config?)
|
177
178
|
Puppet.settings.stubs(:print_config)
|
178
179
|
Puppet::SSL::Host.stubs(:ca_location=)
|
@@ -290,16 +290,16 @@ describe "puppetdoc" do
|
|
290
290
|
@puppetdoc.manifest = false
|
291
291
|
Puppet.stubs(:info)
|
292
292
|
Puppet.stubs(:[]).with(:trace).returns(false)
|
293
|
-
|
294
|
-
Puppet.stubs(:
|
293
|
+
@env = stub 'env'
|
294
|
+
Puppet::Node::Environment.stubs(:new).returns(@env)
|
295
|
+
@env.stubs(:modulepath).returns(['modules'])
|
296
|
+
@env.stubs(:[]).with(:manifest).returns('manifests/site.pp')
|
295
297
|
@puppetdoc.options.stubs(:[]).with(:all).returns(false)
|
296
298
|
@puppetdoc.options.stubs(:[]).with(:outputdir).returns('doc')
|
297
299
|
Puppet.settings.stubs(:[]=).with(:document_all, false)
|
298
300
|
Puppet.settings.stubs(:setdefaults)
|
299
301
|
Puppet::Util::RDoc.stubs(:rdoc)
|
300
302
|
@puppetdoc.stubs(:exit)
|
301
|
-
File.stubs(:expand_path).with('modules').returns('modules')
|
302
|
-
File.stubs(:expand_path).with('manifests').returns('manifests')
|
303
303
|
@old = ARGV.dup
|
304
304
|
ARGV.clear
|
305
305
|
end
|
@@ -331,6 +331,15 @@ describe "puppetdoc" do
|
|
331
331
|
Puppet::Util::RDoc.expects(:manifestdoc)
|
332
332
|
@puppetdoc.rdoc
|
333
333
|
end
|
334
|
+
|
335
|
+
it "should get modulepath and manifestdir values from the environment" do
|
336
|
+
@env.expects(:modulepath).returns(['envmodules1','envmodules2'])
|
337
|
+
@env.expects(:[]).with(:manifest).returns('envmanifests/site.pp')
|
338
|
+
|
339
|
+
Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'])
|
340
|
+
|
341
|
+
@puppetdoc.rdoc
|
342
|
+
end
|
334
343
|
end
|
335
344
|
|
336
345
|
describe "in the other modes" do
|
@@ -144,11 +144,21 @@ describe "puppetrun" do
|
|
144
144
|
Puppet.stubs(:[]).with(:node_terminus).returns("ldap")
|
145
145
|
end
|
146
146
|
|
147
|
+
it "should pass the fqdn option to search" do
|
148
|
+
@puppetrun.options.stubs(:[]).with(:fqdn).returns(:something)
|
149
|
+
@puppetrun.options.stubs(:[]).with(:all).returns(true)
|
150
|
+
@puppetrun.stubs(:puts)
|
151
|
+
|
152
|
+
Puppet::Node.expects(:search).with("whatever",:fqdn => :something).returns([])
|
153
|
+
|
154
|
+
@puppetrun.run_setup
|
155
|
+
end
|
156
|
+
|
147
157
|
it "should search for all nodes if --all" do
|
148
158
|
@puppetrun.options.stubs(:[]).with(:all).returns(true)
|
149
159
|
@puppetrun.stubs(:puts)
|
150
160
|
|
151
|
-
Puppet::Node.expects(:search).with("whatever").returns([])
|
161
|
+
Puppet::Node.expects(:search).with("whatever",:fqdn => nil).returns([])
|
152
162
|
|
153
163
|
@puppetrun.run_setup
|
154
164
|
end
|
@@ -158,7 +168,7 @@ describe "puppetrun" do
|
|
158
168
|
@puppetrun.stubs(:puts)
|
159
169
|
@puppetrun.classes = ['class']
|
160
170
|
|
161
|
-
Puppet::Node.expects(:search).with("whatever", :class => "class").returns([])
|
171
|
+
Puppet::Node.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([])
|
162
172
|
|
163
173
|
@puppetrun.run_setup
|
164
174
|
end
|
@@ -132,17 +132,34 @@ describe "ralsh" do
|
|
132
132
|
|
133
133
|
describe "when running" do
|
134
134
|
|
135
|
+
def set_args(args)
|
136
|
+
(ARGV.clear << args).flatten!
|
137
|
+
end
|
138
|
+
|
139
|
+
def push_args(*args)
|
140
|
+
@args_stack ||= []
|
141
|
+
@args_stack << ARGV.dup
|
142
|
+
set_args(args)
|
143
|
+
end
|
144
|
+
|
145
|
+
def pop_args
|
146
|
+
set_args(@args_stack.pop)
|
147
|
+
end
|
148
|
+
|
135
149
|
before :each do
|
136
150
|
@type = stub_everything 'type', :properties => []
|
137
|
-
|
138
|
-
ARGV.stubs(:length).returns(1).then.returns(0)
|
151
|
+
push_args('type')
|
139
152
|
Puppet::Type.stubs(:type).returns(@type)
|
140
153
|
end
|
141
154
|
|
142
|
-
|
143
|
-
|
155
|
+
after :each do
|
156
|
+
pop_args
|
157
|
+
end
|
144
158
|
|
159
|
+
it "should raise an error if no type is given" do
|
160
|
+
push_args
|
145
161
|
lambda { @ralsh.main }.should raise_error
|
162
|
+
pop_args
|
146
163
|
end
|
147
164
|
|
148
165
|
it "should raise an error when editing a remote host" do
|
@@ -186,11 +203,10 @@ describe "ralsh" do
|
|
186
203
|
end
|
187
204
|
|
188
205
|
it "should describe the given resource" do
|
189
|
-
|
190
|
-
ARGV.stubs(:length).returns(1).then.returns(1).then.returns(0)
|
206
|
+
push_args('type','name')
|
191
207
|
@client.expects(:describe).returns(stub_everything)
|
192
|
-
|
193
208
|
@ralsh.main
|
209
|
+
pop_args
|
194
210
|
end
|
195
211
|
end
|
196
212
|
|
@@ -208,30 +224,31 @@ describe "ralsh" do
|
|
208
224
|
|
209
225
|
describe 'but with a given name' do
|
210
226
|
before :each do
|
211
|
-
|
212
|
-
|
213
|
-
@object = stub_everything 'object', :to_trans => stub_everything('transportable')
|
214
|
-
@type.stubs(:new).returns(@object)
|
215
|
-
@object.stubs(:retrieve)
|
227
|
+
push_args('type','name')
|
228
|
+
@type.stubs(:new).returns(:bob)
|
216
229
|
end
|
217
230
|
|
218
|
-
|
219
|
-
|
220
|
-
|
231
|
+
after :each do
|
232
|
+
pop_args
|
233
|
+
end
|
221
234
|
|
222
|
-
|
235
|
+
it "should retrieve a specific instance if it exists" do
|
236
|
+
pending
|
223
237
|
end
|
224
238
|
|
225
|
-
it "should add given parameters to object" do
|
226
|
-
ARGV.stubs(:each).yields('param=temp')
|
227
|
-
ARGV.stubs(:length).returns(1).then.returns(1).then.returns(1)
|
228
|
-
Puppet::Resource::Catalog.stubs(:new).returns(stub_everything)
|
229
|
-
@object.expects(:[]=).with('param','temp')
|
230
239
|
|
240
|
+
it "should create a stub instance if it doesn't exist" do
|
241
|
+
pending
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should add given parameters to the object" do
|
245
|
+
push_args('type','name','param=temp')
|
246
|
+
pending
|
247
|
+
@object.expects(:[]=).with('param','temp')
|
231
248
|
@ralsh.main
|
249
|
+
pop_args
|
232
250
|
end
|
233
251
|
end
|
234
252
|
end
|
235
|
-
|
236
253
|
end
|
237
254
|
end
|
data/spec/unit/configurer.rb
CHANGED
@@ -183,6 +183,12 @@ describe Puppet::Configurer, "when converting the catalog" do
|
|
183
183
|
@agent.convert_catalog(@oldcatalog, 10).should equal(@catalog)
|
184
184
|
end
|
185
185
|
|
186
|
+
it "should finalize the catalog" do
|
187
|
+
@catalog.expects(:finalize)
|
188
|
+
|
189
|
+
@agent.convert_catalog(@oldcatalog, 10)
|
190
|
+
end
|
191
|
+
|
186
192
|
it "should record the passed retrieval time with the RAL catalog" do
|
187
193
|
@catalog.expects(:retrieval_duration=).with 10
|
188
194
|
|
@@ -97,6 +97,7 @@ describe Puppet::Configurer::FactHandler do
|
|
97
97
|
# I couldn't get marshal to work for this, only yaml, so we hard-code yaml.
|
98
98
|
it "should serialize and CGI escape the fact values for uploading" do
|
99
99
|
facts = stub 'facts'
|
100
|
+
facts.expects(:support_format?).with(:b64_zlib_yaml).returns true
|
100
101
|
facts.expects(:render).returns "my text"
|
101
102
|
text = CGI.escape("my text")
|
102
103
|
|
@@ -107,6 +108,7 @@ describe Puppet::Configurer::FactHandler do
|
|
107
108
|
|
108
109
|
it "should properly accept facts containing a '+'" do
|
109
110
|
facts = stub 'facts'
|
111
|
+
facts.expects(:support_format?).with(:b64_zlib_yaml).returns true
|
110
112
|
facts.expects(:render).returns "my+text"
|
111
113
|
text = "my%2Btext"
|
112
114
|
|
@@ -115,8 +117,9 @@ describe Puppet::Configurer::FactHandler do
|
|
115
117
|
@facthandler.facts_for_uploading.should == {:facts_format => :b64_zlib_yaml, :facts => text}
|
116
118
|
end
|
117
119
|
|
118
|
-
it "
|
120
|
+
it "use compressed yaml as the serialization if zlib is supported" do
|
119
121
|
facts = stub 'facts'
|
122
|
+
facts.expects(:support_format?).with(:b64_zlib_yaml).returns true
|
120
123
|
facts.expects(:render).with(:b64_zlib_yaml).returns "my text"
|
121
124
|
text = CGI.escape("my text")
|
122
125
|
|
@@ -125,6 +128,17 @@ describe Puppet::Configurer::FactHandler do
|
|
125
128
|
@facthandler.facts_for_uploading
|
126
129
|
end
|
127
130
|
|
131
|
+
it "should use yaml as the serialization if zlib is not supported" do
|
132
|
+
facts = stub 'facts'
|
133
|
+
facts.expects(:support_format?).with(:b64_zlib_yaml).returns false
|
134
|
+
facts.expects(:render).with(:yaml).returns "my text"
|
135
|
+
text = CGI.escape("my text")
|
136
|
+
|
137
|
+
@facthandler.expects(:find_facts).returns facts
|
138
|
+
|
139
|
+
@facthandler.facts_for_uploading
|
140
|
+
end
|
141
|
+
|
128
142
|
describe "when reloading Facter" do
|
129
143
|
before do
|
130
144
|
Facter.stubs(:clear)
|
@@ -20,6 +20,84 @@ describe Puppet::FileServing::Metadata do
|
|
20
20
|
it "should have a method that triggers attribute collection" do
|
21
21
|
Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:collect)
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should support pson serialization" do
|
25
|
+
Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should support to_pson_data_hash" do
|
29
|
+
Puppet::FileServing::Metadata.new("/foo/bar").should respond_to(:to_pson_data_hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should support pson deserialization" do
|
33
|
+
Puppet::FileServing::Metadata.should respond_to(:from_pson)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "when serializing" do
|
37
|
+
before do
|
38
|
+
@metadata = Puppet::FileServing::Metadata.new("/foo/bar")
|
39
|
+
end
|
40
|
+
it "should perform pson serialization by calling to_pson on it's pson_data_hash" do
|
41
|
+
pdh = mock "data hash"
|
42
|
+
pdh_as_pson = mock "data as pson"
|
43
|
+
@metadata.expects(:to_pson_data_hash).returns pdh
|
44
|
+
pdh.expects(:to_pson).returns pdh_as_pson
|
45
|
+
@metadata.to_pson.should == pdh_as_pson
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should serialize as FileMetadata" do
|
49
|
+
@metadata.to_pson_data_hash['document_type'].should == "FileMetadata"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "the data should include the path, relative_path, links, owner, group, mode, checksum, type, and destination" do
|
53
|
+
@metadata.to_pson_data_hash['data'].keys.sort.should == %w{ path relative_path links owner group mode checksum type destination }.sort
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should pass the path in the hash verbatum" do
|
57
|
+
@metadata.to_pson_data_hash['data']['path'] == @metadata.path
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should pass the relative_path in the hash verbatum" do
|
61
|
+
@metadata.to_pson_data_hash['data']['relative_path'] == @metadata.relative_path
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should pass the links in the hash verbatum" do
|
65
|
+
@metadata.to_pson_data_hash['data']['links'] == @metadata.links
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should pass the path owner in the hash verbatum" do
|
69
|
+
@metadata.to_pson_data_hash['data']['owner'] == @metadata.owner
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should pass the group in the hash verbatum" do
|
73
|
+
@metadata.to_pson_data_hash['data']['group'] == @metadata.group
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should pass the mode in the hash verbatum" do
|
77
|
+
@metadata.to_pson_data_hash['data']['mode'] == @metadata.mode
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should pass the ftype in the hash verbatum as the 'type'" do
|
81
|
+
@metadata.to_pson_data_hash['data']['type'] == @metadata.ftype
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should pass the destination verbatum" do
|
85
|
+
@metadata.to_pson_data_hash['data']['destination'] == @metadata.destination
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should pass the checksum in the hash as a nested hash" do
|
89
|
+
@metadata.to_pson_data_hash['data']['checksum'].should be_is_a(Hash)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should pass the checksum_type in the hash verbatum as the checksum's type" do
|
93
|
+
@metadata.to_pson_data_hash['data']['checksum']['type'] == @metadata.checksum_type
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should pass the checksum in the hash verbatum as the checksum's value" do
|
97
|
+
@metadata.to_pson_data_hash['data']['checksum']['value'] == @metadata.checksum
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
23
101
|
end
|
24
102
|
|
25
103
|
describe Puppet::FileServing::Metadata, " when finding the file to use for setting attributes" do
|
@@ -29,6 +107,10 @@ describe Puppet::FileServing::Metadata, " when finding the file to use for setti
|
|
29
107
|
|
30
108
|
# Use a link because it's easier to test -- no checksumming
|
31
109
|
@stat = stub "stat", :uid => 10, :gid => 20, :mode => 0755, :ftype => "link"
|
110
|
+
|
111
|
+
# Not quite. We don't want to checksum links, but we must because they might be being followed.
|
112
|
+
@checksum = Digest::MD5.hexdigest("some content\n") # Remove these when :managed links are no longer checksumed.
|
113
|
+
@metadata.stubs(:md5_file).returns(@checksum) #
|
32
114
|
end
|
33
115
|
|
34
116
|
it "should accept a base path path to which the file should be relative" do
|
@@ -139,6 +221,9 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
|
|
139
221
|
@stat.stubs(:ftype).returns("link")
|
140
222
|
File.expects(:readlink).with("/my/file").returns("/path/to/link")
|
141
223
|
@metadata.collect
|
224
|
+
|
225
|
+
@checksum = Digest::MD5.hexdigest("some content\n") # Remove these when :managed links are no longer checksumed.
|
226
|
+
@file.stubs(:md5_file).returns(@checksum) #
|
142
227
|
end
|
143
228
|
|
144
229
|
it "should read links instead of returning their checksums" do
|
@@ -146,29 +231,56 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
|
|
146
231
|
end
|
147
232
|
|
148
233
|
it "should produce tab-separated mode, type, owner, group, and destination for xmlrpc" do
|
149
|
-
|
234
|
+
pending "We'd like this to be true, but we need to always collect the checksum because in the server/client/server round trip we lose the distintion between manage and follow."
|
235
|
+
@metadata.attributes_with_tabs.should == "#{0755}\tlink\t10\t20\t/path/to/link"
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should produce tab-separated mode, type, owner, group, checksum, and destination for xmlrpc" do
|
239
|
+
@metadata.attributes_with_tabs.should == "#{0755}\tlink\t10\t20\t{md5}eb9c2bf0eb63f3a7bc0ea37ef18aeba5\t/path/to/link"
|
150
240
|
end
|
151
241
|
end
|
152
242
|
end
|
153
243
|
|
154
244
|
describe Puppet::FileServing::Metadata, " when pointing to a link" do
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
245
|
+
describe "when links are managed" do
|
246
|
+
before do
|
247
|
+
@file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :manage)
|
248
|
+
File.expects(:lstat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "link", :mode => 0755)
|
249
|
+
File.expects(:readlink).with("/base/path/my/file").returns "/some/other/path"
|
160
250
|
|
161
|
-
|
162
|
-
|
251
|
+
@checksum = Digest::MD5.hexdigest("some content\n") # Remove these when :managed links are no longer checksumed.
|
252
|
+
@file.stubs(:md5_file).returns(@checksum) #
|
253
|
+
end
|
254
|
+
it "should store the destination of the link in :destination if links are :manage" do
|
255
|
+
@file.collect
|
256
|
+
@file.destination.should == "/some/other/path"
|
257
|
+
end
|
258
|
+
it "should not collect the checksum if links are :manage" do
|
259
|
+
pending "We'd like this to be true, but we need to always collect the checksum because in the server/client/server round trip we lose the distintion between manage and follow."
|
260
|
+
@file.collect
|
261
|
+
@file.checksum.should be_nil
|
262
|
+
end
|
263
|
+
it "should collect the checksum if links are :manage" do # see pending note above
|
264
|
+
@file.collect
|
265
|
+
@file.checksum.should == "{md5}#{@checksum}"
|
266
|
+
end
|
163
267
|
end
|
164
268
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
269
|
+
describe "when links are followed" do
|
270
|
+
before do
|
271
|
+
@file = Puppet::FileServing::Metadata.new("/base/path/my/file", :links => :follow)
|
272
|
+
File.expects(:stat).with("/base/path/my/file").returns stub("stat", :uid => 1, :gid => 2, :ftype => "file", :mode => 0755)
|
273
|
+
File.expects(:readlink).with("/base/path/my/file").never
|
274
|
+
@checksum = Digest::MD5.hexdigest("some content\n")
|
275
|
+
@file.stubs(:md5_file).returns(@checksum)
|
276
|
+
end
|
277
|
+
it "should not store the destination of the link in :destination if links are :follow" do
|
278
|
+
@file.collect
|
279
|
+
@file.destination.should be_nil
|
280
|
+
end
|
281
|
+
it "should collect the checksum if links are :follow" do
|
282
|
+
@file.collect
|
283
|
+
@file.checksum.should == "{md5}#{@checksum}"
|
284
|
+
end
|
173
285
|
end
|
174
286
|
end
|
@@ -107,6 +107,14 @@ describe Puppet::FileServing::Mount::File, "when determining the complete file p
|
|
107
107
|
@mount.complete_path("/my/path", nil).should be_nil
|
108
108
|
end
|
109
109
|
|
110
|
+
it "should write a log message if the file is absent" do
|
111
|
+
FileTest.stubs(:exist?).returns(false)
|
112
|
+
|
113
|
+
Puppet.expects(:info).with("File does not exist or is not accessible: /mount/my/path")
|
114
|
+
|
115
|
+
@mount.complete_path("/my/path", nil)
|
116
|
+
end
|
117
|
+
|
110
118
|
it "should return the file path if the file is present" do
|
111
119
|
FileTest.stubs(:exist?).with("/my/path").returns(true)
|
112
120
|
@mount.complete_path("/my/path", nil).should == "/mount/my/path"
|
@@ -76,9 +76,12 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do
|
|
76
76
|
|
77
77
|
describe "when saving an instance" do
|
78
78
|
before do
|
79
|
-
@host = stub 'host', :name => "foo", :save => nil, :merge_resources => nil, :last_compile= => nil
|
79
|
+
@host = stub 'host', :name => "foo", :save => nil, :merge_resources => nil, :last_compile= => nil, :ip= => nil, :environment= => nil
|
80
80
|
@host.stubs(:railsmark).yields
|
81
81
|
|
82
|
+
@node = stub_everything 'node', :parameters => {}
|
83
|
+
Puppet::Node.stubs(:find).returns(@node)
|
84
|
+
|
82
85
|
Puppet::Rails::Host.stubs(:find_by_name).returns @host
|
83
86
|
@catalog = Puppet::Resource::Catalog.new("foo")
|
84
87
|
@request = stub 'request', :key => "foo", :instance => @catalog
|
@@ -105,6 +108,22 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do
|
|
105
108
|
@terminus.save(@request)
|
106
109
|
end
|
107
110
|
|
111
|
+
it "should set host ip if we could find a matching node" do
|
112
|
+
@node.stubs(:parameters).returns({"ipaddress" => "192.168.0.1"})
|
113
|
+
|
114
|
+
@host.expects(:ip=).with '192.168.0.1'
|
115
|
+
|
116
|
+
@terminus.save(@request)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should set host environment if we could find a matching node" do
|
120
|
+
@node.stubs(:environment).returns("myenv")
|
121
|
+
|
122
|
+
@host.expects(:environment=).with 'myenv'
|
123
|
+
|
124
|
+
@terminus.save(@request)
|
125
|
+
end
|
126
|
+
|
108
127
|
it "should set the last compile time on the host" do
|
109
128
|
now = Time.now
|
110
129
|
Time.expects(:now).returns now
|