puppet 2.7.3 → 2.7.4
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 +166 -0
- data/install.rb +27 -7
- data/lib/puppet/application/agent.rb +29 -29
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/inspect.rb +9 -1
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/application/queue.rb +1 -1
- data/lib/puppet/application/resource.rb +3 -0
- data/lib/puppet/application.rb +4 -5
- data/lib/puppet/configurer.rb +1 -4
- data/lib/puppet/defaults.rb +45 -15
- data/lib/puppet/feature/base.rb +28 -17
- data/lib/puppet/feature/rails.rb +0 -3
- data/lib/puppet/feature/rubygems.rb +0 -3
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_bucket/file.rb +3 -3
- data/lib/puppet/file_serving/base.rb +4 -5
- data/lib/puppet/file_serving/configuration.rb +7 -13
- data/lib/puppet/file_serving/content.rb +0 -4
- data/lib/puppet/file_serving/fileset.rb +7 -6
- data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
- data/lib/puppet/file_serving/metadata.rb +0 -4
- data/lib/puppet/file_serving/mount/file.rb +9 -12
- data/lib/puppet/file_serving/mount.rb +0 -5
- data/lib/puppet/file_serving/terminus_helper.rb +0 -4
- data/lib/puppet/file_serving.rb +0 -4
- data/lib/puppet/indirector/catalog/compiler.rb +0 -18
- data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
- data/lib/puppet/indirector/direct_file_server.rb +0 -4
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/store_configs.rb +5 -0
- data/lib/puppet/indirector/file_content/file.rb +0 -4
- data/lib/puppet/indirector/file_content/file_server.rb +0 -4
- data/lib/puppet/indirector/file_content/rest.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
- data/lib/puppet/indirector/file_server.rb +1 -5
- data/lib/puppet/indirector/indirection.rb +3 -5
- data/lib/puppet/indirector/node/store_configs.rb +5 -0
- data/lib/puppet/indirector/request.rb +3 -1
- data/lib/puppet/indirector/resource/active_record.rb +97 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +5 -1
- data/lib/puppet/indirector/store_configs.rb +30 -0
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/indirector.rb +7 -0
- data/lib/puppet/network/client.rb +0 -5
- data/lib/puppet/network/http_pool.rb +0 -56
- data/lib/puppet/node/environment.rb +9 -11
- data/lib/puppet/parameter/path.rb +1 -5
- data/lib/puppet/parameter.rb +1 -7
- data/lib/puppet/parser/ast/collection.rb +2 -2
- data/lib/puppet/parser/ast/collexpr.rb +10 -39
- data/lib/puppet/parser/collector.rb +41 -90
- data/lib/puppet/parser/compiler.rb +0 -3
- data/lib/puppet/parser/functions/create_resources.rb +22 -10
- data/lib/puppet/parser/functions/versioncmp.rb +9 -6
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +2 -1
- data/lib/puppet/provider/augeas/augeas.rb +5 -3
- data/lib/puppet/provider/cron/crontab.rb +2 -2
- data/lib/puppet/provider/exec/posix.rb +23 -96
- data/lib/puppet/provider/exec/shell.rb +11 -2
- data/lib/puppet/provider/exec/windows.rb +35 -0
- data/lib/puppet/provider/exec.rb +79 -0
- data/lib/puppet/provider/group/windows_adsi.rb +48 -0
- data/lib/puppet/provider/host/parsed.rb +3 -0
- data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
- data/lib/puppet/provider/mount.rb +0 -3
- data/lib/puppet/provider/naginator.rb +0 -3
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +3 -7
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/aptrpm.rb +0 -1
- data/lib/puppet/provider/package/blastwave.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +5 -6
- data/lib/puppet/provider/package/fink.rb +3 -4
- data/lib/puppet/provider/package/freebsd.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +0 -1
- data/lib/puppet/provider/package/hpux.rb +3 -3
- data/lib/puppet/provider/package/macports.rb +0 -1
- data/lib/puppet/provider/package/msi.rb +82 -0
- data/lib/puppet/provider/package/openbsd.rb +18 -19
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +0 -1
- data/lib/puppet/provider/package/pkgdmg.rb +9 -7
- data/lib/puppet/provider/package/pkgutil.rb +0 -1
- data/lib/puppet/provider/package/ports.rb +0 -1
- data/lib/puppet/provider/package/portupgrade.rb +183 -193
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +0 -1
- data/lib/puppet/provider/package/sunfreeware.rb +0 -2
- data/lib/puppet/provider/package/up2date.rb +0 -1
- data/lib/puppet/provider/package/urpmi.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package.rb +4 -3
- data/lib/puppet/provider/service/systemd.rb +64 -0
- data/lib/puppet/provider/service/windows.rb +110 -0
- data/lib/puppet/provider/user/windows_adsi.rb +71 -0
- data/lib/puppet/rails/resource.rb +1 -1
- data/lib/puppet/relationship.rb +0 -3
- data/lib/puppet/reports/tagmail.rb +15 -11
- data/lib/puppet/resource/catalog.rb +17 -24
- data/lib/puppet/ssl/certificate_authority.rb +7 -5
- data/lib/puppet/ssl/host.rb +6 -10
- data/lib/puppet/type/augeas.rb +19 -13
- data/lib/puppet/type/cron.rb +13 -12
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file/content.rb +7 -3
- data/lib/puppet/type/file/source.rb +14 -9
- data/lib/puppet/type/file.rb +44 -23
- data/lib/puppet/type/filebucket.rb +13 -5
- data/lib/puppet/type/package.rb +14 -1
- data/lib/puppet/type/service.rb +11 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type.rb +8 -17
- data/lib/puppet/util/adsi.rb +278 -0
- data/lib/puppet/util/autoload.rb +0 -2
- data/lib/puppet/util/cacher.rb +15 -67
- data/lib/puppet/util/feature.rb +0 -3
- data/lib/puppet/util/graph.rb +0 -3
- data/lib/puppet/util/ldap/connection.rb +0 -3
- data/lib/puppet/util/ldap/generator.rb +0 -3
- data/lib/puppet/util/ldap.rb +0 -3
- data/lib/puppet/util/log_paths.rb +0 -3
- data/lib/puppet/util/network_device/cisco/device.rb +2 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/pidlock.rb +5 -1
- data/lib/puppet/util/rdoc/parser.rb +3 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/settings/file_setting.rb +3 -2
- data/lib/puppet/util/settings.rb +4 -6
- data/lib/puppet/util/suidmanager.rb +62 -15
- data/lib/puppet/util.rb +113 -131
- data/lib/puppet.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +22 -17
- data/spec/integration/file_serving/content_spec.rb +0 -6
- data/spec/integration/file_serving/metadata_spec.rb +0 -6
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
- data/spec/integration/network/server/webrick_spec.rb +6 -9
- data/spec/integration/node/facts_spec.rb +0 -6
- data/spec/integration/node_spec.rb +3 -4
- data/spec/integration/parser/compiler_spec.rb +2 -1
- data/spec/integration/parser/parser_spec.rb +2 -4
- data/spec/integration/provider/mount_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +13 -3
- data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
- data/spec/integration/reports_spec.rb +0 -4
- data/spec/integration/resource/catalog_spec.rb +0 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
- data/spec/integration/ssl/certificate_request_spec.rb +10 -17
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
- data/spec/integration/ssl/host_spec.rb +8 -14
- data/spec/integration/transaction/report_spec.rb +0 -5
- data/spec/integration/transaction_spec.rb +11 -13
- data/spec/integration/type/file_spec.rb +16 -16
- data/spec/integration/type/tidy_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +2 -2
- data/spec/integration/util_spec.rb +13 -0
- data/spec/lib/puppet_spec/files.rb +18 -10
- data/spec/shared_behaviours/file_server_terminus.rb +1 -5
- data/spec/shared_behaviours/file_serving.rb +0 -4
- data/spec/shared_behaviours/memory_terminus.rb +0 -4
- data/spec/shared_behaviours/path_parameters.rb +20 -18
- data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/unit/agent_spec.rb +0 -4
- data/spec/unit/application/apply_spec.rb +8 -2
- data/spec/unit/application/certificate_spec.rb +2 -0
- data/spec/unit/application/device_spec.rb +8 -6
- data/spec/unit/application/inspect_spec.rb +2 -1
- data/spec/unit/application/master_spec.rb +7 -2
- data/spec/unit/application/queue_spec.rb +3 -4
- data/spec/unit/application/resource_spec.rb +26 -0
- data/spec/unit/application/secret_agent_spec.rb +3 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/configurer/downloader_spec.rb +4 -3
- data/spec/unit/configurer_spec.rb +11 -4
- data/spec/unit/daemon_spec.rb +3 -1
- data/spec/unit/face/ca_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +5 -1
- data/spec/unit/face/secret_agent_spec.rb +3 -1
- data/spec/unit/file_bucket/dipper_spec.rb +4 -4
- data/spec/unit/file_bucket/file_spec.rb +9 -3
- data/spec/unit/file_serving/configuration_spec.rb +26 -37
- data/spec/unit/file_serving/fileset_spec.rb +71 -55
- data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
- data/spec/unit/file_serving/mount/file_spec.rb +163 -169
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
- data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
- data/spec/unit/indirector/facts/facter_spec.rb +0 -4
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_content/file_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
- data/spec/unit/indirector/file_server_spec.rb +1 -5
- data/spec/unit/indirector/indirection_spec.rb +0 -4
- data/spec/unit/indirector/key/ca_spec.rb +0 -4
- data/spec/unit/indirector/key/file_spec.rb +0 -4
- data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -4
- data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
- data/spec/unit/indirector/ssl_file_spec.rb +25 -6
- data/spec/unit/indirector/store_configs_spec.rb +8 -0
- data/spec/unit/indirector/yaml_spec.rb +14 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +5 -5
- data/spec/unit/network/http/mongrel_spec.rb +0 -4
- data/spec/unit/network/http/webrick_spec.rb +5 -9
- data/spec/unit/network/http_pool_spec.rb +4 -75
- data/spec/unit/network/http_spec.rb +0 -4
- data/spec/unit/network/server_spec.rb +0 -4
- data/spec/unit/node/environment_spec.rb +18 -31
- data/spec/unit/node/facts_spec.rb +0 -4
- data/spec/unit/node_spec.rb +1 -8
- data/spec/unit/other/selinux_spec.rb +3 -1
- data/spec/unit/parameter_spec.rb +0 -10
- data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
- data/spec/unit/parser/collector_spec.rb +147 -263
- data/spec/unit/parser/compiler_spec.rb +3 -1
- data/spec/unit/parser/files_spec.rb +7 -4
- data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
- data/spec/unit/parser/type_loader_spec.rb +7 -7
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
- data/spec/unit/provider/exec/posix_spec.rb +102 -106
- data/spec/unit/provider/exec/shell_spec.rb +1 -1
- data/spec/unit/provider/exec/windows_spec.rb +119 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
- data/spec/unit/provider/ldap_spec.rb +0 -4
- data/spec/unit/provider/macauthorization_spec.rb +5 -0
- data/spec/unit/provider/mount/parsed_spec.rb +1 -5
- data/spec/unit/provider/package/msi_spec.rb +170 -0
- data/spec/unit/provider/service/redhat_spec.rb +2 -0
- data/spec/unit/provider/service/smf_spec.rb +3 -0
- data/spec/unit/provider/service/systemd_spec.rb +25 -0
- data/spec/unit/provider/service/windows_spec.rb +166 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/ldap_spec.rb +0 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
- data/spec/unit/relationship_spec.rb +0 -4
- data/spec/unit/resource/catalog_spec.rb +37 -25
- data/spec/unit/resource/status_spec.rb +4 -2
- data/spec/unit/resource_spec.rb +5 -5
- data/spec/unit/simple_graph_spec.rb +0 -4
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
- data/spec/unit/ssl/host_spec.rb +12 -13
- data/spec/unit/ssl/inventory_spec.rb +2 -2
- data/spec/unit/sslcertificates/ca_spec.rb +6 -10
- data/spec/unit/transaction/event_manager_spec.rb +4 -2
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/report_spec.rb +2 -6
- data/spec/unit/transaction/resource_harness_spec.rb +9 -5
- data/spec/unit/transaction_spec.rb +3 -1
- data/spec/unit/type/cron_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +80 -47
- data/spec/unit/type/file/checksum_spec.rb +9 -8
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/file/selinux_spec.rb +10 -8
- data/spec/unit/type/file/source_spec.rb +18 -36
- data/spec/unit/type/file_spec.rb +170 -217
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/noop_metaparam_spec.rb +3 -1
- data/spec/unit/type/package_spec.rb +15 -3
- data/spec/unit/type/resources_spec.rb +2 -2
- data/spec/unit/type/service_spec.rb +19 -4
- data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
- data/spec/unit/type/tidy_spec.rb +3 -1
- data/spec/unit/type/user_spec.rb +1 -1
- data/spec/unit/type_spec.rb +29 -34
- data/spec/unit/util/adsi_spec.rb +202 -0
- data/spec/unit/util/autoload_spec.rb +23 -19
- data/spec/unit/util/backups_spec.rb +16 -13
- data/spec/unit/util/cacher_spec.rb +64 -141
- data/spec/unit/util/checksums_spec.rb +0 -4
- data/spec/unit/util/constant_inflector_spec.rb +0 -4
- data/spec/unit/util/execution_stub_spec.rb +1 -1
- data/spec/unit/util/ldap/connection_spec.rb +0 -4
- data/spec/unit/util/ldap/generator_spec.rb +0 -4
- data/spec/unit/util/ldap/manager_spec.rb +0 -4
- data/spec/unit/util/log_spec.rb +4 -2
- data/spec/unit/util/logging_spec.rb +2 -2
- data/spec/unit/util/nagios_maker_spec.rb +0 -4
- data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
- data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
- data/spec/unit/util/network_device/config_spec.rb +5 -3
- data/spec/unit/util/rdoc/parser_spec.rb +7 -1
- data/spec/unit/util/run_mode_spec.rb +6 -2
- data/spec/unit/util/settings/file_setting_spec.rb +29 -2
- data/spec/unit/util/settings_spec.rb +28 -15
- data/spec/unit/util/storage_spec.rb +1 -1
- data/spec/unit/util/suidmanager_spec.rb +310 -0
- data/spec/unit/util/tagging_spec.rb +0 -4
- data/spec/unit/util_spec.rb +335 -0
- data/test/language/ast/variable.rb +0 -4
- data/test/lib/puppettest/support/resources.rb +0 -4
- data/test/lib/puppettest/testcase.rb +0 -4
- data/test/lib/puppettest.rb +0 -1
- data/test/network/handler/master.rb +0 -5
- data/test/network/server/webrick.rb +5 -22
- data/test/ral/manager/attributes.rb +0 -4
- data/test/ral/manager/instances.rb +0 -4
- data/test/ral/manager/manager.rb +0 -4
- data/test/ral/providers/cron/crontab.rb +1 -0
- data/test/ral/providers/service/base.rb +0 -4
- data/test/ral/type/filesources.rb +0 -1
- data/test/ral/type/resources.rb +0 -4
- data/test/util/utiltest.rb +0 -13
- metadata +36 -9
- data/spec/unit/network/client_spec.rb +0 -45
- data/test/puppet/tc_suidmanager.rb +0 -120
@@ -0,0 +1,335 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Puppet::Util do
|
6
|
+
describe "#absolute_path?" do
|
7
|
+
it "should default to the platform of the local system" do
|
8
|
+
Puppet.features.stubs(:posix?).returns(true)
|
9
|
+
Puppet.features.stubs(:microsoft_windows?).returns(false)
|
10
|
+
|
11
|
+
Puppet::Util.should be_absolute_path('/foo')
|
12
|
+
Puppet::Util.should_not be_absolute_path('C:/foo')
|
13
|
+
|
14
|
+
Puppet.features.stubs(:posix?).returns(false)
|
15
|
+
Puppet.features.stubs(:microsoft_windows?).returns(true)
|
16
|
+
|
17
|
+
Puppet::Util.should be_absolute_path('C:/foo')
|
18
|
+
Puppet::Util.should_not be_absolute_path('/foo')
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when using platform :posix" do
|
22
|
+
%w[/ /foo /foo/../bar //foo //Server/Foo/Bar //?/C:/foo/bar /\Server/Foo].each do |path|
|
23
|
+
it "should return true for #{path}" do
|
24
|
+
Puppet::Util.should be_absolute_path(path, :posix)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
%w[. ./foo \foo C:/foo \\Server\Foo\Bar \\?\C:\foo\bar \/?/foo\bar \/Server/foo].each do |path|
|
29
|
+
it "should return false for #{path}" do
|
30
|
+
Puppet::Util.should_not be_absolute_path(path, :posix)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "when using platform :windows" do
|
36
|
+
%w[C:/foo C:\foo \\\\Server\Foo\Bar \\\\?\C:\foo\bar //Server/Foo/Bar //?/C:/foo/bar /\?\C:/foo\bar \/Server\Foo/Bar].each do |path|
|
37
|
+
it "should return true for #{path}" do
|
38
|
+
Puppet::Util.should be_absolute_path(path, :windows)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
%w[/ . ./foo \foo /foo /foo/../bar //foo C:foo/bar].each do |path|
|
43
|
+
it "should return false for #{path}" do
|
44
|
+
Puppet::Util.should_not be_absolute_path(path, :windows)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "execution methods" do
|
51
|
+
let(:pid) { 5501 }
|
52
|
+
let(:null_file) { Puppet.features.microsoft_windows? ? 'NUL' : '/dev/null' }
|
53
|
+
|
54
|
+
describe "#execute_posix" do
|
55
|
+
before :each do
|
56
|
+
# Most of the things this method does are bad to do during specs. :/
|
57
|
+
Kernel.stubs(:fork).returns(pid).yields
|
58
|
+
Process.stubs(:setsid)
|
59
|
+
Kernel.stubs(:exec)
|
60
|
+
Puppet::Util::SUIDManager.stubs(:change_user)
|
61
|
+
Puppet::Util::SUIDManager.stubs(:change_group)
|
62
|
+
|
63
|
+
$stdin.stubs(:reopen)
|
64
|
+
$stdout.stubs(:reopen)
|
65
|
+
$stderr.stubs(:reopen)
|
66
|
+
|
67
|
+
@stdin = File.open(null_file, 'r')
|
68
|
+
@stdout = Tempfile.new('stdout')
|
69
|
+
@stderr = File.open(null_file, 'w')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should fork a child process to execute the command" do
|
73
|
+
Kernel.expects(:fork).returns(pid).yields
|
74
|
+
Kernel.expects(:exec).with('test command')
|
75
|
+
|
76
|
+
Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should start a new session group" do
|
80
|
+
Process.expects(:setsid)
|
81
|
+
|
82
|
+
Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should close all open file descriptors except stdin/stdout/stderr" do
|
86
|
+
# This is ugly, but I can't really think of a better way to do it without
|
87
|
+
# letting it actually close fds, which seems risky
|
88
|
+
(0..2).each {|n| IO.expects(:new).with(n).never}
|
89
|
+
(3..256).each {|n| IO.expects(:new).with(n).returns mock('io', :close) }
|
90
|
+
|
91
|
+
Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should permanently change to the correct user and group if specified" do
|
95
|
+
Puppet::Util::SUIDManager.expects(:change_group).with(55, true)
|
96
|
+
Puppet::Util::SUIDManager.expects(:change_user).with(50, true)
|
97
|
+
|
98
|
+
Puppet::Util.execute_posix('test command', {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should exit failure if there is a problem execing the command" do
|
102
|
+
Kernel.expects(:exec).with('test command').raises("failed to execute!")
|
103
|
+
Puppet::Util.stubs(:puts)
|
104
|
+
Puppet::Util.expects(:exit!).with(1)
|
105
|
+
|
106
|
+
Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should properly execute commands specified as arrays" do
|
110
|
+
Kernel.expects(:exec).with('test command', 'with', 'arguments')
|
111
|
+
|
112
|
+
Puppet::Util.execute_posix(['test command', 'with', 'arguments'], {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should return the pid of the child process" do
|
116
|
+
Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr).should == pid
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#execute_windows" do
|
121
|
+
let(:proc_info_stub) { stub 'processinfo', :process_id => pid }
|
122
|
+
|
123
|
+
before :each do
|
124
|
+
Process.stubs(:create).returns(proc_info_stub)
|
125
|
+
Process.stubs(:waitpid2).with(pid).returns([pid, 0])
|
126
|
+
|
127
|
+
@stdin = File.open(null_file, 'r')
|
128
|
+
@stdout = Tempfile.new('stdout')
|
129
|
+
@stderr = File.open(null_file, 'w')
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should create a new process for the command" do
|
133
|
+
Process.expects(:create).with(
|
134
|
+
:command_line => "test command",
|
135
|
+
:startup_info => {:stdin => @stdin, :stdout => @stdout, :stderr => @stderr}
|
136
|
+
).returns(proc_info_stub)
|
137
|
+
|
138
|
+
Puppet::Util.execute_windows('test command', {}, @stdin, @stdout, @stderr)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return the pid of the child process" do
|
142
|
+
Puppet::Util.execute_windows('test command', {}, @stdin, @stdout, @stderr).should == pid
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should quote arguments containing spaces if command is specified as an array" do
|
146
|
+
Process.expects(:create).with do |args|
|
147
|
+
args[:command_line] == '"test command" with some "arguments \"with spaces"'
|
148
|
+
end.returns(proc_info_stub)
|
149
|
+
|
150
|
+
Puppet::Util.execute_windows(['test command', 'with', 'some', 'arguments "with spaces'], {}, @stdin, @stdout, @stderr)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#execute" do
|
155
|
+
before :each do
|
156
|
+
Process.stubs(:waitpid2).with(pid).returns([pid, 0])
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "when an execution stub is specified" do
|
160
|
+
before :each do
|
161
|
+
Puppet::Util::ExecutionStub.set do |command,args,stdin,stdout,stderr|
|
162
|
+
"execution stub output"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should call the block on the stub" do
|
167
|
+
Puppet::Util.execute("/usr/bin/run_my_execute_stub").should == "execution stub output"
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should not actually execute anything" do
|
171
|
+
Puppet::Util.expects(:execute_posix).never
|
172
|
+
Puppet::Util.expects(:execute_windows).never
|
173
|
+
|
174
|
+
Puppet::Util.execute("/usr/bin/run_my_execute_stub")
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "when setting up input and output files" do
|
179
|
+
include PuppetSpec::Files
|
180
|
+
let(:executor) { Puppet.features.microsoft_windows? ? 'execute_windows' : 'execute_posix' }
|
181
|
+
|
182
|
+
before :each do
|
183
|
+
Puppet::Util.stubs(:wait_for_output)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should set stdin to the stdinfile if specified" do
|
187
|
+
input = tmpfile('stdin')
|
188
|
+
FileUtils.touch(input)
|
189
|
+
|
190
|
+
Puppet::Util.expects(executor).with do |_,_,stdin,_,_|
|
191
|
+
stdin.path == input
|
192
|
+
end.returns(pid)
|
193
|
+
|
194
|
+
Puppet::Util.execute('test command', :stdinfile => input)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should set stdin to the null file if not specified" do
|
198
|
+
Puppet::Util.expects(executor).with do |_,_,stdin,_,_|
|
199
|
+
stdin.path == null_file
|
200
|
+
end.returns(pid)
|
201
|
+
|
202
|
+
Puppet::Util.execute('test command')
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "when squelch is set" do
|
206
|
+
it "should set stdout and stderr to the null file" do
|
207
|
+
Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
|
208
|
+
stdout.path == null_file and stderr.path == null_file
|
209
|
+
end.returns(pid)
|
210
|
+
|
211
|
+
Puppet::Util.execute('test command', :squelch => true)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe "when squelch is not set" do
|
216
|
+
it "should set stdout to a temporary output file" do
|
217
|
+
outfile = Tempfile.new('stdout')
|
218
|
+
Tempfile.stubs(:new).returns(outfile)
|
219
|
+
|
220
|
+
Puppet::Util.expects(executor).with do |_,_,_,stdout,_|
|
221
|
+
stdout.path == outfile.path
|
222
|
+
end.returns(pid)
|
223
|
+
|
224
|
+
Puppet::Util.execute('test command', :squelch => false)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should set stderr to the same file as stdout if combine is true" do
|
228
|
+
outfile = Tempfile.new('stdout')
|
229
|
+
Tempfile.stubs(:new).returns(outfile)
|
230
|
+
|
231
|
+
Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
|
232
|
+
stdout.path == outfile.path and stderr.path == outfile.path
|
233
|
+
end.returns(pid)
|
234
|
+
|
235
|
+
Puppet::Util.execute('test command', :squelch => false, :combine => true)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should set stderr to the null device if combine is false" do
|
239
|
+
outfile = Tempfile.new('stdout')
|
240
|
+
Tempfile.stubs(:new).returns(outfile)
|
241
|
+
|
242
|
+
Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
|
243
|
+
stdout.path == outfile.path and stderr.path == null_file
|
244
|
+
end.returns(pid)
|
245
|
+
|
246
|
+
Puppet::Util.execute('test command', :squelch => false, :combine => false)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe "after execution" do
|
253
|
+
let(:executor) { Puppet.features.microsoft_windows? ? 'execute_windows' : 'execute_posix' }
|
254
|
+
before :each do
|
255
|
+
Process.stubs(:waitpid2).with(pid).returns([pid, 0])
|
256
|
+
|
257
|
+
Puppet::Util.stubs(executor).returns(pid)
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should wait for the child process to exit" do
|
261
|
+
Puppet::Util.stubs(:wait_for_output)
|
262
|
+
|
263
|
+
Process.expects(:waitpid2).with(pid).returns([pid, 0])
|
264
|
+
|
265
|
+
Puppet::Util.execute('test command')
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should close the stdin/stdout/stderr files used by the child" do
|
269
|
+
stdin = mock 'file', :close
|
270
|
+
stdout = mock 'file', :close
|
271
|
+
stderr = mock 'file', :close
|
272
|
+
|
273
|
+
File.expects(:open).
|
274
|
+
times(3).
|
275
|
+
returns(stdin).
|
276
|
+
then.returns(stdout).
|
277
|
+
then.returns(stderr)
|
278
|
+
|
279
|
+
Puppet::Util.execute('test command', :squelch => true)
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should read and return the output if squelch is false" do
|
283
|
+
stdout = Tempfile.new('test')
|
284
|
+
Tempfile.stubs(:new).returns(stdout)
|
285
|
+
stdout.write("My expected command output")
|
286
|
+
|
287
|
+
Puppet::Util.execute('test command').should == "My expected command output"
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should not read the output if squelch is true" do
|
291
|
+
stdout = Tempfile.new('test')
|
292
|
+
Tempfile.stubs(:new).returns(stdout)
|
293
|
+
stdout.write("My expected command output")
|
294
|
+
|
295
|
+
Puppet::Util.execute('test command', :squelch => true).should == nil
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should delete the file used for output if squelch is false" do
|
299
|
+
stdout = Tempfile.new('test')
|
300
|
+
path = stdout.path
|
301
|
+
Tempfile.stubs(:new).returns(stdout)
|
302
|
+
|
303
|
+
Puppet::Util.execute('test command')
|
304
|
+
|
305
|
+
File.should_not be_exist(path)
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should raise an error if failonfail is true and the child failed" do
|
309
|
+
child_status = stub('child_status', :exitstatus => 1)
|
310
|
+
|
311
|
+
Process.expects(:waitpid2).with(pid).returns([pid, child_status])
|
312
|
+
|
313
|
+
expect {
|
314
|
+
Puppet::Util.execute('fail command', :failonfail => true)
|
315
|
+
}.to raise_error(Puppet::ExecutionFailure, /Execution of 'fail command' returned 1/)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should not raise an error if failonfail is false and the child failed" do
|
319
|
+
Process.expects(:waitpid2).with(pid).returns([pid, 1])
|
320
|
+
|
321
|
+
expect {
|
322
|
+
Puppet::Util.execute('fail command', :failonfail => false)
|
323
|
+
}.not_to raise_error
|
324
|
+
end
|
325
|
+
|
326
|
+
it "should not raise an error if failonfail is true and the child succeeded" do
|
327
|
+
Process.expects(:waitpid2).with(pid).returns([pid, 0])
|
328
|
+
|
329
|
+
expect {
|
330
|
+
Puppet::Util.execute('fail command', :failonfail => true)
|
331
|
+
}.not_to raise_error
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
@@ -1,8 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Luke A. Kanies on 2006-11-29.
|
4
|
-
# Copyright (c) 2006. All rights reserved.
|
5
|
-
|
6
2
|
module PuppetTest::Support::Resources
|
7
3
|
def tree_resource(name)
|
8
4
|
Puppet::Type.type(:file).new :title => name, :path => "/tmp/#{name}", :mode => 0755
|
data/test/lib/puppettest.rb
CHANGED
@@ -16,11 +16,6 @@ class TestMaster < Test::Unit::TestCase
|
|
16
16
|
Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
|
17
17
|
end
|
18
18
|
|
19
|
-
def teardown
|
20
|
-
super
|
21
|
-
Puppet::Util::Cacher.expire
|
22
|
-
end
|
23
|
-
|
24
19
|
def test_freshness_is_always_now
|
25
20
|
now1 = mock 'now1'
|
26
21
|
Time.stubs(:now).returns(now1)
|
@@ -11,24 +11,17 @@ class TestWebrickServer < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def setup
|
13
13
|
Puppet::Util::SUIDManager.stubs(:asuser).yields
|
14
|
+
Puppet::SSL::Host.instance_variable_set(:@localhost, nil)
|
14
15
|
super
|
15
16
|
end
|
16
17
|
|
17
|
-
def teardown
|
18
|
-
super
|
19
|
-
Puppet::Network::HttpPool.clear_http_instances
|
20
|
-
end
|
21
|
-
|
22
18
|
# Make sure we can create a server, and that it knows how to create its
|
23
19
|
# certs by default.
|
24
20
|
def test_basics
|
25
21
|
server = nil
|
26
22
|
assert_raise(Puppet::Error, "server succeeded with no cert") do
|
27
|
-
|
28
|
-
server = Puppet::Network::HTTPServer::WEBrick.new(
|
29
|
-
|
23
|
+
server = Puppet::Network::HTTPServer::WEBrick.new(
|
30
24
|
:Port => @@port,
|
31
|
-
|
32
25
|
:Handlers => {
|
33
26
|
:Status => nil
|
34
27
|
}
|
@@ -36,11 +29,8 @@ class TestWebrickServer < Test::Unit::TestCase
|
|
36
29
|
end
|
37
30
|
|
38
31
|
assert_nothing_raised("Could not create simple server") do
|
39
|
-
|
40
|
-
server = Puppet::Network::HTTPServer::WEBrick.new(
|
41
|
-
|
32
|
+
server = Puppet::Network::HTTPServer::WEBrick.new(
|
42
33
|
:Port => @@port,
|
43
|
-
|
44
34
|
:Handlers => {
|
45
35
|
:CA => {}, # so that certs autogenerate
|
46
36
|
:Status => nil
|
@@ -76,11 +66,8 @@ class TestWebrickServer < Test::Unit::TestCase
|
|
76
66
|
client = nil
|
77
67
|
|
78
68
|
assert_nothing_raised {
|
79
|
-
|
80
|
-
client = Puppet::Network::Client.status.new(
|
81
|
-
|
69
|
+
client = Puppet::Network::Client.status.new(
|
82
70
|
:Server => "localhost",
|
83
|
-
|
84
71
|
:Port => @@port
|
85
72
|
)
|
86
73
|
}
|
@@ -91,17 +78,13 @@ class TestWebrickServer < Test::Unit::TestCase
|
|
91
78
|
server = nil
|
92
79
|
Puppet[:certdnsnames] = "localhost"
|
93
80
|
assert_nothing_raised {
|
94
|
-
|
95
|
-
server = Puppet::Network::HTTPServer::WEBrick.new(
|
96
|
-
|
81
|
+
server = Puppet::Network::HTTPServer::WEBrick.new(
|
97
82
|
:Port => @@port,
|
98
|
-
|
99
83
|
:Handlers => {
|
100
84
|
:CA => {}, # so that certs autogenerate
|
101
85
|
:Status => nil
|
102
86
|
}
|
103
87
|
)
|
104
|
-
|
105
88
|
}
|
106
89
|
|
107
90
|
pid = fork {
|
data/test/ral/manager/manager.rb
CHANGED
data/test/ral/type/resources.rb
CHANGED
data/test/util/utiltest.rb
CHANGED
@@ -219,18 +219,5 @@ class TestPuppetUtil < Test::Unit::TestCase
|
|
219
219
|
end
|
220
220
|
|
221
221
|
end
|
222
|
-
|
223
|
-
# Check whether execute accepts strings in addition to arrays.
|
224
|
-
def test_string_exec
|
225
|
-
cmd = "/bin/echo howdy"
|
226
|
-
output = nil
|
227
|
-
assert_raise(ArgumentError) {
|
228
|
-
output = Puppet::Util.execute(cmd)
|
229
|
-
}
|
230
|
-
#assert_equal("howdy\n", output)
|
231
|
-
#assert_raise(RuntimeError) {
|
232
|
-
# Puppet::Util.execute(cmd, 0, 0)
|
233
|
-
#}
|
234
|
-
end
|
235
222
|
end
|
236
223
|
|