puppet 2.6.4 → 2.6.5
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 +147 -0
- data/LICENSE +2 -2
- data/Rakefile +3 -4
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application.rb +22 -5
- data/lib/puppet/application/apply.rb +2 -18
- data/lib/puppet/application/doc.rb +1 -4
- data/lib/puppet/application/inspect.rb +178 -0
- data/lib/puppet/configurer.rb +9 -11
- data/lib/puppet/configurer/plugin_handler.rb +0 -2
- data/lib/puppet/defaults.rb +12 -3
- data/lib/puppet/external/pson/pure/generator.rb +1 -22
- data/lib/puppet/file_bucket/dipper.rb +9 -3
- data/lib/puppet/file_bucket/file.rb +14 -94
- data/lib/puppet/indirector.rb +4 -0
- data/lib/puppet/indirector/catalog/active_record.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +64 -75
- data/lib/puppet/indirector/indirection.rb +18 -8
- data/lib/puppet/indirector/resource/ral.rb +7 -2
- data/lib/puppet/indirector/rest.rb +19 -2
- data/lib/puppet/network/http/api/v1.rb +3 -0
- data/lib/puppet/network/http/handler.rb +16 -1
- data/lib/puppet/network/http/rack/rest.rb +1 -3
- data/lib/puppet/network/rest_authconfig.rb +4 -12
- data/lib/puppet/network/rights.rb +28 -14
- data/lib/puppet/parser/ast.rb +4 -0
- data/lib/puppet/parser/compiler.rb +18 -3
- data/lib/puppet/parser/functions/defined.rb +28 -6
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -3
- data/lib/puppet/parser/templatewrapper.rb +1 -0
- data/lib/puppet/property.rb +16 -1
- data/lib/puppet/property/keyvalue.rb +0 -2
- data/lib/puppet/property/list.rb +0 -2
- data/lib/puppet/provider/file/posix.rb +1 -3
- data/lib/puppet/provider/file/win32.rb +1 -3
- data/lib/puppet/provider/maillist/mailman.rb +3 -5
- data/lib/puppet/provider/mount.rb +2 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/freebsd.rb +2 -2
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/reference/configuration.rb +2 -2
- data/lib/puppet/reference/function.rb +4 -0
- data/lib/puppet/relationship.rb +4 -0
- data/lib/puppet/reports/store.rb +1 -19
- data/lib/puppet/resource.rb +11 -2
- data/lib/puppet/resource/status.rb +24 -3
- data/lib/puppet/resource/type.rb +24 -16
- data/lib/puppet/resource/type_collection.rb +4 -1
- data/lib/puppet/simple_graph.rb +4 -0
- data/lib/puppet/transaction.rb +1 -28
- data/lib/puppet/transaction/event.rb +9 -4
- data/lib/puppet/transaction/report.rb +42 -22
- data/lib/puppet/transaction/resource_harness.rb +99 -71
- data/lib/puppet/type.rb +22 -9
- data/lib/puppet/type/cron.rb +1 -5
- data/lib/puppet/type/exec.rb +4 -34
- data/lib/puppet/type/file.rb +19 -26
- data/lib/puppet/type/file/checksum.rb +1 -1
- data/lib/puppet/type/file/content.rb +2 -1
- data/lib/puppet/type/file/ctime.rb +18 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +10 -44
- data/lib/puppet/type/file/mtime.rb +17 -0
- data/lib/puppet/type/file/owner.rb +1 -1
- data/lib/puppet/type/file/source.rb +0 -1
- data/lib/puppet/type/file/target.rb +1 -1
- data/lib/puppet/type/file/type.rb +5 -12
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/package.rb +0 -2
- data/lib/puppet/type/service.rb +11 -5
- data/lib/puppet/type/user.rb +7 -9
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zpool.rb +0 -4
- data/lib/puppet/util/checksums.rb +24 -1
- data/lib/puppet/util/command_line.rb +6 -2
- data/lib/puppet/util/command_line/puppet +5 -1
- data/lib/puppet/util/command_line/puppetca +2 -2
- data/lib/puppet/util/command_line/puppetd +11 -9
- data/lib/puppet/util/command_line/puppetdoc +2 -2
- data/lib/puppet/util/command_line/puppetmasterd +5 -0
- data/lib/puppet/util/log.rb +15 -8
- data/lib/puppet/util/log/destinations.rb +2 -0
- data/lib/puppet/util/log_paths.rb +1 -1
- data/lib/puppet/util/logging.rb +1 -1
- data/lib/puppet/util/metric.rb +1 -0
- data/lib/puppet/util/reference.rb +1 -10
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/zaml.rb +30 -31
- data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +7 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -4
- data/spec/integration/indirector/report/rest_spec.rb +13 -17
- data/spec/integration/network/formats_spec.rb +2 -5
- data/spec/integration/network/server/mongrel_spec.rb +1 -2
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -1
- data/spec/integration/provider/package_spec.rb +1 -3
- data/spec/integration/provider/service/init_spec.rb +3 -9
- data/spec/integration/reference/providers_spec.rb +2 -2
- data/spec/integration/resource/catalog_spec.rb +1 -2
- data/spec/integration/transaction/report_spec.rb +1 -1
- data/spec/monkey_patches/alias_should_to_must.rb +2 -0
- data/spec/shared_behaviours/file_server_terminus.rb +1 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/shared_behaviours/memory_terminus.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/unit/application/agent_spec.rb +1 -0
- data/spec/unit/application/apply_spec.rb +7 -7
- data/spec/unit/application/doc_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +278 -0
- data/spec/unit/application/kick_spec.rb +1 -3
- data/spec/unit/application/master_spec.rb +1 -3
- data/spec/unit/application/queue_spec.rb +1 -0
- data/spec/unit/application_spec.rb +63 -5
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -1
- data/spec/unit/configurer_spec.rb +33 -49
- data/spec/unit/file_bucket/dipper_spec.rb +69 -77
- data/spec/unit/file_bucket/file_spec.rb +12 -127
- data/spec/unit/file_serving/fileset_spec.rb +1 -0
- data/spec/unit/file_serving/metadata_spec.rb +4 -4
- data/spec/unit/indirector/active_record_spec.rb +1 -0
- data/spec/unit/indirector/catalog/active_record_spec.rb +29 -13
- data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
- data/spec/unit/indirector/facts/couch_spec.rb +1 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +202 -218
- data/spec/unit/indirector/file_server_spec.rb +6 -7
- data/spec/unit/indirector/indirection_spec.rb +71 -2
- data/spec/unit/indirector/ldap_spec.rb +2 -6
- data/spec/unit/indirector/node/active_record_spec.rb +1 -3
- data/spec/unit/indirector/queue_spec.rb +1 -3
- data/spec/unit/indirector/rest_spec.rb +37 -1
- data/spec/unit/indirector/ssl_file_spec.rb +5 -5
- data/spec/unit/indirector_spec.rb +6 -1
- data/spec/unit/module_spec.rb +1 -3
- data/spec/unit/network/formats_spec.rb +2 -5
- data/spec/unit/network/http/api/v1_spec.rb +4 -0
- data/spec/unit/network/http/compression_spec.rb +1 -3
- data/spec/unit/network/http/handler_spec.rb +39 -0
- data/spec/unit/network/http/mongrel/rest_spec.rb +1 -2
- data/spec/unit/network/http/mongrel_spec.rb +3 -9
- data/spec/unit/network/http/rack/rest_spec.rb +1 -3
- data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
- data/spec/unit/network/http/rack_spec.rb +2 -3
- data/spec/unit/network/http/webrick_spec.rb +1 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/network/rights_spec.rb +43 -23
- data/spec/unit/network/xmlrpc/client_spec.rb +1 -0
- data/spec/unit/parameter_spec.rb +1 -2
- data/spec/unit/parser/collector_spec.rb +3 -6
- data/spec/unit/parser/compiler_spec.rb +90 -5
- data/spec/unit/parser/lexer_spec.rb +3 -2
- data/spec/unit/parser/templatewrapper_spec.rb +1 -0
- data/spec/unit/property/keyvalue_spec.rb +5 -5
- data/spec/unit/property/list_spec.rb +7 -7
- data/spec/unit/provider/mount/parsed_spec.rb +1 -2
- data/spec/unit/provider/mount_spec.rb +8 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +38 -0
- data/spec/unit/provider/package/freebsd_spec.rb +55 -0
- data/spec/unit/provider/service/init_spec.rb +2 -0
- data/spec/unit/rails/host_spec.rb +1 -3
- data/spec/unit/rails/param_value_spec.rb +2 -3
- data/spec/unit/rails/resource_spec.rb +2 -3
- data/spec/unit/rails_spec.rb +5 -15
- data/spec/unit/relationship_spec.rb +2 -6
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/reports/store_spec.rb +31 -0
- data/spec/unit/reports/tagmail_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +2 -6
- data/spec/unit/resource/status_spec.rb +53 -3
- data/spec/unit/resource/type_collection_spec.rb +0 -8
- data/spec/unit/resource/type_spec.rb +50 -4
- data/spec/unit/resource_spec.rb +10 -6
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +1 -1
- data/spec/unit/transaction/event_spec.rb +21 -2
- data/spec/unit/transaction/report_spec.rb +91 -35
- data/spec/unit/transaction/resource_harness_spec.rb +289 -208
- data/spec/unit/transaction_spec.rb +1 -6
- data/spec/unit/type/augeas_spec.rb +1 -3
- data/spec/unit/type/file/content_spec.rb +63 -10
- data/spec/unit/type/file/ctime.rb +35 -0
- data/spec/unit/type/file/ensure_spec.rb +8 -7
- data/spec/unit/type/file/group_spec.rb +5 -5
- data/spec/unit/type/file/mtime.rb +35 -0
- data/spec/unit/type/file/owner_spec.rb +7 -7
- data/spec/unit/type/file/selinux_spec.rb +2 -2
- data/spec/unit/type/file/source_spec.rb +3 -3
- data/spec/unit/type/file/type.rb +20 -0
- data/spec/unit/type/file_spec.rb +131 -8
- data/spec/unit/type/mount_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +3 -3
- data/spec/unit/type/ssh_authorized_key_spec.rb +1 -1
- data/spec/unit/type/user_spec.rb +31 -3
- data/spec/unit/type/zpool_spec.rb +12 -12
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/checksums_spec.rb +9 -1
- data/spec/unit/util/command_line_spec.rb +29 -0
- data/spec/unit/util/log/destinations_spec.rb +13 -0
- data/spec/unit/util/log_spec.rb +24 -12
- data/spec/unit/util/logging_spec.rb +1 -1
- data/spec/unit/util/metric_spec.rb +7 -7
- data/spec/unit/util/pson_spec.rb +15 -0
- data/spec/unit/util/queue/stomp_spec.rb +2 -6
- data/spec/unit/util/settings/file_setting_spec.rb +1 -3
- data/spec/unit/util/zaml_spec.rb +51 -0
- data/test/language/snippets.rb +3 -0
- data/test/lib/puppettest/fileparsing.rb +2 -0
- data/test/lib/puppettest/reporttesting.rb +1 -1
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/network/server/mongrel_test.rb +0 -6
- data/test/other/report.rb +1 -1
- data/test/ral/providers/cron/crontab.rb +4 -1
- data/test/ral/type/file.rb +1 -1
- data/test/ral/type/filesources.rb +1 -4
- metadata +1119 -1113
- data/lib/puppet/transaction/change.rb +0 -87
- data/spec/Rakefile +0 -91
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -46
- data/spec/spec_specs/runnable_spec.rb +0 -95
- data/spec/unit/transaction/change_spec.rb +0 -193
@@ -184,22 +184,22 @@ describe Puppet::Type.type(:mount)::Ensure do
|
|
184
184
|
|
185
185
|
it "should be insync if it is mounted and should be defined" do
|
186
186
|
@ensure.should = :defined
|
187
|
-
@ensure.
|
187
|
+
@ensure.safe_insync?(:mounted).should == true
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should be insync if it is unmounted and should be defined" do
|
191
191
|
@ensure.should = :defined
|
192
|
-
@ensure.
|
192
|
+
@ensure.safe_insync?(:unmounted).should == true
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should be insync if it is mounted and should be present" do
|
196
196
|
@ensure.should = :present
|
197
|
-
@ensure.
|
197
|
+
@ensure.safe_insync?(:mounted).should == true
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should be insync if it is unmounted and should be present" do
|
201
201
|
@ensure.should = :present
|
202
|
-
@ensure.
|
202
|
+
@ensure.safe_insync?(:unmounted).should == true
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -121,7 +121,7 @@ describe Puppet::Type.type(:package) do
|
|
121
121
|
before { @package[:ensure] = :purged }
|
122
122
|
|
123
123
|
it "should do nothing if it is :purged" do
|
124
|
-
@provider.expects(:properties).returns(:ensure => :purged)
|
124
|
+
@provider.expects(:properties).returns(:ensure => :purged).at_least_once
|
125
125
|
@catalog.apply
|
126
126
|
end
|
127
127
|
|
@@ -141,7 +141,7 @@ describe Puppet::Type.type(:package) do
|
|
141
141
|
|
142
142
|
[:purged, :absent].each do |state|
|
143
143
|
it "should do nothing if it is #{state.to_s}" do
|
144
|
-
@provider.expects(:properties).returns(:ensure => state)
|
144
|
+
@provider.expects(:properties).returns(:ensure => state).at_least_once
|
145
145
|
@catalog.apply
|
146
146
|
end
|
147
147
|
end
|
@@ -162,7 +162,7 @@ describe Puppet::Type.type(:package) do
|
|
162
162
|
|
163
163
|
[:present, :latest, "1.0"].each do |state|
|
164
164
|
it "should do nothing if it is #{state.to_s}" do
|
165
|
-
@provider.expects(:properties).returns(:ensure => state)
|
165
|
+
@provider.expects(:properties).returns(:ensure => state).at_least_once
|
166
166
|
@catalog.apply
|
167
167
|
end
|
168
168
|
end
|
@@ -134,7 +134,7 @@ describe ssh_authorized_key do
|
|
134
134
|
it "should not raise spurious change events" do
|
135
135
|
resource = @class.new(:name => "Test", :user => "root")
|
136
136
|
target = File.expand_path("~root/.ssh/authorized_keys")
|
137
|
-
resource.property(:target).
|
137
|
+
resource.property(:target).safe_insync?(target).should == true
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
data/spec/unit/type/user_spec.rb
CHANGED
@@ -201,21 +201,21 @@ describe user do
|
|
201
201
|
it "should return true if no 'should' values are set" do
|
202
202
|
@gid = user.attrclass(:gid).new(:resource => @resource)
|
203
203
|
|
204
|
-
@gid.must
|
204
|
+
@gid.must be_safe_insync(500)
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should return true if any of the specified groups are equal to the current integer" do
|
208
208
|
Puppet::Util.expects(:gid).with("foo").returns 300
|
209
209
|
Puppet::Util.expects(:gid).with("bar").returns 500
|
210
210
|
|
211
|
-
@gid.must
|
211
|
+
@gid.must be_safe_insync(500)
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should return false if none of the specified groups are equal to the current integer" do
|
215
215
|
Puppet::Util.expects(:gid).with("foo").returns 300
|
216
216
|
Puppet::Util.expects(:gid).with("bar").returns 500
|
217
217
|
|
218
|
-
@gid.should_not
|
218
|
+
@gid.should_not be_safe_insync(700)
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
@@ -245,6 +245,34 @@ describe user do
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
+
describe "when managing minimum password age" do
|
249
|
+
before do
|
250
|
+
@age = user.attrclass(:password_min_age).new(:resource => @resource)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should accept a negative minimum age" do
|
254
|
+
expect { @age.should = -1 }.should_not raise_error
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should fail with an empty minimum age" do
|
258
|
+
expect { @age.should = '' }.should raise_error(Puppet::Error)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "when managing maximum password age" do
|
263
|
+
before do
|
264
|
+
@age = user.attrclass(:password_max_age).new(:resource => @resource)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should accept a negative maximum age" do
|
268
|
+
expect { @age.should = -1 }.should_not raise_error
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should fail with an empty maximum age" do
|
272
|
+
expect { @age.should = '' }.should raise_error(Puppet::Error)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
248
276
|
describe "when managing passwords" do
|
249
277
|
before do
|
250
278
|
@password = user.attrclass(:password).new(:resource => @resource, :should => "mypass")
|
@@ -38,27 +38,27 @@ describe vdev_property do
|
|
38
38
|
|
39
39
|
it "should be insync if the devices are the same" do
|
40
40
|
@property.should = ["dev1 dev2"]
|
41
|
-
@property.
|
41
|
+
@property.safe_insync?(["dev2 dev1"]).must be_true
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should be out of sync if the devices are not the same" do
|
45
45
|
@property.should = ["dev1 dev3"]
|
46
|
-
@property.
|
46
|
+
@property.safe_insync?(["dev2 dev1"]).must be_false
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should be insync if the devices are the same and the should values are comma seperated" do
|
50
50
|
@property.should = ["dev1", "dev2"]
|
51
|
-
@property.
|
51
|
+
@property.safe_insync?(["dev2 dev1"]).must be_true
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should be out of sync if the device is absent and should has a value" do
|
55
55
|
@property.should = ["dev1", "dev2"]
|
56
|
-
@property.
|
56
|
+
@property.safe_insync?(:absent).must be_false
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should be insync if the device is absent and should is absent" do
|
60
60
|
@property.should = [:absent]
|
61
|
-
@property.
|
61
|
+
@property.safe_insync?(:absent).must be_true
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -73,38 +73,38 @@ describe multi_vdev_property do
|
|
73
73
|
|
74
74
|
it "should be insync if the devices are the same" do
|
75
75
|
@property.should = ["dev1 dev2"]
|
76
|
-
@property.
|
76
|
+
@property.safe_insync?(["dev2 dev1"]).must be_true
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should be out of sync if the devices are not the same" do
|
80
80
|
@property.should = ["dev1 dev3"]
|
81
|
-
@property.
|
81
|
+
@property.safe_insync?(["dev2 dev1"]).must be_false
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should be out of sync if the device is absent and should has a value" do
|
85
85
|
@property.should = ["dev1", "dev2"]
|
86
|
-
@property.
|
86
|
+
@property.safe_insync?(:absent).must be_false
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should be insync if the device is absent and should is absent" do
|
90
90
|
@property.should = [:absent]
|
91
|
-
@property.
|
91
|
+
@property.safe_insync?(:absent).must be_true
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "when there are multiple lists of devices" do
|
95
95
|
it "should be in sync if each group has the same devices" do
|
96
96
|
@property.should = ["dev1 dev2", "dev3 dev4"]
|
97
|
-
@property.
|
97
|
+
@property.safe_insync?(["dev2 dev1", "dev3 dev4"]).must be_true
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should be out of sync if any group has the different devices" do
|
101
101
|
@property.should = ["dev1 devX", "dev3 dev4"]
|
102
|
-
@property.
|
102
|
+
@property.safe_insync?(["dev2 dev1", "dev3 dev4"]).must be_false
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should be out of sync if devices are in the wrong group" do
|
106
106
|
@property.should = ["dev1 dev2", "dev3 dev4"]
|
107
|
-
@property.
|
107
|
+
@property.safe_insync?(["dev2 dev3", "dev1 dev4"]).must be_false
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
data/spec/unit/type_spec.rb
CHANGED
@@ -116,7 +116,7 @@ describe Puppet::Type do
|
|
116
116
|
catalog.version = 50
|
117
117
|
catalog.add_resource resource
|
118
118
|
|
119
|
-
resource.source_descriptors.should == {:
|
119
|
+
resource.source_descriptors.should == {:tags=>["mount", "foo"], :path=>"/Mount[foo]"}
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should consider its type to be the name of its class" do
|
@@ -153,7 +153,7 @@ describe Puppet::Type do
|
|
153
153
|
@resource.event.default_log_level.should == :warning
|
154
154
|
end
|
155
155
|
|
156
|
-
{:file => "/my/file", :line => 50, :tags => %{foo bar}
|
156
|
+
{:file => "/my/file", :line => 50, :tags => %{foo bar}}.each do |attr, value|
|
157
157
|
it "should set the #{attr}" do
|
158
158
|
@resource.stubs(attr).returns value
|
159
159
|
@resource.event.send(attr).should == value
|
@@ -140,7 +140,9 @@ describe Puppet::Util::Checksums do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should return nil for streams" do
|
143
|
-
|
143
|
+
expectation = stub "expectation"
|
144
|
+
expectation.expects(:do_something!).at_least_once
|
145
|
+
@summer.send(sum.to_s + "_stream"){ |checksum| checksum << "anything" ; expectation.do_something! }.should be_nil
|
144
146
|
end
|
145
147
|
end
|
146
148
|
end
|
@@ -149,5 +151,11 @@ describe Puppet::Util::Checksums do
|
|
149
151
|
it "should return an empty string" do
|
150
152
|
@summer.none_file("/my/file").should == ""
|
151
153
|
end
|
154
|
+
|
155
|
+
it "should return an empty string for streams" do
|
156
|
+
expectation = stub "expectation"
|
157
|
+
expectation.expects(:do_something!).at_least_once
|
158
|
+
@summer.none_stream{ |checksum| checksum << "anything" ; expectation.do_something! }.should == ""
|
159
|
+
end
|
152
160
|
end
|
153
161
|
end
|
@@ -6,6 +6,7 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
|
|
6
6
|
require 'puppet/util/command_line'
|
7
7
|
|
8
8
|
describe Puppet::Util::CommandLine do
|
9
|
+
include PuppetSpec::Files
|
9
10
|
before do
|
10
11
|
@tty = stub("tty", :tty? => true )
|
11
12
|
@pipe = stub("pipe", :tty? => false)
|
@@ -105,4 +106,32 @@ describe Puppet::Util::CommandLine do
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
end
|
109
|
+
describe 'when loading commands' do
|
110
|
+
before do
|
111
|
+
@core_apps = %w{describe filebucket kick queue resource agent cert apply doc master}
|
112
|
+
@command_line = Puppet::Util::CommandLine.new("foo", %w{ client --help whatever.pp }, @tty )
|
113
|
+
end
|
114
|
+
it 'should be able to find all existing commands' do
|
115
|
+
@core_apps.each do |command|
|
116
|
+
@command_line.available_subcommands.should include command
|
117
|
+
end
|
118
|
+
end
|
119
|
+
describe 'when multiple paths have applications' do
|
120
|
+
before do
|
121
|
+
@dir=tmpdir('command_line_plugin_test')
|
122
|
+
@appdir="#{@dir}/puppet/application"
|
123
|
+
FileUtils.mkdir_p(@appdir)
|
124
|
+
FileUtils.touch("#{@appdir}/foo.rb")
|
125
|
+
$LOAD_PATH.unshift(@dir) # WARNING: MUST MATCH THE AFTER ACTIONS!
|
126
|
+
end
|
127
|
+
it 'should be able to find commands from both paths' do
|
128
|
+
found = @command_line.available_subcommands
|
129
|
+
found.should include 'foo'
|
130
|
+
@core_apps.each { |cmd| found.should include cmd }
|
131
|
+
end
|
132
|
+
after do
|
133
|
+
$LOAD_PATH.shift # WARNING: MUST MATCH THE BEFORE ACTIONS!
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
108
137
|
end
|
@@ -22,3 +22,16 @@ describe Puppet::Util::Log.desttypes[:report] do
|
|
22
22
|
dest.handle "my log"
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
|
27
|
+
describe Puppet::Util::Log.desttypes[:file] do
|
28
|
+
before do
|
29
|
+
File.stubs(:open) # prevent actually creating the file
|
30
|
+
@class = Puppet::Util::Log.desttypes[:file]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should default to autoflush false" do
|
34
|
+
@class.new('/tmp/log').autoflush.should == false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/spec/unit/util/log_spec.rb
CHANGED
@@ -120,7 +120,7 @@ describe Puppet::Util::Log do
|
|
120
120
|
Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => "foo")
|
121
121
|
end
|
122
122
|
|
123
|
-
[:file, :line
|
123
|
+
[:file, :line].each do |attr|
|
124
124
|
it "should use #{attr} if provided" do
|
125
125
|
Puppet::Util::Log.any_instance.expects(attr.to_s + "=").with "foo"
|
126
126
|
Puppet::Util::Log.new(:level => "notice", :message => :foo, attr => "foo")
|
@@ -136,6 +136,11 @@ describe Puppet::Util::Log do
|
|
136
136
|
Puppet::Util::Log.new(:level => "notice", :message => :foo)
|
137
137
|
end
|
138
138
|
|
139
|
+
it "should update Log autoflush when Puppet[:autoflush] is set" do
|
140
|
+
Puppet::Util::Log.expects(:autoflush=).once.with(true)
|
141
|
+
Puppet[:autoflush] = true
|
142
|
+
end
|
143
|
+
|
139
144
|
it "should have a method for determining if a tag is present" do
|
140
145
|
Puppet::Util::Log.new(:level => "notice", :message => :foo).should respond_to(:tagged?)
|
141
146
|
end
|
@@ -177,23 +182,12 @@ describe Puppet::Util::Log do
|
|
177
182
|
log = Puppet::Util::Log.new(:level => "notice", :message => :foo)
|
178
183
|
log.expects(:tag).with("tag")
|
179
184
|
log.expects(:tag).with("tag2")
|
180
|
-
log.expects(:version=).with(100)
|
181
185
|
|
182
186
|
log.source = source
|
183
187
|
|
184
188
|
log.source.should == "path"
|
185
189
|
end
|
186
190
|
|
187
|
-
it "should copy over any version information" do
|
188
|
-
catalog = Puppet::Resource::Catalog.new
|
189
|
-
catalog.version = 25
|
190
|
-
source = Puppet::Type.type(:file).new :path => "/foo/bar"
|
191
|
-
catalog.add_resource source
|
192
|
-
|
193
|
-
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source)
|
194
|
-
log.version.should == 25
|
195
|
-
end
|
196
|
-
|
197
191
|
it "should copy over any file and line information" do
|
198
192
|
source = Puppet::Type.type(:file).new :path => "/foo/bar"
|
199
193
|
source.file = "/my/file"
|
@@ -212,4 +206,22 @@ describe Puppet::Util::Log do
|
|
212
206
|
end
|
213
207
|
end
|
214
208
|
end
|
209
|
+
|
210
|
+
describe "to_yaml" do
|
211
|
+
it "should not include the @version attribute" do
|
212
|
+
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :version => 100)
|
213
|
+
log.to_yaml_properties.should_not include('@version')
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should include attributes @level, @message, @source, @tags, and @time" do
|
217
|
+
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :version => 100)
|
218
|
+
log.to_yaml_properties.should == %w{@level @message @source @tags @time}
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should include attributes @file and @line if specified" do
|
222
|
+
log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :file => "foo", :line => 35)
|
223
|
+
log.to_yaml_properties.should include('@file')
|
224
|
+
log.to_yaml_properties.should include('@line')
|
225
|
+
end
|
226
|
+
end
|
215
227
|
end
|
@@ -81,7 +81,7 @@ describe Puppet::Util::Logging do
|
|
81
81
|
@logger.notice ["foo", "bar", "baz"]
|
82
82
|
end
|
83
83
|
|
84
|
-
[:file, :line, :
|
84
|
+
[:file, :line, :tags].each do |attr|
|
85
85
|
it "should include #{attr} if available" do
|
86
86
|
@logger.singleton_class.send(:attr_accessor, attr)
|
87
87
|
|
@@ -59,7 +59,7 @@ describe Puppet::Util::Metric do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should support a label for values" do
|
62
|
-
@metric.newvalue(
|
62
|
+
@metric.newvalue("foo", 10, "label")
|
63
63
|
@metric.values[0][1].should == "label"
|
64
64
|
end
|
65
65
|
|
@@ -69,19 +69,19 @@ describe Puppet::Util::Metric do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should return its values sorted by label" do
|
72
|
-
@metric.newvalue(
|
73
|
-
@metric.newvalue(
|
72
|
+
@metric.newvalue("foo", 10, "b")
|
73
|
+
@metric.newvalue("bar", 10, "a")
|
74
74
|
|
75
|
-
@metric.values.should == [[
|
75
|
+
@metric.values.should == [["bar", "a", 10], ["foo", "b", 10]]
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should use an array indexer method to retrieve individual values" do
|
79
|
-
@metric.newvalue(
|
80
|
-
@metric[
|
79
|
+
@metric.newvalue("foo", 10)
|
80
|
+
@metric["foo"].should == 10
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should return nil if the named value cannot be found" do
|
84
|
-
@metric[
|
84
|
+
@metric["foo"].should == 0
|
85
85
|
end
|
86
86
|
|
87
87
|
# LAK: I'm not taking the time to develop these tests right now.
|
data/spec/unit/util/pson_spec.rb
CHANGED
@@ -35,4 +35,19 @@ describe Puppet::Util::Pson do
|
|
35
35
|
bin_string = (1..20000).collect { |i| ((17*i+13*i*i) % 255).chr }.join
|
36
36
|
PSON.parse(%Q{{ "type": "foo", "data": #{bin_string.to_pson} }})["data"].should == bin_string
|
37
37
|
end
|
38
|
+
|
39
|
+
it "should be able to handle UTF8 that isn't a real unicode character" do
|
40
|
+
s = ["\355\274\267"]
|
41
|
+
PSON.parse( [s].to_pson ).should == [s]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be able to handle UTF8 for \\xFF" do
|
45
|
+
s = ["\xc3\xbf"]
|
46
|
+
PSON.parse( [s].to_pson ).should == [s]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to handle invalid UTF8 bytes" do
|
50
|
+
s = ["\xc3\xc3"]
|
51
|
+
PSON.parse( [s].to_pson ).should == [s]
|
52
|
+
end
|
38
53
|
end
|
@@ -3,18 +3,14 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
4
4
|
require 'puppet/util/queue'
|
5
5
|
|
6
|
-
describe Puppet::Util::Queue do
|
7
|
-
confine "Missing Stomp" => Puppet.features.stomp?
|
8
|
-
|
6
|
+
describe Puppet::Util::Queue, :if => Puppet.features.stomp? do
|
9
7
|
it 'should load :stomp client appropriately' do
|
10
8
|
Puppet.settings.stubs(:value).returns 'faux_queue_source'
|
11
9
|
Puppet::Util::Queue.queue_type_to_class(:stomp).name.should == 'Puppet::Util::Queue::Stomp'
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
|
-
describe 'Puppet::Util::Queue::Stomp' do
|
16
|
-
confine "Missing Stomp" => Puppet.features.stomp?
|
17
|
-
|
13
|
+
describe 'Puppet::Util::Queue::Stomp', :if => Puppet.features.stomp? do
|
18
14
|
before do
|
19
15
|
# So we make sure we never create a real client instance.
|
20
16
|
# Otherwise we'll try to connect, and that's bad.
|