puppet 2.6.0 → 2.6.1
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 +123 -0
- data/conf/redhat/puppet.spec +8 -2
- data/conf/solaris/smf/svc-puppetd +1 -1
- data/conf/solaris/smf/svc-puppetmasterd +1 -1
- data/conf/suse/client.init +4 -4
- data/conf/suse/fileserver.conf +12 -0
- data/conf/suse/logrotate +10 -0
- data/conf/suse/puppet.conf +25 -0
- data/conf/suse/puppet.spec +114 -49
- data/conf/suse/ruby-env.patch +17 -0
- data/conf/suse/server.init +4 -4
- data/ext/logcheck/puppet +23 -23
- data/ext/puppet-load.rb +357 -0
- data/ext/puppetstoredconfigclean.rb +3 -3
- data/ext/rack/files/config.ru +3 -5
- data/ext/vim/syntax/puppet.vim +6 -5
- data/install.rb +12 -11
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +3 -1
- data/lib/puppet/application.rb +2 -3
- data/lib/puppet/application/agent.rb +4 -0
- data/lib/puppet/application/apply.rb +14 -6
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/doc.rb +2 -36
- data/lib/puppet/application/master.rb +0 -3
- data/lib/puppet/application/queue.rb +1 -0
- data/lib/puppet/configurer.rb +4 -0
- data/lib/puppet/daemon.rb +1 -1
- data/lib/puppet/defaults.rb +38 -44
- data/lib/puppet/file_serving/indirection_hooks.rb +2 -2
- data/lib/puppet/indirector/facts/memory.rb +1 -1
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +9 -53
- data/lib/puppet/indirector/node/memory.rb +1 -1
- data/lib/puppet/indirector/yaml.rb +6 -9
- data/lib/puppet/network/format_handler.rb +6 -0
- data/lib/puppet/network/formats.rb +4 -4
- data/lib/puppet/network/http/handler.rb +1 -1
- data/lib/puppet/network/http/rack.rb +3 -0
- data/lib/puppet/network/http/rack/rest.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +6 -3
- data/lib/puppet/node/environment.rb +15 -5
- data/lib/puppet/parameter/value_collection.rb +3 -3
- data/lib/puppet/parser/ast/function.rb +0 -1
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/ast/resource.rb +4 -3
- data/lib/puppet/parser/ast/resource_reference.rb +9 -2
- data/lib/puppet/parser/compiler.rb +12 -14
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +2 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +157 -0
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +6 -5
- data/lib/puppet/parser/functions/md5.rb +5 -0
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +19 -19
- data/lib/puppet/parser/functions/require.rb +2 -3
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/sprintf.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +4 -2
- data/lib/puppet/parser/functions/versioncmp.rb +12 -12
- data/lib/puppet/parser/lexer.rb +13 -14
- data/lib/puppet/parser/resource.rb +2 -7
- data/lib/puppet/parser/resource/param.rb +1 -1
- data/lib/puppet/parser/scope.rb +35 -0
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/property.rb +5 -5
- data/lib/puppet/provider.rb +3 -3
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +3 -3
- data/lib/puppet/provider/group/pw.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +5 -1
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/aptrpm.rb +1 -1
- data/lib/puppet/provider/package/blastwave.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +2 -2
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +1 -1
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sunfreeware.rb +2 -2
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/bsd.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +2 -2
- data/lib/puppet/provider/service/gentoo.rb +2 -2
- data/lib/puppet/provider/service/init.rb +2 -2
- data/lib/puppet/provider/service/redhat.rb +2 -2
- data/lib/puppet/provider/user/ldap.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/rails/host.rb +1 -0
- data/lib/puppet/reference/configuration.rb +37 -34
- data/lib/puppet/reference/indirection.rb +3 -4
- data/lib/puppet/reference/metaparameter.rb +0 -8
- data/lib/puppet/reference/network.rb +6 -4
- data/lib/puppet/reference/providers.rb +4 -4
- data/lib/puppet/reference/report.rb +5 -6
- data/lib/puppet/reference/type.rb +14 -14
- data/lib/puppet/reports/http.rb +1 -1
- data/lib/puppet/reports/rrdgraph.rb +8 -9
- data/lib/puppet/reports/store.rb +2 -2
- data/lib/puppet/reports/tagmail.rb +12 -13
- data/lib/puppet/resource.rb +15 -115
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/type.rb +26 -3
- data/lib/puppet/resource/type_collection.rb +3 -6
- data/lib/puppet/simple_graph.rb +4 -5
- data/lib/puppet/transaction/resource_harness.rb +1 -1
- data/lib/puppet/type.rb +100 -92
- data/lib/puppet/type/augeas.rb +44 -45
- data/lib/puppet/type/computer.rb +2 -2
- data/lib/puppet/type/cron.rb +29 -29
- data/lib/puppet/type/exec.rb +66 -67
- data/lib/puppet/type/file.rb +25 -25
- data/lib/puppet/type/file/content.rb +7 -1
- data/lib/puppet/type/file/ensure.rb +13 -13
- data/lib/puppet/type/file/mode.rb +6 -6
- data/lib/puppet/type/file/selcontext.rb +5 -5
- data/lib/puppet/type/file/source.rb +36 -26
- data/lib/puppet/type/filebucket.rb +5 -6
- data/lib/puppet/type/group.rb +1 -2
- data/lib/puppet/type/host.rb +3 -6
- data/lib/puppet/type/k5login.rb +3 -3
- data/lib/puppet/type/macauthorization.rb +1 -2
- data/lib/puppet/type/mailalias.rb +0 -1
- data/lib/puppet/type/maillist.rb +0 -1
- data/lib/puppet/type/mcx.rb +9 -9
- data/lib/puppet/type/mount.rb +9 -10
- data/lib/puppet/type/notify.rb +0 -1
- data/lib/puppet/type/package.rb +34 -36
- data/lib/puppet/type/resources.rb +1 -5
- data/lib/puppet/type/schedule.rb +9 -12
- data/lib/puppet/type/selboolean.rb +2 -7
- data/lib/puppet/type/selmodule.rb +3 -4
- data/lib/puppet/type/service.rb +9 -9
- data/lib/puppet/type/ssh_authorized_key.rb +2 -3
- data/lib/puppet/type/sshkey.rb +4 -7
- data/lib/puppet/type/stage.rb +5 -4
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/user.rb +1 -2
- data/lib/puppet/type/whit.rb +7 -0
- data/lib/puppet/type/yumrepo.rb +16 -3
- data/lib/puppet/type/zfs.rb +1 -2
- data/lib/puppet/type/zone.rb +28 -28
- data/lib/puppet/type/zpool.rb +10 -5
- data/lib/puppet/util/autoload.rb +17 -5
- data/lib/puppet/util/cacher.rb +15 -10
- data/lib/puppet/util/command_line/puppetdoc +5 -5
- data/lib/puppet/util/command_line/puppetrun +0 -2
- data/lib/puppet/util/command_line/ralsh +13 -13
- data/lib/puppet/util/docs.rb +5 -12
- data/lib/puppet/util/monkey_patches.rb +5 -2
- data/lib/puppet/util/nagios_maker.rb +4 -5
- data/lib/puppet/util/provider_features.rb +2 -2
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +5 -3
- data/lib/puppet/util/reference.rb +3 -52
- data/man/man5/puppet.conf.5 +2072 -1526
- data/man/man8/filebucket.8 +104 -106
- data/man/man8/pi.8 +14 -47
- data/man/man8/puppet.8 +8 -9
- data/man/man8/puppetca.8 +168 -129
- data/man/man8/puppetd.8 +282 -226
- data/man/man8/puppetdoc.8 +103 -103
- data/man/man8/puppetmasterd.8 +51 -71
- data/man/man8/puppetqd.8 +18 -53
- data/man/man8/puppetrun.8 +163 -143
- data/man/man8/ralsh.8 +77 -114
- data/spec/integration/indirector/bucket_file/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate_request/rest_spec.rb +1 -0
- data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +1 -0
- data/spec/integration/indirector/report/rest_spec.rb +1 -0
- data/spec/integration/indirector/rest_spec.rb +1 -0
- data/spec/integration/network/server/webrick_spec.rb +1 -0
- data/spec/integration/parser/compiler_spec.rb +43 -0
- data/spec/integration/provider/mailalias/aliases_spec.rb +5 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +1 -0
- data/spec/integration/ssl/certificate_request_spec.rb +1 -0
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -0
- data/spec/integration/ssl/host_spec.rb +1 -0
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -1
- data/spec/monkey_patches/publicize_methods.rb +11 -0
- data/spec/shared_behaviours/file_serving.rb +12 -1
- data/spec/spec_helper.rb +6 -25
- data/spec/unit/application/apply_spec.rb +22 -4
- data/spec/unit/application/cert_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +0 -19
- data/spec/unit/application/master_spec.rb +1 -1
- data/spec/unit/application_spec.rb +2 -12
- data/spec/unit/indirector/node/ldap_spec.rb +19 -21
- data/spec/unit/indirector/yaml_spec.rb +18 -6
- data/spec/unit/network/http/rack/rest_spec.rb +3 -3
- data/spec/unit/network/http/webrick/rest_spec.rb +1 -0
- data/spec/unit/node/environment_spec.rb +32 -3
- data/spec/unit/node/facts_spec.rb +13 -2
- data/spec/unit/parameter/value_collection_spec.rb +2 -2
- data/spec/unit/parser/ast/leaf_spec.rb +4 -0
- data/spec/unit/parser/ast/resource_reference_spec.rb +0 -5
- data/spec/unit/parser/ast/resource_spec.rb +7 -0
- data/spec/unit/parser/compiler_spec.rb +12 -1
- data/spec/unit/parser/files_spec.rb +3 -3
- data/spec/unit/parser/functions/extlookup_spec.rb +95 -0
- data/spec/unit/parser/functions/include_spec.rb +33 -0
- data/spec/unit/parser/functions/require_spec.rb +1 -1
- data/spec/unit/parser/functions/tag_spec.rb +1 -0
- data/spec/unit/parser/lexer_spec.rb +10 -1
- data/spec/unit/parser/resource_spec.rb +3 -9
- data/spec/unit/parser/type_loader_spec.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +4 -2
- data/spec/unit/rails/resource_spec.rb +1 -1
- data/spec/unit/reports/tagmail_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/resource/type_collection_spec.rb +35 -0
- data/spec/unit/resource/type_spec.rb +19 -1
- data/spec/unit/resource_spec.rb +0 -36
- data/spec/unit/simple_graph_spec.rb +12 -2
- data/spec/unit/transaction/resource_harness_spec.rb +1 -1
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/schedule_spec.rb +1 -1
- data/spec/unit/type/service_spec.rb +8 -0
- data/spec/unit/type/user_spec.rb +5 -0
- data/spec/unit/util/backups_spec.rb +0 -1
- data/spec/unit/util/rdoc/parser_spec.rb +3 -3
- data/spec/unit/util/rdoc_spec.rb +13 -0
- data/test/certmgr/support.rb +2 -1
- data/test/language/parser.rb +6 -6
- data/test/lib/puppettest.rb +3 -23
- data/test/lib/puppettest/fakes.rb +1 -1
- data/test/lib/puppettest/support/assertions.rb +0 -2
- data/test/lib/puppettest/support/utils.rb +25 -20
- data/test/ral/manager/attributes.rb +4 -1
- metadata +15 -9
- data/conf/suse/puppet.suse.patch +0 -16
- data/ext/extlookup.rb +0 -181
- data/ext/puppetlast +0 -16
- data/tasks/rake/tracdocs.rake +0 -8
- data/test/lib/mocha_standalone.rb +0 -2
@@ -3,6 +3,7 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
4
|
|
5
5
|
require 'puppet/application/apply'
|
6
|
+
require 'puppet/file_bucket/dipper'
|
6
7
|
|
7
8
|
describe Puppet::Application::Apply do
|
8
9
|
before :each do
|
@@ -53,7 +54,6 @@ describe Puppet::Application::Apply do
|
|
53
54
|
Puppet.stubs(:trap)
|
54
55
|
Puppet::Log.stubs(:level=)
|
55
56
|
Puppet.stubs(:parse_config)
|
56
|
-
require 'lib/puppet/file_bucket/dipper'
|
57
57
|
Puppet::FileBucket::Dipper.stubs(:new)
|
58
58
|
STDIN.stubs(:read)
|
59
59
|
|
@@ -212,7 +212,8 @@ describe Puppet::Application::Apply do
|
|
212
212
|
@apply.main
|
213
213
|
end
|
214
214
|
|
215
|
-
it "should set the manifest if
|
215
|
+
it "should set the manifest if a file is passed on command line and the file exists" do
|
216
|
+
File.stubs(:exist?).with('site.pp').returns true
|
216
217
|
@apply.command_line.stubs(:args).returns(['site.pp'])
|
217
218
|
|
218
219
|
Puppet.expects(:[]=).with(:manifest,"site.pp")
|
@@ -220,6 +221,23 @@ describe Puppet::Application::Apply do
|
|
220
221
|
@apply.main
|
221
222
|
end
|
222
223
|
|
224
|
+
it "should raise an error if a file is passed on command line and the file does not exist" do
|
225
|
+
File.stubs(:exist?).with('noexist.pp').returns false
|
226
|
+
@apply.command_line.stubs(:args).returns(['noexist.pp'])
|
227
|
+
lambda { @apply.main }.should raise_error(RuntimeError, 'Could not find file noexist.pp')
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should set the manifest to the first file and warn other files will be skipped" do
|
231
|
+
File.stubs(:exist?).with('starwarsIV').returns true
|
232
|
+
File.expects(:exist?).with('starwarsI').never
|
233
|
+
@apply.command_line.stubs(:args).returns(['starwarsIV', 'starwarsI', 'starwarsII'])
|
234
|
+
|
235
|
+
Puppet.expects(:[]=).with(:manifest,"starwarsIV")
|
236
|
+
Puppet.expects(:warning).with('Only one file can be applied per run. Skipping starwarsI, starwarsII')
|
237
|
+
|
238
|
+
@apply.main
|
239
|
+
end
|
240
|
+
|
223
241
|
it "should collect the node facts" do
|
224
242
|
Puppet::Node::Facts.expects(:find).returns(@facts)
|
225
243
|
|
@@ -232,7 +250,7 @@ describe Puppet::Application::Apply do
|
|
232
250
|
lambda { @apply.main }.should raise_error
|
233
251
|
end
|
234
252
|
|
235
|
-
it "should
|
253
|
+
it "should look for the node" do
|
236
254
|
Puppet::Node.expects(:find).returns(@node)
|
237
255
|
|
238
256
|
@apply.main
|
@@ -294,7 +312,7 @@ describe Puppet::Application::Apply do
|
|
294
312
|
end
|
295
313
|
|
296
314
|
it "should apply the catalog" do
|
297
|
-
@catalog.expects(:apply)
|
315
|
+
@catalog.expects(:apply).returns(stub_everything 'transaction')
|
298
316
|
|
299
317
|
@apply.main
|
300
318
|
end
|
@@ -12,7 +12,7 @@ describe Puppet::Application::Cert do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should operate in master run_mode" do
|
15
|
-
@cert_app.class.run_mode.name.should equal
|
15
|
+
@cert_app.class.run_mode.name.should equal(:master)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should ask Puppet::Application to parse Puppet configuration file" do
|
@@ -27,10 +27,6 @@ describe Puppet::Application::Doc do
|
|
27
27
|
@doc.should respond_to(:rdoc)
|
28
28
|
end
|
29
29
|
|
30
|
-
it "should declare a trac command" do
|
31
|
-
@doc.should respond_to(:trac)
|
32
|
-
end
|
33
|
-
|
34
30
|
it "should declare a fallback for unknown options" do
|
35
31
|
@doc.should respond_to(:handle_unknown)
|
36
32
|
end
|
@@ -270,21 +266,6 @@ describe Puppet::Application::Doc do
|
|
270
266
|
end
|
271
267
|
|
272
268
|
describe "when running" do
|
273
|
-
before :each do
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "in trac mode" do
|
277
|
-
it "should call trac for each reference" do
|
278
|
-
ref = stub 'ref'
|
279
|
-
Puppet::Util::Reference.stubs(:reference).with(:ref).returns(ref)
|
280
|
-
@doc.options.stubs(:[]).with(:references).returns([:ref])
|
281
|
-
@doc.options.stubs(:[]).with(:mode).returns(:trac)
|
282
|
-
|
283
|
-
ref.expects(:trac)
|
284
|
-
|
285
|
-
@doc.trac
|
286
|
-
end
|
287
|
-
end
|
288
269
|
|
289
270
|
describe "in rdoc mode" do
|
290
271
|
before :each do
|
@@ -23,7 +23,7 @@ describe Puppet::Application::Master do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should operate in master run_mode" do
|
26
|
-
@master.class.run_mode.name.should equal
|
26
|
+
@master.class.run_mode.name.should equal(:master)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should ask Puppet::Application to parse Puppet configuration file" do
|
@@ -194,7 +194,6 @@ describe Puppet::Application do
|
|
194
194
|
it "should create a new option parser when needed" do
|
195
195
|
option_parser = stub "option parser"
|
196
196
|
option_parser.stubs(:on)
|
197
|
-
option_parser.stubs(:default_argv=)
|
198
197
|
OptionParser.expects(:new).returns(option_parser).once
|
199
198
|
@app.option_parser.should == option_parser
|
200
199
|
@app.option_parser.should == option_parser
|
@@ -203,7 +202,6 @@ describe Puppet::Application do
|
|
203
202
|
it "should pass the banner to the option parser" do
|
204
203
|
option_parser = stub "option parser"
|
205
204
|
option_parser.stubs(:on)
|
206
|
-
option_parser.stubs(:default_argv=)
|
207
205
|
@app.class.instance_eval do
|
208
206
|
banner "banner"
|
209
207
|
end
|
@@ -213,15 +211,6 @@ describe Puppet::Application do
|
|
213
211
|
@app.option_parser
|
214
212
|
end
|
215
213
|
|
216
|
-
it "should set the optionparser's args to the command line args" do
|
217
|
-
option_parser = stub "option parser"
|
218
|
-
option_parser.stubs(:on)
|
219
|
-
option_parser.expects(:default_argv=).with(%w{ fake args })
|
220
|
-
@app.command_line.stubs(:args).returns(%w{ fake args })
|
221
|
-
OptionParser.expects(:new).returns(option_parser)
|
222
|
-
@app.option_parser
|
223
|
-
end
|
224
|
-
|
225
214
|
it "should get options from Puppet.settings.optparse_addargs" do
|
226
215
|
Puppet.settings.expects(:optparse_addargs).returns([])
|
227
216
|
|
@@ -237,7 +226,8 @@ describe Puppet::Application do
|
|
237
226
|
end
|
238
227
|
|
239
228
|
it "should ask OptionParser to parse the command-line argument" do
|
240
|
-
@app.
|
229
|
+
@app.command_line.stubs(:args).returns(%w{ fake args })
|
230
|
+
@app.option_parser.expects(:parse!).with(%w{ fake args })
|
241
231
|
|
242
232
|
@app.parse_options
|
243
233
|
end
|
@@ -5,10 +5,6 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
5
5
|
require 'puppet/indirector/node/ldap'
|
6
6
|
|
7
7
|
describe Puppet::Node::Ldap do
|
8
|
-
before do
|
9
|
-
Puppet::Node::Facts.stubs(:terminus_class).returns :yaml
|
10
|
-
end
|
11
|
-
|
12
8
|
describe "when searching for a single node" do
|
13
9
|
before :each do
|
14
10
|
@searcher = Puppet::Node::Ldap.new
|
@@ -23,17 +19,17 @@ describe Puppet::Node::Ldap do
|
|
23
19
|
end
|
24
20
|
|
25
21
|
it "should convert the hostname into a search filter" do
|
26
|
-
entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {
|
22
|
+
entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
|
27
23
|
@searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry
|
28
|
-
@searcher.name2hash(@name
|
24
|
+
@searcher.name2hash(@name)
|
29
25
|
end
|
30
26
|
|
31
27
|
it "should convert any found entry into a hash" do
|
32
|
-
entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {
|
28
|
+
entry = stub 'entry', :dn => 'cn=mynode.domain.com,ou=hosts,dc=madstop,dc=com', :vals => %w{}, :to_hash => {}
|
33
29
|
@searcher.expects(:ldapsearch).with("(&(objectclass=puppetClient)(cn=#{@name}))").yields entry
|
34
|
-
myhash = {"myhash" => true
|
30
|
+
myhash = {"myhash" => true}
|
35
31
|
@searcher.expects(:entry2hash).with(entry).returns myhash
|
36
|
-
@searcher.name2hash(@name
|
32
|
+
@searcher.name2hash(@name).should == myhash
|
37
33
|
end
|
38
34
|
|
39
35
|
# This heavily tests our entry2hash method, so we don't have to stub out the stupid entry information any more.
|
@@ -128,20 +124,20 @@ describe Puppet::Node::Ldap do
|
|
128
124
|
end
|
129
125
|
|
130
126
|
it "should search first for the provided key" do
|
131
|
-
@searcher.expects(:name2hash).with("mynode.domain.com"
|
127
|
+
@searcher.expects(:name2hash).with("mynode.domain.com").returns({})
|
132
128
|
@searcher.find(@request)
|
133
129
|
end
|
134
130
|
|
135
131
|
it "should search for the short version of the provided key if the key looks like a hostname and no results are found for the key itself" do
|
136
|
-
@searcher.expects(:name2hash).with("mynode.domain.com"
|
137
|
-
@searcher.expects(:name2hash).with("mynode"
|
132
|
+
@searcher.expects(:name2hash).with("mynode.domain.com").returns(nil)
|
133
|
+
@searcher.expects(:name2hash).with("mynode").returns({})
|
138
134
|
@searcher.find(@request)
|
139
135
|
end
|
140
136
|
|
141
137
|
it "should search for default information if no information can be found for the key" do
|
142
|
-
@searcher.expects(:name2hash).with("mynode.domain.com"
|
143
|
-
@searcher.expects(:name2hash).with("mynode"
|
144
|
-
@searcher.expects(:name2hash).with("default"
|
138
|
+
@searcher.expects(:name2hash).with("mynode.domain.com").returns(nil)
|
139
|
+
@searcher.expects(:name2hash).with("mynode").returns(nil)
|
140
|
+
@searcher.expects(:name2hash).with("default").returns({})
|
145
141
|
@searcher.find(@request)
|
146
142
|
end
|
147
143
|
|
@@ -162,8 +158,8 @@ describe Puppet::Node::Ldap do
|
|
162
158
|
end
|
163
159
|
|
164
160
|
it "should create the node with the correct name, even if it was found by a different name" do
|
165
|
-
@searcher.expects(:name2hash).with("mynode.domain.com"
|
166
|
-
@searcher.expects(:name2hash).with("mynode"
|
161
|
+
@searcher.expects(:name2hash).with("mynode.domain.com").returns nil
|
162
|
+
@searcher.expects(:name2hash).with("mynode").returns @result
|
167
163
|
|
168
164
|
Puppet::Node.expects(:new).with("mynode.domain.com").returns @node
|
169
165
|
@searcher.find(@request)
|
@@ -213,15 +209,17 @@ describe Puppet::Node::Ldap do
|
|
213
209
|
@parent = {:classes => [], :parameters => {}}
|
214
210
|
@parent_parent = {:classes => [], :parameters => {}}
|
215
211
|
|
216
|
-
@searcher.stubs(:name2hash).with
|
217
|
-
@searcher.stubs(:name2hash).with
|
218
|
-
@searcher.stubs(:name2hash).with
|
212
|
+
@searcher.stubs(:name2hash).with(@name).returns(@entry)
|
213
|
+
@searcher.stubs(:name2hash).with('parent').returns(@parent)
|
214
|
+
@searcher.stubs(:name2hash).with('parent_parent').returns(@parent_parent)
|
219
215
|
|
220
216
|
@searcher.stubs(:parent_attribute).returns(:parent)
|
221
217
|
end
|
222
218
|
|
223
219
|
it "should search for the parent node" do
|
224
220
|
@entry[:parent] = "parent"
|
221
|
+
@searcher.expects(:name2hash).with(@name).returns @entry
|
222
|
+
@searcher.expects(:name2hash).with('parent').returns @parent
|
225
223
|
|
226
224
|
@searcher.find(@request)
|
227
225
|
end
|
@@ -229,7 +227,7 @@ describe Puppet::Node::Ldap do
|
|
229
227
|
it "should fail if the parent cannot be found" do
|
230
228
|
@entry[:parent] = "parent"
|
231
229
|
|
232
|
-
@searcher.expects(:name2hash).with('parent'
|
230
|
+
@searcher.expects(:name2hash).with('parent').returns nil
|
233
231
|
|
234
232
|
proc { @searcher.find(@request) }.should raise_error(Puppet::Error)
|
235
233
|
end
|
@@ -40,6 +40,18 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
|
|
40
40
|
@store.path(:me).should =~ %r{^/client/yaml/dir}
|
41
41
|
end
|
42
42
|
|
43
|
+
it "should use the extension if one is specified" do
|
44
|
+
Puppet.run_mode.expects(:master?).returns true
|
45
|
+
Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
|
46
|
+
@store.path(:me,'.farfignewton').should =~ %r{\.farfignewton$}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should assume an extension of .yaml if none is specified" do
|
50
|
+
Puppet.run_mode.expects(:master?).returns true
|
51
|
+
Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
|
52
|
+
@store.path(:me).should =~ %r{\.yaml$}
|
53
|
+
end
|
54
|
+
|
43
55
|
it "should store all files in a single file root set in the Puppet defaults" do
|
44
56
|
@store.path(:me).should =~ %r{^#{@dir}}
|
45
57
|
end
|
@@ -120,8 +132,8 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
|
|
120
132
|
@request = stub 'request', :key => "*", :instance => @subject
|
121
133
|
@one = mock 'one'
|
122
134
|
@two = mock 'two'
|
123
|
-
@store.expects(:
|
124
|
-
Dir.expects(:glob).with(
|
135
|
+
@store.expects(:path).with(@request.key,'').returns :glob
|
136
|
+
Dir.expects(:glob).with(:glob).returns(%w{one.yaml two.yaml})
|
125
137
|
YAML.expects(:load_file).with("one.yaml").returns @one;
|
126
138
|
YAML.expects(:load_file).with("two.yaml").returns @two;
|
127
139
|
@store.search(@request).should == [@one, @two]
|
@@ -130,16 +142,16 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
|
|
130
142
|
it "should return an array containing a single instance of fact when globbing 'one*'" do
|
131
143
|
@request = stub 'request', :key => "one*", :instance => @subject
|
132
144
|
@one = mock 'one'
|
133
|
-
@store.expects(:
|
134
|
-
Dir.expects(:glob).with(
|
145
|
+
@store.expects(:path).with(@request.key,'').returns :glob
|
146
|
+
Dir.expects(:glob).with(:glob).returns(%w{one.yaml})
|
135
147
|
YAML.expects(:load_file).with("one.yaml").returns @one;
|
136
148
|
@store.search(@request).should == [@one]
|
137
149
|
end
|
138
150
|
|
139
151
|
it "should return an empty array when the glob doesn't match anything" do
|
140
152
|
@request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject
|
141
|
-
@store.expects(:
|
142
|
-
Dir.expects(:glob).with(
|
153
|
+
@store.expects(:path).with(@request.key,'').returns :glob
|
154
|
+
Dir.expects(:glob).with(:glob).returns []
|
143
155
|
@store.search(@request).should == []
|
144
156
|
end
|
145
157
|
end
|
@@ -82,8 +82,8 @@ describe "Puppet::Network::HTTP::RackREST" do
|
|
82
82
|
@file.stubs(:is_a?).with(File).returns(true)
|
83
83
|
end
|
84
84
|
|
85
|
-
it "should set the Content-Length header" do
|
86
|
-
@response.expects(:[]=).with("Content-Length", 100)
|
85
|
+
it "should set the Content-Length header as a string" do
|
86
|
+
@response.expects(:[]=).with("Content-Length", '100')
|
87
87
|
|
88
88
|
@handler.set_response(@response, @file, 200)
|
89
89
|
end
|
@@ -246,4 +246,4 @@ describe Puppet::Network::HTTP::RackREST::RackFile do
|
|
246
246
|
@file.expects(:close)
|
247
247
|
@rackfile.close
|
248
248
|
end
|
249
|
-
end
|
249
|
+
end
|
@@ -53,6 +53,7 @@ describe Puppet::Node::Environment do
|
|
53
53
|
@env = Puppet::Node::Environment.new("dev")
|
54
54
|
@collection = Puppet::Resource::TypeCollection.new(@env)
|
55
55
|
@collection.stubs(:perform_initial_import)
|
56
|
+
Thread.current[:known_resource_types] = nil
|
56
57
|
end
|
57
58
|
|
58
59
|
it "should create a resource type collection if none exists" do
|
@@ -71,13 +72,41 @@ describe Puppet::Node::Environment do
|
|
71
72
|
@env.known_resource_types
|
72
73
|
end
|
73
74
|
|
74
|
-
it "should
|
75
|
-
|
75
|
+
it "should return the same collection even if stale if it's the same thread" do
|
76
|
+
Puppet::Resource::TypeCollection.stubs(:new).returns @collection
|
77
|
+
@env.known_resource_types.stubs(:stale?).returns true
|
76
78
|
|
77
|
-
|
79
|
+
@env.known_resource_types.should equal(@collection)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return the current thread associated collection if there is one" do
|
83
|
+
Thread.current[:known_resource_types] = @collection
|
78
84
|
|
79
85
|
@env.known_resource_types.should equal(@collection)
|
80
86
|
end
|
87
|
+
|
88
|
+
it "should give to all threads the same collection if it didn't change" do
|
89
|
+
Puppet::Resource::TypeCollection.expects(:new).with(@env).returns @collection
|
90
|
+
@env.known_resource_types
|
91
|
+
|
92
|
+
t = Thread.new {
|
93
|
+
@env.known_resource_types.should equal(@collection)
|
94
|
+
}
|
95
|
+
t.join
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should give to new threads a new collection if it isn't stale" do
|
99
|
+
Puppet::Resource::TypeCollection.expects(:new).with(@env).returns @collection
|
100
|
+
@env.known_resource_types.expects(:stale?).returns(true)
|
101
|
+
|
102
|
+
Puppet::Resource::TypeCollection.expects(:new).returns @collection
|
103
|
+
|
104
|
+
t = Thread.new {
|
105
|
+
@env.known_resource_types.should equal(@collection)
|
106
|
+
}
|
107
|
+
t.join
|
108
|
+
end
|
109
|
+
|
81
110
|
end
|
82
111
|
|
83
112
|
[:modulepath, :manifestdir].each do |setting|
|
@@ -88,9 +88,20 @@ describe Puppet::Node::Facts, "when indirecting" do
|
|
88
88
|
@facts.save
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
describe "when the Puppet application is 'master'" do
|
92
|
+
it "should default to the 'yaml' terminus" do
|
93
|
+
pending "Cannot test the behavior of defaults in defaults.rb"
|
94
|
+
# Puppet::Node::Facts.indirection.terminus_class.should == :yaml
|
95
|
+
end
|
93
96
|
end
|
97
|
+
|
98
|
+
describe "when the Puppet application is not 'master'" do
|
99
|
+
it "should default to the 'facter' terminus" do
|
100
|
+
pending "Cannot test the behavior of defaults in defaults.rb"
|
101
|
+
# Puppet::Node::Facts.indirection.terminus_class.should == :facter
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
94
105
|
end
|
95
106
|
|
96
107
|
describe "when storing and retrieving" do
|
@@ -68,12 +68,12 @@ describe Puppet::Parameter::ValueCollection do
|
|
68
68
|
|
69
69
|
it "should correctly generate documentation for values" do
|
70
70
|
@collection.newvalues :foo
|
71
|
-
@collection.doc.should be_include("Valid values are
|
71
|
+
@collection.doc.should be_include("Valid values are `foo`")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should correctly generate documentation for regexes" do
|
75
75
|
@collection.newvalues %r{\w+}
|
76
|
-
@collection.doc.should be_include("Values can match
|
76
|
+
@collection.doc.should be_include("Values can match `/\\w+/`")
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should be able to find the first matching value" do
|
@@ -47,6 +47,10 @@ describe Puppet::Parser::AST::String do
|
|
47
47
|
value = stub 'value', :is_a? => true, :to_s => "ab"
|
48
48
|
Puppet::Parser::AST::String.new( :value => value ).to_s.should == "\"ab\""
|
49
49
|
end
|
50
|
+
it "should return a dup of its value" do
|
51
|
+
value = ""
|
52
|
+
Puppet::Parser::AST::String.new( :value => value ).evaluate(stub 'scope').should_not be_equal(value)
|
53
|
+
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -32,11 +32,6 @@ describe Puppet::Parser::AST::ResourceReference do
|
|
32
32
|
]
|
33
33
|
end
|
34
34
|
|
35
|
-
it "should pass its scope's namespaces to all created resource references" do
|
36
|
-
@scope.add_namespace "foo"
|
37
|
-
newref("File", "/tmp/yay").evaluate(@scope).namespaces.should == ["foo"]
|
38
|
-
end
|
39
|
-
|
40
35
|
it "should return a correct representation when converting to string" do
|
41
36
|
type = stub 'type', :is_a? => true, :to_s => "file"
|
42
37
|
title = stub 'title', :is_a? => true, :to_s => "[/tmp/a, /tmp/b]"
|