puppet 2.7.5 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/CHANGELOG +121 -0
  2. data/conf/redhat/puppet.spec +16 -7
  3. data/lib/puppet.rb +1 -1
  4. data/lib/puppet/application/cert.rb +17 -3
  5. data/lib/puppet/application/device.rb +1 -0
  6. data/lib/puppet/application/kick.rb +0 -2
  7. data/lib/puppet/application/resource.rb +73 -66
  8. data/lib/puppet/configurer/plugin_handler.rb +6 -2
  9. data/lib/puppet/defaults.rb +60 -5
  10. data/lib/puppet/face/ca.rb +11 -2
  11. data/lib/puppet/face/certificate.rb +33 -4
  12. data/lib/puppet/file_serving/fileset.rb +1 -1
  13. data/lib/puppet/file_serving/indirection_hooks.rb +2 -2
  14. data/lib/puppet/file_serving/metadata.rb +43 -4
  15. data/lib/puppet/indirector.rb +0 -1
  16. data/lib/puppet/indirector/request.rb +3 -4
  17. data/lib/puppet/indirector/resource/active_record.rb +3 -10
  18. data/lib/puppet/indirector/resource/ral.rb +2 -2
  19. data/lib/puppet/indirector/rest.rb +1 -1
  20. data/lib/puppet/network/handler/ca.rb +16 -106
  21. data/lib/puppet/network/handler/master.rb +0 -3
  22. data/lib/puppet/network/handler/runner.rb +1 -0
  23. data/lib/puppet/parser/scope.rb +10 -0
  24. data/lib/puppet/provider/file/posix.rb +72 -34
  25. data/lib/puppet/provider/file/windows.rb +100 -0
  26. data/lib/puppet/provider/group/windows_adsi.rb +2 -2
  27. data/lib/puppet/provider/user/windows_adsi.rb +19 -4
  28. data/lib/puppet/resource.rb +16 -0
  29. data/lib/puppet/resource/catalog.rb +1 -1
  30. data/lib/puppet/ssl/certificate.rb +2 -2
  31. data/lib/puppet/ssl/certificate_authority.rb +86 -10
  32. data/lib/puppet/ssl/certificate_authority/interface.rb +64 -19
  33. data/lib/puppet/ssl/certificate_factory.rb +112 -91
  34. data/lib/puppet/ssl/certificate_request.rb +88 -1
  35. data/lib/puppet/ssl/host.rb +20 -3
  36. data/lib/puppet/type/file.rb +15 -34
  37. data/lib/puppet/type/file/group.rb +11 -91
  38. data/lib/puppet/type/file/mode.rb +11 -41
  39. data/lib/puppet/type/file/owner.rb +18 -34
  40. data/lib/puppet/type/file/source.rb +22 -7
  41. data/lib/puppet/type/group.rb +4 -3
  42. data/lib/puppet/type/user.rb +4 -1
  43. data/lib/puppet/util.rb +59 -6
  44. data/lib/puppet/util/adsi.rb +11 -0
  45. data/lib/puppet/util/log.rb +4 -0
  46. data/lib/puppet/util/log/destinations.rb +7 -1
  47. data/lib/puppet/util/monkey_patches.rb +19 -0
  48. data/lib/puppet/util/network_device/config.rb +4 -5
  49. data/lib/puppet/util/settings.rb +5 -0
  50. data/lib/puppet/util/suidmanager.rb +0 -1
  51. data/lib/puppet/util/windows.rb +4 -0
  52. data/lib/puppet/util/windows/error.rb +16 -0
  53. data/lib/puppet/util/windows/security.rb +593 -0
  54. data/spec/integration/defaults_spec.rb +27 -0
  55. data/spec/integration/network/handler_spec.rb +1 -1
  56. data/spec/integration/type/file_spec.rb +382 -145
  57. data/spec/integration/util/windows/security_spec.rb +468 -0
  58. data/spec/shared_behaviours/file_serving.rb +4 -3
  59. data/spec/unit/application/agent_spec.rb +1 -0
  60. data/spec/unit/application/device_spec.rb +5 -0
  61. data/spec/unit/application/resource_spec.rb +62 -101
  62. data/spec/unit/configurer/downloader_spec.rb +2 -2
  63. data/spec/unit/configurer/plugin_handler_spec.rb +15 -8
  64. data/spec/unit/configurer_spec.rb +2 -2
  65. data/spec/unit/face/ca_spec.rb +34 -0
  66. data/spec/unit/face/certificate_spec.rb +168 -1
  67. data/spec/unit/file_serving/fileset_spec.rb +1 -1
  68. data/spec/unit/file_serving/indirection_hooks_spec.rb +1 -1
  69. data/spec/unit/file_serving/metadata_spec.rb +151 -107
  70. data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -3
  71. data/spec/unit/indirector/direct_file_server_spec.rb +10 -9
  72. data/spec/unit/indirector/file_metadata/file_spec.rb +6 -4
  73. data/spec/unit/indirector/request_spec.rb +13 -3
  74. data/spec/unit/indirector/resource/active_record_spec.rb +4 -10
  75. data/spec/unit/indirector/resource/ral_spec.rb +6 -4
  76. data/spec/unit/indirector/rest_spec.rb +5 -6
  77. data/spec/unit/network/handler/ca_spec.rb +86 -0
  78. data/spec/unit/parser/collector_spec.rb +7 -7
  79. data/spec/unit/parser/scope_spec.rb +20 -0
  80. data/spec/unit/provider/file/posix_spec.rb +226 -0
  81. data/spec/unit/provider/file/windows_spec.rb +136 -0
  82. data/spec/unit/provider/group/windows_adsi_spec.rb +7 -2
  83. data/spec/unit/provider/user/windows_adsi_spec.rb +36 -3
  84. data/spec/unit/resource/catalog_spec.rb +20 -10
  85. data/spec/unit/resource_spec.rb +55 -8
  86. data/spec/unit/ssl/certificate_authority/interface_spec.rb +97 -54
  87. data/spec/unit/ssl/certificate_authority_spec.rb +133 -23
  88. data/spec/unit/ssl/certificate_factory_spec.rb +90 -70
  89. data/spec/unit/ssl/certificate_request_spec.rb +62 -1
  90. data/spec/unit/ssl/certificate_spec.rb +20 -14
  91. data/spec/unit/ssl/host_spec.rb +52 -6
  92. data/spec/unit/type/file/content_spec.rb +4 -4
  93. data/spec/unit/type/file/group_spec.rb +34 -96
  94. data/spec/unit/type/file/mode_spec.rb +88 -0
  95. data/spec/unit/type/file/owner_spec.rb +32 -123
  96. data/spec/unit/type/file/source_spec.rb +120 -41
  97. data/spec/unit/type/file_spec.rb +1033 -753
  98. data/spec/unit/type_spec.rb +19 -1
  99. data/spec/unit/util/adsi_spec.rb +19 -0
  100. data/spec/unit/util/log/destinations_spec.rb +75 -0
  101. data/spec/unit/util/log_spec.rb +15 -0
  102. data/spec/unit/util/network_device/config_spec.rb +7 -0
  103. data/spec/unit/util/settings_spec.rb +10 -0
  104. data/spec/unit/util_spec.rb +126 -13
  105. data/test/language/functions.rb +0 -1
  106. data/test/language/snippets.rb +0 -9
  107. data/test/lib/puppettest/exetest.rb +1 -1
  108. data/test/lib/puppettest/servertest.rb +0 -1
  109. data/test/rails/rails.rb +0 -1
  110. data/test/ral/type/filesources.rb +0 -60
  111. metadata +13 -33
  112. data/lib/puppet/network/client.rb +0 -174
  113. data/lib/puppet/network/client/ca.rb +0 -56
  114. data/lib/puppet/network/client/file.rb +0 -6
  115. data/lib/puppet/network/client/proxy.rb +0 -27
  116. data/lib/puppet/network/client/report.rb +0 -26
  117. data/lib/puppet/network/client/runner.rb +0 -10
  118. data/lib/puppet/network/client/status.rb +0 -4
  119. data/lib/puppet/network/http_server.rb +0 -3
  120. data/lib/puppet/network/http_server/mongrel.rb +0 -130
  121. data/lib/puppet/network/http_server/webrick.rb +0 -155
  122. data/lib/puppet/network/xmlrpc/client.rb +0 -211
  123. data/lib/puppet/provider/file/win32.rb +0 -72
  124. data/lib/puppet/sslcertificates.rb +0 -146
  125. data/lib/puppet/sslcertificates/ca.rb +0 -375
  126. data/lib/puppet/sslcertificates/certificate.rb +0 -255
  127. data/lib/puppet/sslcertificates/inventory.rb +0 -38
  128. data/lib/puppet/sslcertificates/support.rb +0 -146
  129. data/spec/integration/network/client_spec.rb +0 -18
  130. data/spec/unit/network/xmlrpc/client_spec.rb +0 -172
  131. data/spec/unit/sslcertificates/ca_spec.rb +0 -106
  132. data/test/certmgr/certmgr.rb +0 -308
  133. data/test/certmgr/inventory.rb +0 -69
  134. data/test/certmgr/support.rb +0 -105
  135. data/test/network/client/ca.rb +0 -69
  136. data/test/network/client/dipper.rb +0 -34
  137. data/test/network/handler/ca.rb +0 -273
  138. data/test/network/server/mongrel_test.rb +0 -99
  139. data/test/network/server/webrick.rb +0 -111
  140. data/test/network/xmlrpc/client.rb +0 -45
@@ -152,13 +152,31 @@ describe Puppet::Type, :fails_on_windows => true do
152
152
 
153
153
  describe "when creating a provider" do
154
154
  before :each do
155
- @type = Puppet::Type.newtype(:provider_test_type)
155
+ @type = Puppet::Type.newtype(:provider_test_type) do
156
+ newparam(:name) { isnamevar }
157
+ newparam(:foo)
158
+ newproperty(:bar)
159
+ end
156
160
  end
157
161
 
158
162
  after :each do
159
163
  @type.provider_hash.clear
160
164
  end
161
165
 
166
+ describe "when determining if instances of the type are managed" do
167
+ it "should not consider audit only resources to be managed" do
168
+ @type.new(:name => "foo", :audit => 'all').managed?.should be_false
169
+ end
170
+
171
+ it "should not consider resources with only parameters to be managed" do
172
+ @type.new(:name => "foo", :foo => 'did someone say food?').managed?.should be_false
173
+ end
174
+
175
+ it "should consider resources with any properties set to be managed" do
176
+ @type.new(:name => "foo", :bar => 'Let us all go there').managed?.should be_true
177
+ end
178
+ end
179
+
162
180
  it "should create a subclass of Puppet::Provider for the provider" do
163
181
  provider = @type.provide(:test_provider)
164
182
 
@@ -12,6 +12,10 @@ describe Puppet::Util::ADSI do
12
12
  Puppet::Util::ADSI.stubs(:connect).returns connection
13
13
  end
14
14
 
15
+ after(:each) do
16
+ Puppet::Util::ADSI.instance_variable_set(:@computer_name, nil)
17
+ end
18
+
15
19
  it "should generate the correct URI for a resource" do
16
20
  Puppet::Util::ADSI.uri('test', 'user').should == "WinNT://testcomputername/test,user"
17
21
  end
@@ -24,6 +28,21 @@ describe Puppet::Util::ADSI do
24
28
  Puppet::Util::ADSI.computer_uri.should == "WinNT://testcomputername"
25
29
  end
26
30
 
31
+ describe ".sid_for_account" do
32
+ it "should return the SID" do
33
+ result = [stub('account', :Sid => 'S-1-1-50')]
34
+ connection.expects(:execquery).returns(result)
35
+
36
+ Puppet::Util::ADSI.sid_for_account('joe').should == 'S-1-1-50'
37
+ end
38
+
39
+ it "should return nil if the account does not exist" do
40
+ connection.expects(:execquery).returns([])
41
+
42
+ Puppet::Util::ADSI.sid_for_account('foobar').should be_nil
43
+ end
44
+ end
45
+
27
46
  describe Puppet::Util::ADSI::User do
28
47
  let(:username) { 'testuser' }
29
48
 
@@ -32,5 +32,80 @@ describe Puppet::Util::Log.desttypes[:file] do
32
32
  it "should default to autoflush false" do
33
33
  @class.new('/tmp/log').autoflush.should == false
34
34
  end
35
+
36
+ describe "when matching" do
37
+ shared_examples_for "file destination" do
38
+ it "should match an absolute path" do
39
+ @class.match?(abspath).should be_true
40
+ end
41
+
42
+ it "should not match a relative path" do
43
+ @class.match?(relpath).should be_false
44
+ end
45
+ end
46
+
47
+ describe "on POSIX systems" do
48
+ before :each do Puppet.features.stubs(:microsoft_windows?).returns false end
49
+
50
+ let (:abspath) { '/tmp/log' }
51
+ let (:relpath) { 'log' }
52
+
53
+ it_behaves_like "file destination"
54
+ end
55
+
56
+ describe "on Windows systems" do
57
+ before :each do Puppet.features.stubs(:microsoft_windows?).returns true end
58
+
59
+ let (:abspath) { 'C:\\temp\\log.txt' }
60
+ let (:relpath) { 'log.txt' }
61
+
62
+ it_behaves_like "file destination"
63
+ end
64
+ end
65
+ end
66
+
67
+ describe Puppet::Util::Log.desttypes[:syslog] do
68
+ let (:klass) { Puppet::Util::Log.desttypes[:syslog] }
69
+
70
+ # these tests can only be run when syslog is present, because
71
+ # we can't stub the top-level Syslog module
72
+ describe "when syslog is available", :if => Puppet.features.syslog? do
73
+ before :each do
74
+ Syslog.stubs(:opened?).returns(false)
75
+ Syslog.stubs(:const_get).returns("LOG_KERN").returns(0)
76
+ Syslog.stubs(:open)
77
+ end
78
+
79
+ it "should open syslog" do
80
+ Syslog.expects(:open)
81
+
82
+ klass.new
83
+ end
84
+
85
+ it "should close syslog" do
86
+ Syslog.expects(:close)
87
+
88
+ dest = klass.new
89
+ dest.close
90
+ end
91
+
92
+ it "should send messages to syslog" do
93
+ syslog = mock 'syslog'
94
+ syslog.expects(:info).with("don't panic")
95
+ Syslog.stubs(:open).returns(syslog)
96
+
97
+ msg = Puppet::Util::Log.new(:level => :info, :message => "don't panic")
98
+ dest = klass.new
99
+ dest.handle(msg)
100
+ end
101
+ end
102
+
103
+ describe "when syslog is unavailable" do
104
+ it "should not be a suitable log destination" do
105
+ Puppet.features.stubs(:syslog?).returns(false)
106
+
107
+ klass.suitable?(:syslog).should be_false
108
+ end
109
+ end
35
110
  end
36
111
 
@@ -50,6 +50,12 @@ describe Puppet::Util::Log do
50
50
  end
51
51
  end
52
52
 
53
+ describe Puppet::Util::Log::DestSyslog do
54
+ before do
55
+ @syslog = Puppet::Util::Log::DestSyslog.new
56
+ end
57
+ end
58
+
53
59
  describe "instances" do
54
60
  before do
55
61
  Puppet::Util::Log.stubs(:newmessage)
@@ -167,6 +173,15 @@ describe Puppet::Util::Log do
167
173
  report.should be_include(log.time.to_s)
168
174
  end
169
175
 
176
+ it "should not create unsuitable log destinations" do
177
+ Puppet.features.stubs(:syslog?).returns(false)
178
+
179
+ Puppet::Util::Log::DestSyslog.expects(:suitable?)
180
+ Puppet::Util::Log::DestSyslog.expects(:new).never
181
+
182
+ Puppet::Util::Log.newdestination(:syslog)
183
+ end
184
+
170
185
  describe "when setting the source as a RAL object" do
171
186
  it "should tag itself with any tags the source has" do
172
187
  source = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar")
@@ -78,6 +78,13 @@ describe Puppet::Util::NetworkDevice::Config do
78
78
  lambda { @config.read }.should raise_error
79
79
  end
80
80
 
81
+ it "should accept device certname containing dashes" do
82
+ @fd.stubs(:each).yields('[router-1.puppetlabs.com]')
83
+
84
+ @config.read
85
+ @config.devices.should include('router-1.puppetlabs.com')
86
+ end
87
+
81
88
  it "should create a new device for each found device line" do
82
89
  @fd.stubs(:each).multiple_yields('[router.puppetlabs.com]', '[swith.puppetlabs.com]')
83
90
 
@@ -131,6 +131,16 @@ describe Puppet::Util::Settings do
131
131
  @settings[:myval].should == ""
132
132
  end
133
133
 
134
+ it "should flag settings from the CLI" do
135
+ @settings.handlearg("--myval")
136
+ @settings.setting(:myval).setbycli.should be_true
137
+ end
138
+
139
+ it "should not flag settings memory" do
140
+ @settings[:myval] = "12"
141
+ @settings.setting(:myval).setbycli.should be_false
142
+ end
143
+
134
144
  it "should clear the cache when setting getopt-specific values" do
135
145
  @settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"]
136
146
  @settings[:two].should == "whah yay"
@@ -3,6 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Puppet::Util do
6
+ def process_status(exitstatus)
7
+ return exitstatus if Puppet.features.microsoft_windows?
8
+
9
+ stub('child_status', :exitstatus => exitstatus)
10
+ end
11
+
6
12
  describe "#absolute_path?" do
7
13
  it "should default to the platform of the local system" do
8
14
  Puppet.features.stubs(:posix?).returns(true)
@@ -19,13 +25,13 @@ describe Puppet::Util do
19
25
  end
20
26
 
21
27
  describe "when using platform :posix" do
22
- %w[/ /foo /foo/../bar //foo //Server/Foo/Bar //?/C:/foo/bar /\Server/Foo].each do |path|
28
+ %w[/ /foo /foo/../bar //foo //Server/Foo/Bar //?/C:/foo/bar /\Server/Foo /foo//bar/baz].each do |path|
23
29
  it "should return true for #{path}" do
24
30
  Puppet::Util.should be_absolute_path(path, :posix)
25
31
  end
26
32
  end
27
33
 
28
- %w[. ./foo \foo C:/foo \\Server\Foo\Bar \\?\C:\foo\bar \/?/foo\bar \/Server/foo].each do |path|
34
+ %w[. ./foo \foo C:/foo \\Server\Foo\Bar \\?\C:\foo\bar \/?/foo\bar \/Server/foo foo//bar/baz].each do |path|
29
35
  it "should return false for #{path}" do
30
36
  Puppet::Util.should_not be_absolute_path(path, :posix)
31
37
  end
@@ -33,13 +39,13 @@ describe Puppet::Util do
33
39
  end
34
40
 
35
41
  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|
42
+ %w[C:/foo C:\foo \\\\Server\Foo\Bar \\\\?\C:\foo\bar //Server/Foo/Bar //?/C:/foo/bar /\?\C:/foo\bar \/Server\Foo/Bar c:/foo//bar//baz].each do |path|
37
43
  it "should return true for #{path}" do
38
44
  Puppet::Util.should be_absolute_path(path, :windows)
39
45
  end
40
46
  end
41
47
 
42
- %w[/ . ./foo \foo /foo /foo/../bar //foo C:foo/bar].each do |path|
48
+ %w[/ . ./foo \foo /foo /foo/../bar //foo C:foo/bar foo//bar/baz].each do |path|
43
49
  it "should return false for #{path}" do
44
50
  Puppet::Util.should_not be_absolute_path(path, :windows)
45
51
  end
@@ -47,6 +53,108 @@ describe Puppet::Util do
47
53
  end
48
54
  end
49
55
 
56
+ describe "#path_to_uri" do
57
+ %w[. .. foo foo/bar foo/../bar].each do |path|
58
+ it "should reject relative path: #{path}" do
59
+ lambda { Puppet::Util.path_to_uri(path) }.should raise_error(Puppet::Error)
60
+ end
61
+ end
62
+
63
+ it "should perform URI escaping" do
64
+ Puppet::Util.path_to_uri("/foo bar").path.should == "/foo%20bar"
65
+ end
66
+
67
+ describe "when using platform :posix" do
68
+ before :each do
69
+ Puppet.features.stubs(:posix).returns true
70
+ Puppet.features.stubs(:microsoft_windows?).returns false
71
+ end
72
+
73
+ %w[/ /foo /foo/../bar].each do |path|
74
+ it "should convert #{path} to URI" do
75
+ Puppet::Util.path_to_uri(path).path.should == path
76
+ end
77
+ end
78
+ end
79
+
80
+ describe "when using platform :windows" do
81
+ before :each do
82
+ Puppet.features.stubs(:posix).returns false
83
+ Puppet.features.stubs(:microsoft_windows?).returns true
84
+ end
85
+
86
+ it "should normalize backslashes" do
87
+ Puppet::Util.path_to_uri('c:\\foo\\bar\\baz').path.should == '/' + 'c:/foo/bar/baz'
88
+ end
89
+
90
+ %w[C:/ C:/foo/bar].each do |path|
91
+ it "should convert #{path} to absolute URI" do
92
+ Puppet::Util.path_to_uri(path).path.should == '/' + path
93
+ end
94
+ end
95
+
96
+ %w[share C$].each do |path|
97
+ it "should convert UNC #{path} to absolute URI" do
98
+ uri = Puppet::Util.path_to_uri("\\\\server\\#{path}")
99
+ uri.host.should == 'server'
100
+ uri.path.should == '/' + path
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ describe ".uri_to_path" do
107
+ require 'uri'
108
+
109
+ it "should strip host component" do
110
+ Puppet::Util.uri_to_path(URI.parse('http://foo/bar')).should == '/bar'
111
+ end
112
+
113
+ it "should accept puppet URLs" do
114
+ Puppet::Util.uri_to_path(URI.parse('puppet:///modules/foo')).should == '/modules/foo'
115
+ end
116
+
117
+ it "should return unencoded path" do
118
+ Puppet::Util.uri_to_path(URI.parse('http://foo/bar%20baz')).should == '/bar baz'
119
+ end
120
+
121
+ it "should be nil-safe" do
122
+ Puppet::Util.uri_to_path(nil).should be_nil
123
+ end
124
+
125
+ describe "when using platform :posix",:if => Puppet.features.posix? do
126
+ it "should accept root" do
127
+ Puppet::Util.uri_to_path(URI.parse('file:/')).should == '/'
128
+ end
129
+
130
+ it "should accept single slash" do
131
+ Puppet::Util.uri_to_path(URI.parse('file:/foo/bar')).should == '/foo/bar'
132
+ end
133
+
134
+ it "should accept triple slashes" do
135
+ Puppet::Util.uri_to_path(URI.parse('file:///foo/bar')).should == '/foo/bar'
136
+ end
137
+ end
138
+
139
+ describe "when using platform :windows", :if => Puppet.features.microsoft_windows? do
140
+ it "should accept root" do
141
+ Puppet::Util.uri_to_path(URI.parse('file:/C:/')).should == 'C:/'
142
+ end
143
+
144
+ it "should accept single slash" do
145
+ Puppet::Util.uri_to_path(URI.parse('file:/C:/foo/bar')).should == 'C:/foo/bar'
146
+ end
147
+
148
+ it "should accept triple slashes" do
149
+ Puppet::Util.uri_to_path(URI.parse('file:///C:/foo/bar')).should == 'C:/foo/bar'
150
+ end
151
+
152
+ it "should accept file scheme with double slashes as a UNC path" do
153
+ Puppet::Util.uri_to_path(URI.parse('file://host/share/file')).should == '//host/share/file'
154
+ end
155
+ end
156
+ end
157
+
50
158
  describe "execution methods" do
51
159
  let(:pid) { 5501 }
52
160
  let(:null_file) { Puppet.features.microsoft_windows? ? 'NUL' : '/dev/null' }
@@ -112,6 +220,12 @@ describe Puppet::Util do
112
220
  Puppet::Util.execute_posix(['test command', 'with', 'arguments'], {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
113
221
  end
114
222
 
223
+ it "should properly execute string commands with embedded newlines" do
224
+ Kernel.expects(:exec).with("/bin/echo 'foo' ; \n /bin/echo 'bar' ;")
225
+
226
+ Puppet::Util.execute_posix("/bin/echo 'foo' ; \n /bin/echo 'bar' ;", {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
227
+ end
228
+
115
229
  it "should return the pid of the child process" do
116
230
  Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr).should == pid
117
231
  end
@@ -122,7 +236,7 @@ describe Puppet::Util do
122
236
 
123
237
  before :each do
124
238
  Process.stubs(:create).returns(proc_info_stub)
125
- Process.stubs(:waitpid2).with(pid).returns([pid, 0])
239
+ Process.stubs(:waitpid2).with(pid).returns([pid, process_status(0)])
126
240
 
127
241
  @stdin = File.open(null_file, 'r')
128
242
  @stdout = Tempfile.new('stdout')
@@ -153,7 +267,7 @@ describe Puppet::Util do
153
267
 
154
268
  describe "#execute" do
155
269
  before :each do
156
- Process.stubs(:waitpid2).with(pid).returns([pid, 0])
270
+ Process.stubs(:waitpid2).with(pid).returns([pid, process_status(0)])
157
271
  end
158
272
 
159
273
  describe "when an execution stub is specified" do
@@ -251,8 +365,9 @@ describe Puppet::Util do
251
365
 
252
366
  describe "after execution" do
253
367
  let(:executor) { Puppet.features.microsoft_windows? ? 'execute_windows' : 'execute_posix' }
368
+
254
369
  before :each do
255
- Process.stubs(:waitpid2).with(pid).returns([pid, 0])
370
+ Process.stubs(:waitpid2).with(pid).returns([pid, process_status(0)])
256
371
 
257
372
  Puppet::Util.stubs(executor).returns(pid)
258
373
  end
@@ -260,7 +375,7 @@ describe Puppet::Util do
260
375
  it "should wait for the child process to exit" do
261
376
  Puppet::Util.stubs(:wait_for_output)
262
377
 
263
- Process.expects(:waitpid2).with(pid).returns([pid, 0])
378
+ Process.expects(:waitpid2).with(pid).returns([pid, process_status(0)])
264
379
 
265
380
  Puppet::Util.execute('test command')
266
381
  end
@@ -306,9 +421,7 @@ describe Puppet::Util do
306
421
  end
307
422
 
308
423
  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])
424
+ Process.expects(:waitpid2).with(pid).returns([pid, process_status(1)])
312
425
 
313
426
  expect {
314
427
  Puppet::Util.execute('fail command', :failonfail => true)
@@ -316,7 +429,7 @@ describe Puppet::Util do
316
429
  end
317
430
 
318
431
  it "should not raise an error if failonfail is false and the child failed" do
319
- Process.expects(:waitpid2).with(pid).returns([pid, 1])
432
+ Process.expects(:waitpid2).with(pid).returns([pid, process_status(1)])
320
433
 
321
434
  expect {
322
435
  Puppet::Util.execute('fail command', :failonfail => false)
@@ -324,7 +437,7 @@ describe Puppet::Util do
324
437
  end
325
438
 
326
439
  it "should not raise an error if failonfail is true and the child succeeded" do
327
- Process.expects(:waitpid2).with(pid).returns([pid, 0])
440
+ Process.expects(:waitpid2).with(pid).returns([pid, process_status(0)])
328
441
 
329
442
  expect {
330
443
  Puppet::Util.execute('fail command', :failonfail => true)
@@ -4,7 +4,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/puppettest')
4
4
 
5
5
  require 'puppet'
6
6
  require 'puppet/parser/parser'
7
- require 'puppet/network/client'
8
7
  require 'puppettest'
9
8
  require 'puppettest/resourcetesting'
10
9
 
@@ -4,8 +4,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/puppettest')
4
4
 
5
5
  require 'puppet'
6
6
  require 'puppet/parser/parser'
7
- require 'puppet/network/client'
8
- require 'puppet/network/handler'
9
7
  require 'puppettest'
10
8
 
11
9
  class TestSnippets < Test::Unit::TestCase
@@ -69,13 +67,6 @@ class TestSnippets < Test::Unit::TestCase
69
67
  ast
70
68
  end
71
69
 
72
- def client
73
- args = {
74
- :Listen => false
75
- }
76
- Puppet::Network::Client.new(args)
77
- end
78
-
79
70
  def ast2scope(ast)
80
71
  scope = Puppet::Parser::Scope.new
81
72
  ast.evaluate(scope)