puppet 2.7.11 → 2.7.12
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 +188 -0
- data/conf/osx/createpackage.sh +1 -0
- data/conf/redhat/puppet.spec +12 -9
- data/conf/suse/puppet.spec +4 -1
- data/install.rb +9 -22
- data/lib/puppet.rb +1 -31
- data/lib/puppet/agent.rb +3 -5
- data/lib/puppet/agent/locker.rb +15 -1
- data/lib/puppet/application.rb +7 -4
- data/lib/puppet/application/agent.rb +4 -25
- data/lib/puppet/application/apply.rb +3 -3
- data/lib/puppet/application/device.rb +2 -16
- data/lib/puppet/application/doc.rb +2 -2
- data/lib/puppet/application/face_base.rb +22 -5
- data/lib/puppet/application/filebucket.rb +2 -0
- data/lib/puppet/application/inspect.rb +2 -1
- data/lib/puppet/application/kick.rb +25 -9
- data/lib/puppet/application/queue.rb +0 -23
- data/lib/puppet/configurer.rb +1 -0
- data/lib/puppet/configurer/downloader.rb +7 -3
- data/lib/puppet/defaults.rb +34 -29
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/catalog.rb +1 -0
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/list.rb +23 -3
- data/lib/puppet/face/module/search.rb +21 -32
- data/lib/puppet/face/module/uninstall.rb +56 -15
- data/lib/puppet/file_bucket/dipper.rb +2 -2
- data/lib/puppet/file_serving/base.rb +6 -5
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/forge.rb +153 -0
- data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
- data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
- data/lib/puppet/interface/action.rb +6 -2
- data/lib/puppet/module.rb +70 -10
- data/lib/puppet/module_tool.rb +2 -38
- data/lib/puppet/module_tool/applications.rb +15 -11
- data/lib/puppet/module_tool/applications/application.rb +2 -5
- data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +10 -45
- data/lib/puppet/module_tool/applications/searcher.rb +2 -26
- data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +1 -1
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/http/handler.rb +4 -1
- data/lib/puppet/network/http/webrick.rb +4 -2
- data/lib/puppet/node/environment.rb +32 -6
- data/lib/puppet/parameter/path.rb +0 -4
- data/lib/puppet/parser/ast/relationship.rb +3 -16
- data/lib/puppet/parser/collector.rb +5 -3
- data/lib/puppet/parser/compiler.rb +2 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +8 -2
- data/lib/puppet/parser/grammar.ra +16 -15
- data/lib/puppet/parser/parser.rb +959 -881
- data/lib/puppet/parser/relationship.rb +32 -15
- data/lib/puppet/parser/resource.rb +0 -1
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +17 -29
- data/lib/puppet/provider/exec/windows.rb +25 -3
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +21 -23
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +7 -1
- data/lib/puppet/provider/package/openbsd.rb +13 -16
- data/lib/puppet/provider/package/pacman.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +3 -0
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +35 -3
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +4 -0
- data/lib/puppet/provider/service/src.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/service/windows.rb +5 -4
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/pw.rb +6 -0
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/resource/catalog.rb +6 -6
- data/lib/puppet/resource/type.rb +2 -0
- data/lib/puppet/ssl/certificate_request.rb +0 -70
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -2
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/cron.rb +5 -2
- data/lib/puppet/type/exec.rb +8 -0
- data/lib/puppet/type/file.rb +27 -18
- data/lib/puppet/type/file/checksum.rb +2 -2
- data/lib/puppet/type/file/content.rb +14 -9
- data/lib/puppet/type/file/ensure.rb +5 -4
- data/lib/puppet/type/file/group.rb +10 -2
- data/lib/puppet/type/file/mode.rb +46 -18
- data/lib/puppet/type/file/owner.rb +10 -2
- data/lib/puppet/type/file/source.rb +27 -40
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/group.rb +13 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/package.rb +24 -8
- data/lib/puppet/type/scheduled_task.rb +77 -131
- data/lib/puppet/type/service.rb +22 -8
- data/lib/puppet/type/user.rb +29 -9
- data/lib/puppet/util.rb +24 -33
- data/lib/puppet/util/colors.rb +98 -0
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/log.rb +5 -1
- data/lib/puppet/util/log/destinations.rb +37 -44
- data/lib/puppet/util/monkey_patches.rb +32 -0
- data/lib/puppet/util/pidlock.rb +70 -21
- data/lib/puppet/util/rdoc/parser.rb +4 -2
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -12
- data/lib/puppet/util/windows.rb +2 -0
- data/lib/puppet/util/windows/process.rb +33 -0
- data/lib/puppet/util/windows/security.rb +6 -4
- data/lib/puppet/util/windows/user.rb +44 -0
- data/lib/semver.rb +55 -4
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
- data/spec/integration/defaults_spec.rb +10 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
- data/spec/integration/module_tool_spec.rb +10 -12
- data/spec/integration/parser/compiler_spec.rb +147 -0
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/windows/user_spec.rb +59 -0
- data/spec/lib/puppet/face/basetest.rb +5 -0
- data/spec/lib/puppet_spec/modules.rb +26 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agent/locker_spec.rb +12 -0
- data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
- data/spec/unit/agent_spec.rb +28 -8
- data/spec/unit/application/agent_spec.rb +4 -36
- data/spec/unit/application/device_spec.rb +55 -10
- data/spec/unit/application/face_base_spec.rb +32 -10
- data/spec/unit/application/filebucket_spec.rb +5 -0
- data/spec/unit/application/kick_spec.rb +6 -0
- data/spec/unit/application_spec.rb +8 -1
- data/spec/unit/configurer/downloader_spec.rb +4 -5
- data/spec/unit/face/ca_spec.rb +15 -4
- data/spec/unit/file_bucket/dipper_spec.rb +1 -1
- data/spec/unit/file_serving/base_spec.rb +60 -42
- data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
- data/spec/unit/file_serving/content_spec.rb +26 -27
- data/spec/unit/file_serving/metadata_spec.rb +22 -21
- data/spec/unit/forge/repository_spec.rb +86 -0
- data/spec/unit/forge_spec.rb +114 -0
- data/spec/unit/indirector/exec_spec.rb +8 -6
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
- data/spec/unit/interface/action_builder_spec.rb +7 -5
- data/spec/unit/module_spec.rb +228 -9
- data/spec/unit/module_tool/application_spec.rb +3 -3
- data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
- data/spec/unit/module_tool_spec.rb +0 -33
- data/spec/unit/network/authconfig_spec.rb +22 -21
- data/spec/unit/network/http/webrick_spec.rb +13 -9
- data/spec/unit/node/environment_spec.rb +159 -66
- data/spec/unit/parser/collector_spec.rb +16 -8
- data/spec/unit/parser/functions/generate_spec.rb +60 -18
- data/spec/unit/parser/resource_spec.rb +44 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
- data/spec/unit/provider/confine/feature_spec.rb +3 -5
- data/spec/unit/provider/package/dpkg_spec.rb +4 -2
- data/spec/unit/provider/package/gem_spec.rb +59 -43
- data/spec/unit/provider/package/openbsd_spec.rb +114 -0
- data/spec/unit/provider/package/pacman_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +10 -4
- data/spec/unit/provider/package/zypper_spec.rb +56 -14
- data/spec/unit/provider/selmodule_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +22 -21
- data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
- data/spec/unit/provider/user/pw_spec.rb +19 -0
- data/spec/unit/resource/catalog_spec.rb +3 -3
- data/spec/unit/semver_spec.rb +117 -24
- data/spec/unit/transaction/report_spec.rb +11 -1
- data/spec/unit/type/cron_spec.rb +200 -213
- data/spec/unit/type/exec_spec.rb +7 -0
- data/spec/unit/type/file/content_spec.rb +2 -2
- data/spec/unit/type/file_spec.rb +12 -9
- data/spec/unit/type/package_spec.rb +25 -0
- data/spec/unit/type/schedule_spec.rb +31 -31
- data/spec/unit/util/diff_spec.rb +30 -0
- data/spec/unit/util/execution_stub_spec.rb +1 -2
- data/spec/unit/util/log/destinations_spec.rb +51 -0
- data/spec/unit/util/log_spec.rb +17 -1
- data/spec/unit/util/monkey_patches_spec.rb +119 -0
- data/spec/unit/util/rdoc/parser_spec.rb +25 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/suidmanager_spec.rb +6 -51
- data/spec/unit/util_spec.rb +82 -24
- data/test/lib/puppettest/certificates.rb +16 -0
- data/test/lib/puppettest/servertest.rb +4 -0
- data/test/util/pidlock.rb +125 -0
- metadata +23 -14
- data/ext/puppetstoredconfigclean.rb +0 -103
- data/lib/puppet/agent/disabler.rb +0 -27
- data/lib/puppet/util/anonymous_filelock.rb +0 -36
- data/spec/unit/agent/disabler_spec.rb +0 -60
- data/spec/unit/module_tool/repository_spec.rb +0 -52
- data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
- data/spec/unit/util/pidlock_spec.rb +0 -208
data/spec/unit/agent_spec.rb
CHANGED
@@ -24,7 +24,6 @@ describe Puppet::Agent do
|
|
24
24
|
|
25
25
|
# So we don't actually try to hit the filesystem.
|
26
26
|
@agent.stubs(:lock).yields
|
27
|
-
@agent.stubs(:disabled?).returns(false)
|
28
27
|
|
29
28
|
# make Puppet::Application safe for stubbing; restore in an :after block; silence warnings for this.
|
30
29
|
without_warnings { Puppet::Application = Class.new(Puppet::Application) }
|
@@ -58,6 +57,7 @@ describe Puppet::Agent do
|
|
58
57
|
client.expects(:run)
|
59
58
|
|
60
59
|
@agent.stubs(:running?).returns false
|
60
|
+
@agent.stubs(:disabled?).returns false
|
61
61
|
@agent.run
|
62
62
|
end
|
63
63
|
|
@@ -66,24 +66,34 @@ describe Puppet::Agent do
|
|
66
66
|
@agent.lockfile_path.should == "/my/lock"
|
67
67
|
end
|
68
68
|
|
69
|
-
it "should be considered running if the lock file is locked" do
|
69
|
+
it "should be considered running if the lock file is locked and not anonymous" do
|
70
70
|
lockfile = mock 'lockfile'
|
71
71
|
|
72
|
-
@agent.expects(:lockfile).returns
|
72
|
+
@agent.expects(:lockfile).returns(lockfile).twice
|
73
73
|
lockfile.expects(:locked?).returns true
|
74
|
+
lockfile.expects(:anonymous?).returns false
|
74
75
|
|
75
76
|
@agent.should be_running
|
76
77
|
end
|
77
78
|
|
79
|
+
it "should be considered disabled if the lock file is locked and anonymous" do
|
80
|
+
lockfile = mock 'lockfile'
|
81
|
+
|
82
|
+
@agent.expects(:lockfile).returns(lockfile).at_least_once
|
83
|
+
lockfile.expects(:locked?).returns(true).at_least_once
|
84
|
+
lockfile.expects(:anonymous?).returns(true).at_least_once
|
85
|
+
|
86
|
+
@agent.should be_disabled
|
87
|
+
end
|
88
|
+
|
78
89
|
describe "when being run" do
|
79
90
|
before do
|
80
|
-
AgentTestClient.stubs(:lockfile_path).returns "/my/lock"
|
81
91
|
@agent.stubs(:running?).returns false
|
92
|
+
@agent.stubs(:disabled?).returns false
|
82
93
|
end
|
83
94
|
|
84
95
|
it "should splay" do
|
85
96
|
@agent.expects(:splay)
|
86
|
-
@agent.stubs(:running?).returns false
|
87
97
|
|
88
98
|
@agent.run
|
89
99
|
end
|
@@ -94,9 +104,19 @@ describe Puppet::Agent do
|
|
94
104
|
@agent.run
|
95
105
|
end
|
96
106
|
|
97
|
-
it "should
|
98
|
-
|
99
|
-
|
107
|
+
it "(#11057) should notify the user about why a run is skipped" do
|
108
|
+
Puppet::Application.stubs(:controlled_run).returns(false)
|
109
|
+
Puppet::Application.stubs(:run_status).returns('MOCK_RUN_STATUS')
|
110
|
+
# This is the actual test that we inform the user why the run is skipped.
|
111
|
+
# We assume this information is contained in
|
112
|
+
# Puppet::Application.run_status
|
113
|
+
Puppet.expects(:notice).with(regexp_matches(/MOCK_RUN_STATUS/))
|
114
|
+
@agent.run
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should display an informative message if the agent is administratively disabled" do
|
118
|
+
@agent.expects(:disabled?).returns true
|
119
|
+
Puppet.expects(:notice).with(regexp_matches(/Skipping run of .*; administratively disabled/))
|
100
120
|
@agent.run
|
101
121
|
end
|
102
122
|
|
@@ -91,7 +91,7 @@ describe Puppet::Application::Agent do
|
|
91
91
|
@puppetd.command_line.stubs(:args).returns([])
|
92
92
|
end
|
93
93
|
|
94
|
-
[:centrallogging, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
|
94
|
+
[:centrallogging, :disable, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
|
95
95
|
it "should declare handle_#{option} method" do
|
96
96
|
@puppetd.should respond_to("handle_#{option}".to_sym)
|
97
97
|
end
|
@@ -102,24 +102,6 @@ describe Puppet::Application::Agent do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe "when handling --disable" do
|
106
|
-
it "should declare handle_disable method" do
|
107
|
-
@puppetd.should respond_to(:handle_disable)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should set disable to true" do
|
111
|
-
@puppetd.options.stubs(:[]=)
|
112
|
-
@puppetd.options.expects(:[]=).with(:disable, true)
|
113
|
-
@puppetd.handle_disable('')
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should store disable message" do
|
117
|
-
@puppetd.options.stubs(:[]=)
|
118
|
-
@puppetd.options.expects(:[]=).with(:disable_message, "message")
|
119
|
-
@puppetd.handle_disable('message')
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
105
|
it "should set an existing handler on server" do
|
124
106
|
Puppet::Network::Handler.stubs(:handler).with("handler").returns(true)
|
125
107
|
|
@@ -260,10 +242,10 @@ describe Puppet::Application::Agent do
|
|
260
242
|
end
|
261
243
|
end
|
262
244
|
|
263
|
-
it "should set
|
245
|
+
it "should set a default log destination if no --logdest" do
|
264
246
|
@puppetd.options.stubs(:[]).with(:setdest).returns(false)
|
265
247
|
|
266
|
-
Puppet::Util::Log.expects(:
|
248
|
+
Puppet::Util::Log.expects(:setup_default)
|
267
249
|
|
268
250
|
@puppetd.setup_logs
|
269
251
|
end
|
@@ -286,7 +268,7 @@ describe Puppet::Application::Agent do
|
|
286
268
|
it "should set a central log destination with --centrallogs" do
|
287
269
|
@puppetd.options.stubs(:[]).with(:centrallogs).returns(true)
|
288
270
|
Puppet[:server] = "puppet.reductivelabs.com"
|
289
|
-
Puppet::Util::Log.stubs(:
|
271
|
+
Puppet::Util::Log.stubs(:setup_default)
|
290
272
|
|
291
273
|
Puppet::Util::Log.expects(:newdestination).with("puppet.reductivelabs.com")
|
292
274
|
|
@@ -367,20 +349,6 @@ describe Puppet::Application::Agent do
|
|
367
349
|
end
|
368
350
|
end
|
369
351
|
|
370
|
-
it "should pass the disable message when disabling" do
|
371
|
-
@puppetd.options.stubs(:[]).with(:disable).returns(true)
|
372
|
-
@puppetd.options.stubs(:[]).with(:disable_message).returns("message")
|
373
|
-
@agent.expects(:disable).with("message")
|
374
|
-
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
|
375
|
-
end
|
376
|
-
|
377
|
-
it "should pass the default disable message when disabling without a message" do
|
378
|
-
@puppetd.options.stubs(:[]).with(:disable).returns(true)
|
379
|
-
@puppetd.options.stubs(:[]).with(:disable_message).returns(nil)
|
380
|
-
@agent.expects(:disable).with("reason not specified")
|
381
|
-
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
|
382
|
-
end
|
383
|
-
|
384
352
|
it "should finally exit" do
|
385
353
|
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
|
386
354
|
end
|
@@ -163,10 +163,10 @@ describe Puppet::Application::Device do
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
it "should set
|
166
|
+
it "should set a default log destination if no --logdest" do
|
167
167
|
@device.options.stubs(:[]).with(:setdest).returns(false)
|
168
168
|
|
169
|
-
Puppet::Util::Log.expects(:
|
169
|
+
Puppet::Util::Log.expects(:setup_default)
|
170
170
|
|
171
171
|
@device.setup_logs
|
172
172
|
end
|
@@ -320,22 +320,67 @@ describe Puppet::Application::Device do
|
|
320
320
|
|
321
321
|
[:vardir, :confdir].each do |setting|
|
322
322
|
it "should cleanup the #{setting} setting after the run" do
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
323
|
+
all_devices = Set.new(@device_hash.keys.map do |device_name| make_absolute("/dummy/devices/#{device_name}") end)
|
324
|
+
found_devices = Set.new()
|
325
|
+
|
326
|
+
# a block to use in a few places later to validate the arguments passed to "set_value"
|
327
|
+
p = Proc.new do |my_setting, my_value, my_type|
|
328
|
+
success =
|
329
|
+
(my_setting == setting) &&
|
330
|
+
(my_type == :cli) &&
|
331
|
+
(all_devices.include?(my_value))
|
332
|
+
found_devices.add(my_value) if success
|
333
|
+
success
|
334
|
+
end
|
335
|
+
|
336
|
+
seq = sequence("clean up dirs")
|
337
|
+
|
338
|
+
all_devices.size.times do
|
339
|
+
## one occurrence of set / run / set("/dummy") for each device
|
340
|
+
Puppet.settings.expects(:set_value).with(&p).in_sequence(seq)
|
341
|
+
@configurer.expects(:run).in_sequence(seq)
|
342
|
+
Puppet.settings.expects(:set_value).with(setting, make_absolute("/dummy"), :cli).in_sequence(seq)
|
343
|
+
end
|
344
|
+
|
327
345
|
|
328
346
|
@device.main
|
347
|
+
|
348
|
+
# make sure that we were called with each of the defined devices
|
349
|
+
all_devices.should == found_devices
|
350
|
+
|
329
351
|
end
|
330
352
|
end
|
331
353
|
|
332
354
|
it "should cleanup the certname setting after the run" do
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
355
|
+
all_devices = Set.new(@device_hash.keys)
|
356
|
+
found_devices = Set.new()
|
357
|
+
|
358
|
+
# a block to use in a few places later to validate the arguments passed to "set_value"
|
359
|
+
p = Proc.new do |my_setting, my_value, my_type|
|
360
|
+
success =
|
361
|
+
(my_setting == :certname) &&
|
362
|
+
(my_type == :cli) &&
|
363
|
+
(all_devices.include?(my_value))
|
364
|
+
found_devices.add(my_value) if success
|
365
|
+
success
|
366
|
+
#true
|
367
|
+
end
|
368
|
+
|
369
|
+
seq = sequence("clean up certname")
|
370
|
+
|
371
|
+
all_devices.size.times do
|
372
|
+
## one occurrence of set / run / set("certname") for each device
|
373
|
+
Puppet.settings.expects(:set_value).with(&p).in_sequence(seq)
|
374
|
+
@configurer.expects(:run).in_sequence(seq)
|
375
|
+
Puppet.settings.expects(:set_value).with(:certname, "certname", :cli).in_sequence(seq)
|
376
|
+
end
|
377
|
+
|
337
378
|
|
338
379
|
@device.main
|
380
|
+
|
381
|
+
# make sure that we were called with each of the defined devices
|
382
|
+
all_devices.should == found_devices
|
383
|
+
|
339
384
|
end
|
340
385
|
|
341
386
|
it "should expire all cached attributes" do
|
@@ -224,7 +224,7 @@ describe Puppet::Application::FaceBase do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should use its render method to render any result" do
|
227
|
-
app.expects(:render).with(app.arguments.length + 1)
|
227
|
+
app.expects(:render).with(app.arguments.length + 1, ["myname", "myarg"])
|
228
228
|
expect { app.main }.to exit_with 0
|
229
229
|
end
|
230
230
|
end
|
@@ -257,6 +257,11 @@ describe Puppet::Application::FaceBase do
|
|
257
257
|
app.action = app.face.get_action :return_raise
|
258
258
|
expect { app.main }.not_to exit_with 0
|
259
259
|
end
|
260
|
+
|
261
|
+
it "should use the exit code set by the action" do
|
262
|
+
app.action = app.face.get_action :with_specific_exit_code
|
263
|
+
expect { app.main }.to exit_with 5
|
264
|
+
end
|
260
265
|
end
|
261
266
|
|
262
267
|
describe "#render" do
|
@@ -270,19 +275,19 @@ describe Puppet::Application::FaceBase do
|
|
270
275
|
|
271
276
|
["hello", 1, 1.0].each do |input|
|
272
277
|
it "should just return a #{input.class.name}" do
|
273
|
-
app.render(input).should == input
|
278
|
+
app.render(input, {}).should == input
|
274
279
|
end
|
275
280
|
end
|
276
281
|
|
277
282
|
[[1, 2], ["one"], [{ 1 => 1 }]].each do |input|
|
278
283
|
it "should render #{input.class} using JSON" do
|
279
|
-
app.render(input).should == input.to_pson.chomp
|
284
|
+
app.render(input, {}).should == input.to_pson.chomp
|
280
285
|
end
|
281
286
|
end
|
282
287
|
|
283
288
|
it "should render a non-trivially-keyed Hash with using JSON" do
|
284
289
|
hash = { [1,2] => 3, [2,3] => 5, [3,4] => 7 }
|
285
|
-
app.render(hash).should == hash.to_pson.chomp
|
290
|
+
app.render(hash, {}).should == hash.to_pson.chomp
|
286
291
|
end
|
287
292
|
|
288
293
|
it "should render a {String,Numeric}-keyed Hash into a table" do
|
@@ -292,7 +297,7 @@ describe Puppet::Application::FaceBase do
|
|
292
297
|
|
293
298
|
# Gotta love ASCII-betical sort order. Hope your objects are better
|
294
299
|
# structured for display than my test one is. --daniel 2011-04-18
|
295
|
-
app.render(hash).should == <<EOT
|
300
|
+
app.render(hash, {}).should == <<EOT
|
296
301
|
5 5
|
297
302
|
6.0 6
|
298
303
|
four #{object.to_pson.chomp}
|
@@ -308,7 +313,7 @@ EOT
|
|
308
313
|
"number" => { "1" => '1' * 40, "2" => '2' * 40, '3' => '3' * 40 },
|
309
314
|
"text" => { "a" => 'a' * 40, 'b' => 'b' * 40, 'c' => 'c' * 40 }
|
310
315
|
}
|
311
|
-
app.render(hash).should == <<EOT
|
316
|
+
app.render(hash, {}).should == <<EOT
|
312
317
|
number {"1"=>"1111111111111111111111111111111111111111",
|
313
318
|
"2"=>"2222222222222222222222222222222222222222",
|
314
319
|
"3"=>"3333333333333333333333333333333333333333"}
|
@@ -318,14 +323,31 @@ text {"a"=>"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
318
323
|
EOT
|
319
324
|
end
|
320
325
|
|
321
|
-
|
322
|
-
|
323
|
-
|
326
|
+
describe "when setting the rendering method" do
|
327
|
+
after do
|
328
|
+
# need to reset the when_rendering block so that other tests can set it later
|
329
|
+
app.action.instance_variable_set("@when_rendering", {})
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should invoke the action rendering hook while rendering" do
|
333
|
+
app.action.set_rendering_method_for(:console, proc { |value| "bi-winning!" })
|
334
|
+
app.render("bi-polar?", {}).should == "bi-winning!"
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should invoke the action rendering hook with args and options while rendering" do
|
338
|
+
app.action.instance_variable_set("@when_rendering", {})
|
339
|
+
app.action.when_invoked = proc { |name, options| 'just need to match arity for rendering' }
|
340
|
+
app.action.set_rendering_method_for(
|
341
|
+
:console,
|
342
|
+
proc { |value, name, options| "I'm #{name}, no wait, I'm #{options[:altername]}" }
|
343
|
+
)
|
344
|
+
app.render("bi-polar?", ['bob', {:altername => 'sue'}]).should == "I'm bob, no wait, I'm sue"
|
345
|
+
end
|
324
346
|
end
|
325
347
|
|
326
348
|
it "should render JSON when asked for json" do
|
327
349
|
app.render_as = :json
|
328
|
-
json = app.render({ :one => 1, :two => 2 })
|
350
|
+
json = app.render({ :one => 1, :two => 2 }, {})
|
329
351
|
json.should =~ /"one":\s*1\b/
|
330
352
|
json.should =~ /"two":\s*2\b/
|
331
353
|
PSON.parse(json).should == { "one" => 1, "two" => 2 }
|
@@ -182,6 +182,11 @@ describe Puppet::Application::Filebucket do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
describe "the command backup" do
|
185
|
+
it "should fail if no arguments are specified" do
|
186
|
+
@filebucket.stubs(:args).returns([])
|
187
|
+
lambda { @filebucket.backup }.should raise_error
|
188
|
+
end
|
189
|
+
|
185
190
|
it "should call the client backup method for each given parameter" do
|
186
191
|
@filebucket.stubs(:puts)
|
187
192
|
FileTest.stubs(:exists?).returns(true)
|
@@ -126,6 +126,12 @@ describe Puppet::Application::Kick, :if => Puppet.features.posix? do
|
|
126
126
|
@kick.options.stubs(:[]).with(any_parameters)
|
127
127
|
end
|
128
128
|
|
129
|
+
it "should abort stating that kick is not supported on Windows" do
|
130
|
+
Puppet.features.stubs(:microsoft_windows?).returns(true)
|
131
|
+
|
132
|
+
expect { @kick.setup }.to raise_error(Puppet::Error, /Puppet kick is not supported on Microsoft Windows/)
|
133
|
+
end
|
134
|
+
|
129
135
|
it "should set log level to debug if --debug was passed" do
|
130
136
|
@kick.options.stubs(:[]).with(:debug).returns(true)
|
131
137
|
@kick.setup
|
@@ -38,6 +38,12 @@ describe Puppet::Application do
|
|
38
38
|
|
39
39
|
expect { @klass.find("ThisShallNeverEverEverExist") }.to exit_with 1
|
40
40
|
end
|
41
|
+
|
42
|
+
it "#12114: should prevent File namespace collisions" do
|
43
|
+
# have to require the file face once, then the second time around it would fail
|
44
|
+
@klass.find("File").should == Puppet::Application::File
|
45
|
+
@klass.find("File").should == Puppet::Application::File
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
49
|
describe ".run_mode" do
|
@@ -62,6 +68,7 @@ describe Puppet::Application do
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
71
|
+
Puppet.features.stubs(:syslog?).returns(true)
|
65
72
|
Puppet[:run_mode].should == "user"
|
66
73
|
|
67
74
|
expect {
|
@@ -384,7 +391,7 @@ describe Puppet::Application do
|
|
384
391
|
it "should honor setdest option" do
|
385
392
|
@app.options.stubs(:[]).with(:setdest).returns(false)
|
386
393
|
|
387
|
-
Puppet::Util::Log.expects(:
|
394
|
+
Puppet::Util::Log.expects(:setup_default)
|
388
395
|
|
389
396
|
@app.setup
|
390
397
|
end
|
@@ -79,14 +79,13 @@ describe Puppet::Configurer::Downloader do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "on Windows", :if => Puppet.features.microsoft_windows? do
|
82
|
-
it "should
|
83
|
-
|
84
|
-
Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 'foo' }
|
82
|
+
it "should omit the owner" do
|
83
|
+
Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == nil }
|
85
84
|
@dler.file
|
86
85
|
end
|
87
86
|
|
88
|
-
it "should
|
89
|
-
Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] ==
|
87
|
+
it "should omit the group" do
|
88
|
+
Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == nil }
|
90
89
|
@dler.file
|
91
90
|
end
|
92
91
|
end
|
data/spec/unit/face/ca_spec.rb
CHANGED
@@ -312,16 +312,27 @@ describe Puppet::Face[:ca, '0.1.0'], :unless => Puppet.features.microsoft_window
|
|
312
312
|
end
|
313
313
|
|
314
314
|
context "with no hosts in CA" do
|
315
|
-
[
|
316
|
-
|
317
|
-
|
315
|
+
[
|
316
|
+
{},
|
317
|
+
{ :pending => true },
|
318
|
+
{ :signed => true },
|
319
|
+
{ :all => true },
|
320
|
+
].each do |type|
|
321
|
+
it "should return nothing for #{type.inspect}" do
|
322
|
+
subject.list(type).should == []
|
318
323
|
end
|
319
324
|
|
320
325
|
it "should not fail when a matcher is passed" do
|
321
326
|
expect {
|
322
|
-
subject.list(type
|
327
|
+
subject.list(type.merge :subject => '.').should == []
|
323
328
|
}.should_not raise_error
|
324
329
|
end
|
330
|
+
|
331
|
+
context "when_rendering :console" do
|
332
|
+
it "should return nothing for #{type.inspect}" do
|
333
|
+
action.when_rendering(:console).call(subject.list(type)).should == ""
|
334
|
+
end
|
335
|
+
end
|
325
336
|
end
|
326
337
|
end
|
327
338
|
|
@@ -123,7 +123,7 @@ describe Puppet::FileBucket::Dipper do
|
|
123
123
|
klass.any_instance.expects(:find).with { |r| request = r }.returns(Puppet::FileBucket::File.new(contents))
|
124
124
|
|
125
125
|
dipper.restore(dest, md5).should == md5
|
126
|
-
Digest::MD5.hexdigest(
|
126
|
+
Digest::MD5.hexdigest(IO.binread(dest)).should == md5
|
127
127
|
|
128
128
|
request.key.should == "md5/#{md5}"
|
129
129
|
request.server.should == server
|