puppet 2.7.6 → 2.7.8
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 +168 -0
- data/conf/auth.conf +5 -4
- data/conf/redhat/puppet.spec +16 -1
- data/conf/solaris/pkginfo +2 -2
- data/conf/suse/puppet.spec +9 -3
- data/ext/upload_facts.rb +120 -0
- data/install.rb +11 -16
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +0 -3
- data/lib/puppet/application/apply.rb +0 -3
- data/lib/puppet/application/queue.rb +21 -1
- data/lib/puppet/defaults.rb +6 -4
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/feature/base.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/metadata.rb +5 -2
- data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/network/handler/filebucket.rb +2 -0
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/handler/master.rb +1 -0
- data/lib/puppet/network/handler/report.rb +2 -0
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/network/handler/status.rb +2 -0
- data/lib/puppet/network/http/mongrel/rest.rb +8 -1
- data/lib/puppet/network/http_server.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +129 -0
- data/lib/puppet/network/rest_authconfig.rb +12 -4
- data/lib/puppet/parameter.rb +18 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/grammar.ra +1 -1
- data/lib/puppet/parser/parser.rb +360 -350
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +6 -7
- data/lib/puppet/provider/file/windows.rb +9 -2
- data/lib/puppet/provider/group/aix.rb +8 -8
- data/lib/puppet/provider/group/groupadd.rb +1 -3
- data/lib/puppet/provider/group/ldap.rb +8 -10
- data/lib/puppet/provider/group/windows_adsi.rb +8 -2
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/macports.rb +3 -3
- data/lib/puppet/provider/package/msi.rb +12 -5
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +560 -0
- data/lib/puppet/provider/service/base.rb +2 -2
- data/lib/puppet/provider/service/bsd.rb +4 -3
- data/lib/puppet/provider/service/daemontools.rb +25 -25
- data/lib/puppet/provider/service/debian.rb +6 -4
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/gentoo.rb +4 -3
- data/lib/puppet/provider/service/init.rb +3 -8
- data/lib/puppet/provider/service/launchd.rb +129 -96
- data/lib/puppet/provider/service/redhat.rb +2 -3
- data/lib/puppet/provider/service/runit.rb +20 -20
- data/lib/puppet/provider/service/smf.rb +8 -7
- data/lib/puppet/provider/service/src.rb +5 -6
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +3 -5
- data/lib/puppet/provider/service/windows.rb +7 -7
- data/lib/puppet/provider/sshkey/parsed.rb +2 -3
- data/lib/puppet/provider/user/aix.rb +21 -21
- data/lib/puppet/provider/user/hpux.rb +3 -1
- data/lib/puppet/provider/user/ldap.rb +7 -7
- data/lib/puppet/provider/user/user_role_add.rb +10 -6
- data/lib/puppet/provider/user/useradd.rb +3 -1
- data/lib/puppet/provider/user/windows_adsi.rb +4 -3
- data/lib/puppet/rb_tree_map.rb +388 -0
- data/lib/puppet/reference/configuration.rb +7 -7
- data/lib/puppet/reference/indirection.rb +5 -6
- data/lib/puppet/reference/metaparameter.rb +3 -1
- data/lib/puppet/reference/network.rb +8 -8
- data/lib/puppet/reference/providers.rb +17 -21
- data/lib/puppet/reference/type.rb +12 -9
- data/lib/puppet/resource.rb +2 -5
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +70 -0
- data/lib/puppet/ssl/host.rb +6 -0
- data/lib/puppet/transaction.rb +158 -55
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/type.rb +60 -30
- data/lib/puppet/type/augeas.rb +83 -49
- data/lib/puppet/type/computer.rb +1 -1
- data/lib/puppet/type/cron.rb +11 -11
- data/lib/puppet/type/exec.rb +28 -21
- data/lib/puppet/type/file.rb +17 -7
- data/lib/puppet/type/file/content.rb +2 -2
- data/lib/puppet/type/file/ensure.rb +15 -12
- data/lib/puppet/type/file/mode.rb +30 -5
- data/lib/puppet/type/file/source.rb +11 -10
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +4 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +13 -10
- data/lib/puppet/type/k5login.rb +6 -6
- data/lib/puppet/type/macauthorization.rb +37 -36
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +6 -6
- data/lib/puppet/type/mount.rb +3 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +24 -23
- data/lib/puppet/type/router.rb +4 -1
- data/lib/puppet/type/schedule.rb +52 -44
- data/lib/puppet/type/scheduled_task.rb +222 -0
- data/lib/puppet/type/selmodule.rb +10 -6
- data/lib/puppet/type/service.rb +11 -11
- data/lib/puppet/type/ssh_authorized_key.rb +2 -5
- data/lib/puppet/type/sshkey.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +10 -8
- data/lib/puppet/type/user.rb +61 -53
- data/lib/puppet/type/vlan.rb +4 -4
- data/lib/puppet/type/whit.rb +6 -2
- data/lib/puppet/type/yumrepo.rb +33 -31
- data/lib/puppet/type/zfs.rb +34 -32
- data/lib/puppet/type/zone.rb +21 -19
- data/lib/puppet/type/zpool.rb +3 -3
- data/lib/puppet/util.rb +24 -6
- data/lib/puppet/util/adsi.rb +12 -7
- data/lib/puppet/util/checksums.rb +1 -1
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +2 -2
- data/lib/puppet/util/reference.rb +16 -17
- data/lib/puppet/util/settings/file_setting.rb +14 -2
- data/lib/puppet/util/windows/security.rb +96 -32
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +9 -15
- data/spec/integration/indirector/file_content/file_server_spec.rb +1 -1
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +4 -0
- data/spec/integration/provider/service/init_spec.rb +8 -2
- data/spec/integration/reference/providers_spec.rb +1 -1
- data/spec/integration/ssl/certificate_request_spec.rb +1 -2
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -2
- data/spec/integration/ssl/host_spec.rb +1 -2
- data/spec/integration/transaction_spec.rb +25 -17
- data/spec/integration/type/exec_spec.rb +77 -0
- data/spec/integration/type/file_spec.rb +322 -2
- data/spec/integration/util/windows/security_spec.rb +393 -230
- data/spec/integration/util_spec.rb +16 -0
- data/spec/lib/puppet_spec/files.rb +3 -7
- data/spec/unit/application/apply_spec.rb +0 -9
- data/spec/unit/application/inspect_spec.rb +1 -0
- data/spec/unit/configurer/downloader_spec.rb +3 -3
- data/spec/unit/face/certificate_spec.rb +6 -2
- data/spec/unit/file_bucket/dipper_spec.rb +67 -10
- data/spec/unit/file_bucket/file_spec.rb +22 -28
- data/spec/unit/file_serving/content_spec.rb +1 -1
- data/spec/unit/file_serving/metadata_spec.rb +30 -3
- data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +21 -24
- data/spec/unit/indirector/node/store_configs_spec.rb +1 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource_type/parser_spec.rb +2 -2
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/network/handler/ca_spec.rb +1 -1
- data/spec/unit/network/http/mongrel/rest_spec.rb +54 -25
- data/spec/unit/parameter_spec.rb +36 -0
- data/spec/unit/parser/parser_spec.rb +4 -0
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/provider/exec/windows_spec.rb +2 -8
- data/spec/unit/provider/file/posix_spec.rb +6 -0
- data/spec/unit/provider/file/windows_spec.rb +18 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -6
- data/spec/unit/provider/mount/parsed_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +2 -2
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1571 -0
- data/spec/unit/provider/service/launchd_spec.rb +143 -130
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +39 -9
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +8 -1
- data/spec/unit/rb_tree_map_spec.rb +572 -0
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/simple_graph_spec.rb +9 -9
- data/spec/unit/ssl/host_spec.rb +60 -12
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +394 -11
- data/spec/unit/type/exec_spec.rb +35 -15
- data/spec/unit/type/file/content_spec.rb +11 -10
- data/spec/unit/type/file/mode_spec.rb +73 -19
- data/spec/unit/type/file/source_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +15 -0
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/resources_spec.rb +3 -3
- data/spec/unit/type/scheduled_task_spec.rb +102 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
- data/spec/unit/type/user_spec.rb +2 -1
- data/spec/unit/type_spec.rb +48 -4
- data/spec/unit/util/adsi_spec.rb +18 -7
- data/spec/unit/util/checksums_spec.rb +20 -2
- data/spec/unit/util/execution_stub_spec.rb +10 -5
- data/spec/unit/util/logging_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +1 -1
- data/spec/unit/util/reference_spec.rb +29 -0
- data/spec/unit/util/settings/file_setting_spec.rb +8 -2
- data/spec/unit/util_spec.rb +115 -0
- data/test/other/transactions.rb +5 -11
- data/test/ral/type/exec.rb +1 -1
- metadata +24 -11
@@ -25,7 +25,7 @@ describe Puppet::Indirector::ResourceType::Parser do
|
|
25
25
|
@terminus.find(@request).should == type
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should attempt to load the type if none is found in memory"
|
28
|
+
it "should attempt to load the type if none is found in memory" do
|
29
29
|
dir = tmpdir("find_a_type")
|
30
30
|
FileUtils.mkdir_p(dir)
|
31
31
|
Puppet[:modulepath] = dir
|
@@ -122,7 +122,7 @@ describe Puppet::Indirector::ResourceType::Parser do
|
|
122
122
|
@terminus.search(@request).should be_nil
|
123
123
|
end
|
124
124
|
|
125
|
-
it "should load all resource types from all search paths"
|
125
|
+
it "should load all resource types from all search paths" do
|
126
126
|
dir = tmpdir("searching_in_all")
|
127
127
|
first = File.join(dir, "first")
|
128
128
|
second = File.join(dir, "second")
|
@@ -104,7 +104,7 @@ describe Puppet::Indirector::REST do
|
|
104
104
|
end.to raise_error(/This is often because the time is out of sync on the server or client/)
|
105
105
|
end
|
106
106
|
|
107
|
-
it "should provide a helpful error message when hostname was not match with server certificate" do
|
107
|
+
it "should provide a helpful error message when hostname was not match with server certificate", :unless => Puppet.features.microsoft_windows? do
|
108
108
|
Puppet[:confdir] = tmpdir('conf')
|
109
109
|
cert = Puppet::SSL::CertificateAuthority.new.generate('not_my_server', :dns_alt_names => 'foo,bar,baz').content
|
110
110
|
|
@@ -57,7 +57,7 @@ describe "Puppet::Network::HTTP::MongrelREST", :if => Puppet.features.mongrel?,
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should return the request body as the body" do
|
60
|
-
@request.
|
60
|
+
@request.stubs(:body).returns StringIO.new("mybody")
|
61
61
|
@handler.body(@request).should == "mybody"
|
62
62
|
end
|
63
63
|
|
@@ -109,136 +109,165 @@ describe "Puppet::Network::HTTP::MongrelREST", :if => Puppet.features.mongrel?,
|
|
109
109
|
|
110
110
|
describe "and determining the request parameters" do
|
111
111
|
before do
|
112
|
-
@
|
112
|
+
@params = {'REQUEST_METHOD' => 'GET'}
|
113
|
+
@request.stubs(:params).returns(@params)
|
113
114
|
end
|
114
115
|
|
115
116
|
it "should skip empty parameter values" do
|
116
|
-
@
|
117
|
+
@params['QUERY_STRING'] = "&="
|
117
118
|
lambda { @handler.params(@request) }.should_not raise_error
|
118
119
|
end
|
119
120
|
|
120
121
|
it "should include the HTTP request parameters, with the keys as symbols" do
|
121
|
-
@
|
122
|
+
@params['QUERY_STRING'] = 'foo=baz&bar=xyzzy'
|
122
123
|
result = @handler.params(@request)
|
123
124
|
result[:foo].should == "baz"
|
124
125
|
result[:bar].should == "xyzzy"
|
125
126
|
end
|
126
127
|
|
127
128
|
it "should CGI-decode the HTTP parameters" do
|
128
|
-
|
129
|
-
@
|
129
|
+
escaped = CGI.escape("foo bar")
|
130
|
+
@params['QUERY_STRING'] = "foo=#{escaped}"
|
130
131
|
result = @handler.params(@request)
|
131
132
|
result[:foo].should == "foo bar"
|
132
133
|
end
|
133
134
|
|
135
|
+
it "should include parameters from the body of a POST request" do
|
136
|
+
@params.merge!(
|
137
|
+
'QUERY_STRING' => nil,
|
138
|
+
'REQUEST_METHOD' => 'POST'
|
139
|
+
)
|
140
|
+
body = StringIO.new('foo=bar&baz=qux')
|
141
|
+
@request.stubs(:body).returns(body)
|
142
|
+
|
143
|
+
@handler.params(@request).should include(
|
144
|
+
:foo => 'bar',
|
145
|
+
:baz => 'qux'
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
134
149
|
it "should convert the string 'true' to the boolean" do
|
135
|
-
@
|
150
|
+
@params['QUERY_STRING'] = 'foo=true'
|
136
151
|
result = @handler.params(@request)
|
137
152
|
result[:foo].should be_true
|
138
153
|
end
|
139
154
|
|
140
155
|
it "should convert the string 'false' to the boolean" do
|
141
|
-
@
|
156
|
+
@params['QUERY_STRING'] = 'foo=false'
|
142
157
|
result = @handler.params(@request)
|
143
158
|
result[:foo].should be_false
|
144
159
|
end
|
145
160
|
|
146
161
|
it "should convert integer arguments to Integers" do
|
147
|
-
@
|
162
|
+
@params['QUERY_STRING'] = 'foo=15'
|
148
163
|
result = @handler.params(@request)
|
149
164
|
result[:foo].should == 15
|
150
165
|
end
|
151
166
|
|
152
167
|
it "should convert floating point arguments to Floats" do
|
153
|
-
@
|
168
|
+
@params['QUERY_STRING'] = 'foo=1.5'
|
154
169
|
result = @handler.params(@request)
|
155
170
|
result[:foo].should == 1.5
|
156
171
|
end
|
157
172
|
|
158
173
|
it "should YAML-load and URI-decode values that are YAML-encoded" do
|
159
174
|
escaping = CGI.escape(YAML.dump(%w{one two}))
|
160
|
-
@
|
175
|
+
@params['QUERY_STRING'] = "foo=#{escaping}"
|
161
176
|
result = @handler.params(@request)
|
162
177
|
result[:foo].should == %w{one two}
|
163
178
|
end
|
164
179
|
|
165
180
|
it "should not allow the client to set the node via the query string" do
|
166
|
-
@
|
181
|
+
@params['QUERY_STRING'] = "node=foo"
|
167
182
|
@handler.params(@request)[:node].should be_nil
|
168
183
|
end
|
169
184
|
|
170
185
|
it "should not allow the client to set the IP address via the query string" do
|
171
|
-
@
|
186
|
+
@params['QUERY_STRING'] = "ip=foo"
|
172
187
|
@handler.params(@request)[:ip].should be_nil
|
173
188
|
end
|
174
189
|
|
175
190
|
it "should pass the client's ip address to model find" do
|
176
|
-
@
|
191
|
+
@params['REMOTE_ADDR'] = "ipaddress"
|
177
192
|
@handler.params(@request)[:ip].should == "ipaddress"
|
178
193
|
end
|
179
194
|
|
180
195
|
it "should pass the client's provided X-Forwared-For value as the ip" do
|
181
|
-
@
|
196
|
+
@params["HTTP_X_FORWARDED_FOR"] = "ipaddress"
|
182
197
|
@handler.params(@request)[:ip].should == "ipaddress"
|
183
198
|
end
|
184
199
|
|
185
200
|
it "should pass the client's provided X-Forwared-For first value as the ip" do
|
186
|
-
@
|
201
|
+
@params["HTTP_X_FORWARDED_FOR"] = "ipproxy1,ipproxy2,ipaddress"
|
187
202
|
@handler.params(@request)[:ip].should == "ipaddress"
|
188
203
|
end
|
189
204
|
|
190
205
|
it "should pass the client's provided X-Forwared-For value as the ip instead of the REMOTE_ADDR" do
|
191
|
-
@
|
192
|
-
|
206
|
+
@params.merge!(
|
207
|
+
"REMOTE_ADDR" => "remote_addr",
|
208
|
+
"HTTP_X_FORWARDED_FOR" => "ipaddress"
|
209
|
+
)
|
193
210
|
@handler.params(@request)[:ip].should == "ipaddress"
|
194
211
|
end
|
195
212
|
|
196
213
|
it "should use the :ssl_client_header to determine the parameter when looking for the certificate" do
|
197
214
|
Puppet.settings.stubs(:value).returns "eh"
|
198
215
|
Puppet.settings.expects(:value).with(:ssl_client_header).returns "myheader"
|
199
|
-
@
|
216
|
+
@params["myheader"] = "/CN=host.domain.com"
|
200
217
|
@handler.params(@request)
|
201
218
|
end
|
202
219
|
|
203
220
|
it "should retrieve the hostname by matching the certificate parameter" do
|
204
221
|
Puppet.settings.stubs(:value).returns "eh"
|
205
222
|
Puppet.settings.expects(:value).with(:ssl_client_header).returns "myheader"
|
206
|
-
@
|
223
|
+
@params["myheader"] = "/CN=host.domain.com"
|
207
224
|
@handler.params(@request)[:node].should == "host.domain.com"
|
208
225
|
end
|
209
226
|
|
210
227
|
it "should use the :ssl_client_header to determine the parameter for checking whether the host certificate is valid" do
|
211
228
|
Puppet.settings.stubs(:value).with(:ssl_client_header).returns "certheader"
|
212
229
|
Puppet.settings.expects(:value).with(:ssl_client_verify_header).returns "myheader"
|
213
|
-
@
|
230
|
+
@params.merge!(
|
231
|
+
"myheader" => "SUCCESS",
|
232
|
+
"certheader" => "/CN=host.domain.com"
|
233
|
+
)
|
214
234
|
@handler.params(@request)
|
215
235
|
end
|
216
236
|
|
217
237
|
it "should consider the host authenticated if the validity parameter contains 'SUCCESS'" do
|
218
238
|
Puppet.settings.stubs(:value).with(:ssl_client_header).returns "certheader"
|
219
239
|
Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns "myheader"
|
220
|
-
@
|
240
|
+
@params.merge!(
|
241
|
+
"myheader" => "SUCCESS",
|
242
|
+
"certheader" => "/CN=host.domain.com"
|
243
|
+
)
|
221
244
|
@handler.params(@request)[:authenticated].should be_true
|
222
245
|
end
|
223
246
|
|
224
247
|
it "should consider the host unauthenticated if the validity parameter does not contain 'SUCCESS'" do
|
225
248
|
Puppet.settings.stubs(:value).with(:ssl_client_header).returns "certheader"
|
226
249
|
Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns "myheader"
|
227
|
-
@
|
250
|
+
@params.merge!(
|
251
|
+
"myheader" => "whatever",
|
252
|
+
"certheader" => "/CN=host.domain.com"
|
253
|
+
)
|
228
254
|
@handler.params(@request)[:authenticated].should be_false
|
229
255
|
end
|
230
256
|
|
231
257
|
it "should consider the host unauthenticated if no certificate information is present" do
|
232
258
|
Puppet.settings.stubs(:value).with(:ssl_client_header).returns "certheader"
|
233
259
|
Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns "myheader"
|
234
|
-
@
|
260
|
+
@params.merge!(
|
261
|
+
"myheader" => nil,
|
262
|
+
"certheader" => "SUCCESS"
|
263
|
+
)
|
235
264
|
@handler.params(@request)[:authenticated].should be_false
|
236
265
|
end
|
237
266
|
|
238
267
|
it "should resolve the node name with an ip address look-up if no certificate is present" do
|
239
268
|
Puppet.settings.stubs(:value).returns "eh"
|
240
269
|
Puppet.settings.expects(:value).with(:ssl_client_header).returns "myheader"
|
241
|
-
@
|
270
|
+
@params["myheader"] = nil
|
242
271
|
@handler.expects(:resolve_node).returns("host.domain.com")
|
243
272
|
@handler.params(@request)[:node].should == "host.domain.com"
|
244
273
|
end
|
data/spec/unit/parameter_spec.rb
CHANGED
@@ -157,4 +157,40 @@ describe Puppet::Parameter do
|
|
157
157
|
@parameter.log "mymessage"
|
158
158
|
end
|
159
159
|
end
|
160
|
+
|
161
|
+
describe ".format_value_for_display" do
|
162
|
+
it 'should format strings appropriately' do
|
163
|
+
described_class.format_value_for_display('foo').should == "'foo'"
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should format numbers appropriately' do
|
167
|
+
described_class.format_value_for_display(1).should == "'1'"
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should format symbols appropriately' do
|
171
|
+
described_class.format_value_for_display(:bar).should == "'bar'"
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should format arrays appropriately' do
|
175
|
+
described_class.format_value_for_display([1, 'foo', :bar]).should == "['1', 'foo', 'bar']"
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should format hashes appropriately' do
|
179
|
+
described_class.format_value_for_display(
|
180
|
+
{1 => 'foo', :bar => 2, 'baz' => :qux}
|
181
|
+
).should == "{'1' => 'foo', 'bar' => '2', 'baz' => 'qux'}"
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should format arrays with nested data appropriately' do
|
185
|
+
described_class.format_value_for_display(
|
186
|
+
[1, 'foo', :bar, [1, 2, 3], {1 => 2, 3 => 4}]
|
187
|
+
).should == "['1', 'foo', 'bar', ['1', '2', '3'], {'1' => '2', '3' => '4'}]"
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should format hashes with nested data appropriately' do
|
191
|
+
described_class.format_value_for_display(
|
192
|
+
{1 => 'foo', :bar => [2, 3, 4], 'baz' => {:qux => 1, :quux => 'two'}}
|
193
|
+
).should == "{'1' => 'foo', 'bar' => ['2', '3', '4'], 'baz' => {'quux' => 'two', 'qux' => '1'}}"
|
194
|
+
end
|
195
|
+
end
|
160
196
|
end
|
@@ -369,6 +369,10 @@ describe Puppet::Parser do
|
|
369
369
|
@parser.parse("class foobar { $var = val }").code[0].code.should_not be_nil
|
370
370
|
end
|
371
371
|
|
372
|
+
it "should accept parametrized classes with trailing comma" do
|
373
|
+
@parser.parse("class foobar ($var1 = 0,) { $var = val }").code[0].code.should_not be_nil
|
374
|
+
end
|
375
|
+
|
372
376
|
it "should define parameters when provided" do
|
373
377
|
foobar = @parser.parse("class foobar($biz,$baz) {}").code[0].instantiate('')[0]
|
374
378
|
foobar.arguments.should == {"biz" => nil, "baz" => nil}
|
data/spec/unit/property_spec.rb
CHANGED
@@ -109,12 +109,12 @@ describe Puppet::Property do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
describe "when creating an event"
|
112
|
+
describe "when creating an event" do
|
113
113
|
before do
|
114
114
|
@event = Puppet::Transaction::Event.new
|
115
115
|
|
116
116
|
# Use a real resource so we can test the event creation integration
|
117
|
-
@resource = Puppet::Type.type(:
|
117
|
+
@resource = Puppet::Type.type(:host).new :name => "foo"
|
118
118
|
@instance = @class.new(:resource => @resource)
|
119
119
|
@instance.stubs(:should).returns "myval"
|
120
120
|
end
|
@@ -9,6 +9,7 @@ describe Puppet::Type.type(:exec).provider(:windows) do
|
|
9
9
|
let(:provider) { described_class.new(resource) }
|
10
10
|
|
11
11
|
before :each do
|
12
|
+
Facter.stubs(:value).with(:operatingsystem).returns 'Windows'
|
12
13
|
Puppet.features.stubs(:microsoft_windows?).returns(true)
|
13
14
|
Puppet.features.stubs(:posix?).returns(false)
|
14
15
|
end
|
@@ -77,19 +78,12 @@ describe Puppet::Type.type(:exec).provider(:windows) do
|
|
77
78
|
end
|
78
79
|
|
79
80
|
it "should search for executables with no extension" do
|
81
|
+
provider.resource[:path] = [File.expand_path('/bogus/bin')]
|
80
82
|
provider.expects(:which).with('foo').returns('foo')
|
81
83
|
|
82
84
|
provider.checkexe('foo')
|
83
85
|
end
|
84
86
|
|
85
|
-
%w[bat com ps1 exe].each do |ext|
|
86
|
-
it "should search for executables with the extension '#{ext}'" do
|
87
|
-
provider.expects(:which).with("foo.#{ext}").returns("foo.#{ext}")
|
88
|
-
|
89
|
-
provider.checkexe('foo')
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
87
|
it "should fail if the command isn't in the path" do
|
94
88
|
expect { provider.checkexe('foo') }.to raise_error(ArgumentError, "Could not find command 'foo'")
|
95
89
|
end
|
@@ -223,4 +223,10 @@ describe Puppet::Type.type(:file).provider(:posix), :if => Puppet.features.posix
|
|
223
223
|
expect { provider.group = 25 }.to raise_error(Puppet::Error, /Failed to set group to '25'/)
|
224
224
|
end
|
225
225
|
end
|
226
|
+
|
227
|
+
describe "when validating" do
|
228
|
+
it "should not perform any validation" do
|
229
|
+
resource.validate
|
230
|
+
end
|
231
|
+
end
|
226
232
|
end
|
@@ -133,4 +133,22 @@ describe Puppet::Type.type(:file).provider(:windows), :if => Puppet.features.mic
|
|
133
133
|
expect { provider.group = 'S-1-1-50' }.to raise_error(Puppet::Error, /Failed to set group/)
|
134
134
|
end
|
135
135
|
end
|
136
|
+
|
137
|
+
describe "when validating" do
|
138
|
+
{:owner => 'foo', :group => 'foo', :mode => 0777}.each do |k,v|
|
139
|
+
it "should fail if the filesystem doesn't support ACLs and we're managing #{k}" do
|
140
|
+
described_class.any_instance.stubs(:supports_acl?).returns false
|
141
|
+
|
142
|
+
expect {
|
143
|
+
Puppet::Type.type(:file).new :path => path, k => v
|
144
|
+
}.to raise_error(Puppet::Error, /Can only manage owner, group, and mode on filesystems that support Windows ACLs, such as NTFS/)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not fail if the filesystem doesn't support ACLs and we're not managing permissions" do
|
149
|
+
described_class.any_instance.stubs(:supports_acl?).returns false
|
150
|
+
|
151
|
+
Puppet::Type.type(:file).new :path => path
|
152
|
+
end
|
153
|
+
end
|
136
154
|
end
|
@@ -47,15 +47,31 @@ describe Puppet::Type.type(:group).provider(:windows_adsi) do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
describe 'when creating groups' do
|
51
|
+
it "should be able to create a group" do
|
52
|
+
resource[:members] = ['user1', 'user2']
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
group = stub 'group'
|
55
|
+
Puppet::Util::ADSI::Group.expects(:create).with('testers').returns group
|
55
56
|
|
56
|
-
|
57
|
+
create = sequence('create')
|
58
|
+
group.expects(:commit).in_sequence(create)
|
59
|
+
group.expects(:set_members).with(['user1', 'user2']).in_sequence(create)
|
57
60
|
|
58
|
-
|
61
|
+
provider.create
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should not create a group if a user by the same name exists' do
|
65
|
+
Puppet::Util::ADSI::Group.expects(:create).with('testers').raises( Puppet::Error.new("Cannot create group if user 'testers' exists.") )
|
66
|
+
expect{ provider.create }.to raise_error( Puppet::Error,
|
67
|
+
/Cannot create group if user 'testers' exists./ )
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should commit a newly created group' do
|
71
|
+
provider.group.expects( :commit )
|
72
|
+
|
73
|
+
provider.flush
|
74
|
+
end
|
59
75
|
end
|
60
76
|
|
61
77
|
it "should be able to test whether a group exists" do
|
@@ -4,7 +4,7 @@ require 'shared_behaviours/all_parsedfile_providers'
|
|
4
4
|
|
5
5
|
provider_class = Puppet::Type.type(:mount).provider(:parsed)
|
6
6
|
|
7
|
-
describe provider_class, :
|
7
|
+
describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
8
8
|
|
9
9
|
before :each do
|
10
10
|
@mount_class = Puppet::Type.type(:mount)
|
@@ -69,7 +69,7 @@ describe 'Puppet::Provider::Package::Msi' do
|
|
69
69
|
expect do
|
70
70
|
resource = Puppet::Type.type(:package).new(
|
71
71
|
:name => 'mysql-5.1.58-winx64'
|
72
|
-
)
|
72
|
+
).provider.install
|
73
73
|
end.to raise_error(Puppet::Error, /The source parameter is required when using the MSI provider/)
|
74
74
|
end
|
75
75
|
|
@@ -115,7 +115,7 @@ describe 'Puppet::Provider::Package::Msi' do
|
|
115
115
|
expect do
|
116
116
|
resource = Puppet::Type.type(:package).new(
|
117
117
|
:name => 'mysql-5.1.58-winx64'
|
118
|
-
)
|
118
|
+
).provider.install
|
119
119
|
end.to raise_error(Puppet::Error, /The source parameter is required when using the MSI provider/)
|
120
120
|
end
|
121
121
|
|