puppet 0.25.0 → 0.25.1
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 +4772 -19114
- data/README +1 -1
- data/Rakefile +7 -25
- data/{sbin → bin}/puppetca +0 -0
- data/{sbin → bin}/puppetd +0 -0
- data/{sbin → bin}/puppetmasterd +0 -0
- data/{sbin → bin}/puppetqd +0 -0
- data/{sbin → bin}/puppetrun +0 -0
- data/conf/osx/createpackage.sh +1 -1
- data/conf/redhat/client.init +6 -3
- data/conf/redhat/puppet.spec +26 -14
- data/conf/redhat/server.init +3 -2
- data/ext/vim/syntax/puppet.vim +4 -1
- data/install.rb +25 -7
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +3 -3
- data/lib/puppet/application/puppetd.rb +0 -7
- data/lib/puppet/application/puppetdoc.rb +1 -0
- data/lib/puppet/application/puppetmasterd.rb +2 -2
- data/lib/puppet/configurer.rb +6 -1
- data/lib/puppet/configurer/fact_handler.rb +2 -2
- data/lib/puppet/defaults.rb +2 -2
- data/lib/puppet/external/nagios/base.rb +4 -3
- data/lib/puppet/external/pson/common.rb +367 -0
- data/lib/puppet/external/pson/pure.rb +77 -0
- data/lib/puppet/external/pson/pure/generator.rb +429 -0
- data/lib/puppet/external/pson/pure/parser.rb +269 -0
- data/lib/puppet/external/pson/version.rb +8 -0
- data/lib/puppet/feature/pson.rb +6 -0
- data/lib/puppet/feature/rails.rb +1 -5
- data/lib/puppet/file_serving/configuration.rb +2 -2
- data/lib/puppet/indirector/certificate/rest.rb +6 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/ldap.rb +1 -1
- data/lib/puppet/indirector/queue.rb +3 -3
- data/lib/puppet/indirector/rest.rb +1 -1
- data/lib/puppet/network/authstore.rb +34 -53
- data/lib/puppet/network/formats.rb +59 -9
- data/lib/puppet/network/http/mongrel/rest.rb +10 -9
- data/lib/puppet/network/http/webrick.rb +8 -1
- data/lib/puppet/network/http/webrick/rest.rb +2 -5
- data/lib/puppet/network/http_server/webrick.rb +1 -4
- data/lib/puppet/parser/ast/leaf.rb +1 -3
- data/lib/puppet/parser/collector.rb +14 -8
- data/lib/puppet/parser/compiler.rb +7 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +4 -10
- data/lib/puppet/parser/functions/regsubst.rb +44 -30
- data/lib/puppet/parser/functions/require.rb +18 -3
- data/lib/puppet/parser/functions/versioncmp.rb +1 -1
- data/lib/puppet/parser/interpreter.rb +1 -1
- data/lib/puppet/parser/lexer.rb +29 -31
- data/lib/puppet/parser/loaded_code.rb +4 -0
- data/lib/puppet/parser/parser_support.rb +5 -2
- data/lib/puppet/parser/resource.rb +31 -6
- data/lib/puppet/property.rb +3 -2
- data/lib/puppet/provider/macauthorization/macauthorization.rb +14 -14
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +15 -5
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +7 -10
- data/lib/puppet/provider/service/runit.rb +7 -17
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -47
- data/lib/puppet/provider/zone/solaris.rb +12 -3
- data/lib/puppet/relationship.rb +12 -12
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/store.rb +2 -2
- data/lib/puppet/reports/tagmail.rb +5 -16
- data/lib/puppet/resource.rb +15 -20
- data/lib/puppet/resource/catalog.rb +40 -29
- data/lib/puppet/ssl/certificate_revocation_list.rb +0 -2
- data/lib/puppet/ssl/host.rb +2 -3
- data/lib/puppet/sslcertificates/ca.rb +0 -5
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/file/owner.rb +7 -4
- data/lib/puppet/type/resources.rb +17 -17
- data/lib/puppet/type/yumrepo.rb +10 -3
- data/lib/puppet/util.rb +6 -11
- data/lib/puppet/util/inifile.rb +8 -0
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/monkey_patches.rb +0 -43
- data/lib/puppet/util/{json.rb → pson.rb} +6 -6
- data/lib/puppet/util/rdoc.rb +5 -3
- data/lib/puppet/util/selinux.rb +12 -6
- data/lib/puppet/util/settings.rb +25 -16
- data/lib/puppet/util/settings/file_setting.rb +4 -2
- data/spec/integration/application/puppet.rb +4 -4
- data/spec/integration/defaults.rb +2 -2
- data/spec/integration/indirector/catalog/queue.rb +5 -5
- data/spec/integration/indirector/certificate/rest.rb +3 -1
- data/spec/integration/network/formats.rb +36 -36
- data/spec/integration/parser/functions/require.rb +5 -3
- data/spec/integration/provider/mailalias/aliases.rb +4 -4
- data/spec/integration/resource/catalog.rb +4 -4
- data/spec/unit/application/puppet.rb +16 -15
- data/spec/unit/application/puppetd.rb +1 -1
- data/spec/unit/application/puppetdoc.rb +6 -0
- data/spec/unit/application/puppetmasterd.rb +6 -6
- data/spec/unit/configurer/fact_handler.rb +3 -3
- data/spec/unit/file_serving/configuration.rb +16 -2
- data/spec/unit/indirector/certificate/rest.rb +34 -0
- data/spec/unit/indirector/queue.rb +15 -15
- data/spec/unit/indirector/rest.rb +31 -9
- data/spec/unit/network/authstore.rb +105 -26
- data/spec/unit/network/formats.rb +124 -39
- data/spec/unit/parser/ast/leaf.rb +15 -0
- data/spec/unit/parser/collector.rb +20 -9
- data/spec/unit/parser/compiler.rb +19 -0
- data/spec/unit/parser/functions/fqdn_rand.rb +62 -0
- data/spec/unit/parser/functions/regsubst.rb +80 -0
- data/spec/unit/parser/functions/require.rb +19 -7
- data/spec/unit/parser/interpreter.rb +2 -2
- data/spec/unit/parser/lexer.rb +32 -7
- data/spec/unit/parser/loaded_code.rb +18 -1
- data/spec/unit/parser/parser.rb +10 -2
- data/spec/unit/parser/resource.rb +53 -2
- data/spec/unit/parser/scope.rb +1 -1
- data/spec/unit/property.rb +14 -4
- data/spec/unit/provider/package/dpkg.rb +7 -0
- data/spec/unit/provider/service/daemontools.rb +19 -2
- data/spec/unit/provider/service/redhat.rb +2 -0
- data/spec/unit/provider/service/runit.rb +15 -4
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +32 -55
- data/spec/unit/relationship.rb +21 -46
- data/spec/unit/resource.rb +30 -39
- data/spec/unit/resource/catalog.rb +66 -51
- data/spec/unit/ssl/certificate_revocation_list.rb +0 -12
- data/spec/unit/type/cron.rb +33 -0
- data/spec/unit/type/file/owner.rb +10 -4
- data/spec/unit/util/json.rb +9 -9
- data/spec/unit/util/log.rb +36 -0
- data/spec/unit/util/settings.rb +6 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys2 +1 -0
- data/test/lib/puppettest/support/utils.rb +8 -16
- metadata +36 -13
- data/lib/puppet/feature/json.rb +0 -2
@@ -10,6 +10,7 @@ describe "the require function" do
|
|
10
10
|
@compiler = Puppet::Parser::Compiler.new(@node, @parser)
|
11
11
|
|
12
12
|
@compiler.send(:evaluate_main)
|
13
|
+
@compiler.catalog.client_version = "0.25"
|
13
14
|
@scope = @compiler.topscope
|
14
15
|
# preload our functions
|
15
16
|
Puppet::Parser::Functions.function(:include)
|
@@ -20,10 +21,11 @@ describe "the require function" do
|
|
20
21
|
@parser.newclass("requiredclass")
|
21
22
|
|
22
23
|
@scope.function_require("requiredclass")
|
23
|
-
|
24
|
-
@
|
24
|
+
@scope.resource["require"].should_not be_nil
|
25
|
+
ref = @scope.resource["require"]
|
26
|
+
ref.type.should == "Class"
|
27
|
+
ref.title.should == "requiredclass"
|
25
28
|
end
|
26
|
-
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "the include function" do
|
@@ -17,9 +17,9 @@ describe provider_class do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# #1560
|
20
|
-
|
21
|
-
|
20
|
+
PuppetTest.fakedata("data/providers/mailalias/aliases").each { |file|
|
21
|
+
it "should be able to parse the examples in #{file}" do
|
22
22
|
fakedataparse(file)
|
23
|
-
|
24
|
-
|
23
|
+
end
|
24
|
+
}
|
25
25
|
end
|
@@ -6,10 +6,10 @@
|
|
6
6
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
7
7
|
|
8
8
|
describe Puppet::Resource::Catalog do
|
9
|
-
describe "when
|
10
|
-
confine "
|
11
|
-
it "should support
|
12
|
-
Puppet::Resource::Catalog.supported_formats.should be_include(:
|
9
|
+
describe "when pson is available" do
|
10
|
+
confine "PSON library is missing" => Puppet.features.pson?
|
11
|
+
it "should support pson" do
|
12
|
+
Puppet::Resource::Catalog.supported_formats.should be_include(:pson)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -143,6 +143,7 @@ describe "Puppet" do
|
|
143
143
|
@interpreter = stub_everything
|
144
144
|
Puppet.stubs(:err)
|
145
145
|
@puppet.stubs(:exit)
|
146
|
+
@puppet.options.stubs(:[]).with(:code).returns "some code"
|
146
147
|
Puppet::Parser::Interpreter.stubs(:new).returns(@interpreter)
|
147
148
|
end
|
148
149
|
|
@@ -331,17 +332,17 @@ describe "Puppet" do
|
|
331
332
|
end
|
332
333
|
|
333
334
|
describe "the 'apply' command" do
|
334
|
-
confine "
|
335
|
+
confine "PSON library is missing; cannot test applying catalogs" => Puppet.features.pson?
|
335
336
|
|
336
337
|
before do
|
337
|
-
#Puppet::Resource::Catalog.stubs(:
|
338
|
-
|
338
|
+
#Puppet::Resource::Catalog.stubs(:pson_create).returns Puppet::Resource::Catalog.new
|
339
|
+
PSON.stubs(:parse).returns Puppet::Resource::Catalog.new
|
339
340
|
end
|
340
341
|
|
341
342
|
it "should read the catalog in from disk if a file name is provided" do
|
342
|
-
@puppet.options[:catalog] = "/my/catalog.
|
343
|
+
@puppet.options[:catalog] = "/my/catalog.pson"
|
343
344
|
|
344
|
-
File.expects(:read).with("/my/catalog.
|
345
|
+
File.expects(:read).with("/my/catalog.pson").returns "something"
|
345
346
|
|
346
347
|
@puppet.apply
|
347
348
|
end
|
@@ -354,41 +355,41 @@ describe "Puppet" do
|
|
354
355
|
@puppet.apply
|
355
356
|
end
|
356
357
|
|
357
|
-
it "should deserialize the catalog from
|
358
|
-
@puppet.options[:catalog] = "/my/catalog.
|
358
|
+
it "should deserialize the catalog from pson" do
|
359
|
+
@puppet.options[:catalog] = "/my/catalog.pson"
|
359
360
|
|
360
361
|
File.expects(:read).returns "something"
|
361
|
-
|
362
|
+
PSON.expects(:parse).with("something").returns Puppet::Resource::Catalog.new
|
362
363
|
|
363
364
|
@puppet.apply
|
364
365
|
end
|
365
366
|
|
366
367
|
it "should fail helpfully if deserializing fails" do
|
367
|
-
@puppet.options[:catalog] = "/my/catalog.
|
368
|
+
@puppet.options[:catalog] = "/my/catalog.pson"
|
368
369
|
|
369
370
|
File.expects(:read).returns "something"
|
370
|
-
|
371
|
+
PSON.expects(:parse).raises ArgumentError
|
371
372
|
|
372
373
|
lambda { @puppet.apply }.should raise_error(Puppet::Error)
|
373
374
|
end
|
374
375
|
|
375
376
|
it "should convert plain data structures into a catalog if deserialization does not do so" do
|
376
|
-
@puppet.options[:catalog] = "/my/catalog.
|
377
|
+
@puppet.options[:catalog] = "/my/catalog.pson"
|
377
378
|
|
378
379
|
File.expects(:read).returns "something"
|
379
|
-
|
380
|
-
Puppet::Resource::Catalog.expects(:
|
380
|
+
PSON.expects(:parse).with("something").returns({:foo => "bar"})
|
381
|
+
Puppet::Resource::Catalog.expects(:pson_create).with({:foo => "bar"}).returns(Puppet::Resource::Catalog.new)
|
381
382
|
|
382
383
|
@puppet.apply
|
383
384
|
end
|
384
385
|
|
385
386
|
it "should convert the catalog to a RAL catalog and use a Configurer instance to apply it" do
|
386
|
-
@puppet.options[:catalog] = "/my/catalog.
|
387
|
+
@puppet.options[:catalog] = "/my/catalog.pson"
|
387
388
|
|
388
389
|
File.expects(:read).returns "something"
|
389
390
|
|
390
391
|
catalog = Puppet::Resource::Catalog.new
|
391
|
-
|
392
|
+
PSON.expects(:parse).returns catalog
|
392
393
|
|
393
394
|
catalog.expects(:to_ral).returns "mycatalog"
|
394
395
|
|
@@ -320,6 +320,12 @@ describe "puppetdoc" do
|
|
320
320
|
@puppetdoc.rdoc
|
321
321
|
end
|
322
322
|
|
323
|
+
it "should call Puppet::Util::RDoc.rdoc in full mode with outputdir set to doc if no --outputdir" do
|
324
|
+
@puppetdoc.options.expects(:[]).with(:outputdir).returns(false)
|
325
|
+
Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'])
|
326
|
+
@puppetdoc.rdoc
|
327
|
+
end
|
328
|
+
|
323
329
|
it "should call Puppet::Util::RDoc.manifestdoc in manifest mode" do
|
324
330
|
@puppetdoc.manifest = true
|
325
331
|
Puppet::Util::RDoc.expects(:manifestdoc)
|
@@ -294,11 +294,11 @@ describe "PuppetMaster" do
|
|
294
294
|
Puppet.stubs(:err)
|
295
295
|
@puppetmasterd.stubs(:exit)
|
296
296
|
Puppet::Parser::Interpreter.stubs(:new).returns(@interpreter)
|
297
|
-
Puppet.features.stubs(:
|
297
|
+
Puppet.features.stubs(:pson?).returns true
|
298
298
|
end
|
299
299
|
|
300
|
-
it "should fail if
|
301
|
-
Puppet.features.expects(:
|
300
|
+
it "should fail if pson isn't available" do
|
301
|
+
Puppet.features.expects(:pson?).returns false
|
302
302
|
lambda { @puppetmasterd.compile }.should raise_error
|
303
303
|
end
|
304
304
|
|
@@ -310,13 +310,13 @@ describe "PuppetMaster" do
|
|
310
310
|
@puppetmasterd.compile
|
311
311
|
end
|
312
312
|
|
313
|
-
it "should render the catalog to
|
313
|
+
it "should render the catalog to pson and print the output" do
|
314
314
|
@puppetmasterd.options[:node] = "foo"
|
315
315
|
catalog = Puppet::Resource::Catalog.new
|
316
|
-
catalog.expects(:render).with(:
|
316
|
+
catalog.expects(:render).with(:pson).returns "mypson"
|
317
317
|
Puppet::Resource::Catalog.expects(:find).returns catalog
|
318
318
|
|
319
|
-
$stdout.expects(:puts).with("
|
319
|
+
$stdout.expects(:puts).with("mypson")
|
320
320
|
@puppetmasterd.compile
|
321
321
|
end
|
322
322
|
|
@@ -102,7 +102,7 @@ describe Puppet::Configurer::FactHandler do
|
|
102
102
|
|
103
103
|
@facthandler.expects(:find_facts).returns facts
|
104
104
|
|
105
|
-
@facthandler.facts_for_uploading.should == {:facts_format => :
|
105
|
+
@facthandler.facts_for_uploading.should == {:facts_format => :b64_zlib_yaml, :facts => text}
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should properly accept facts containing a '+'" do
|
@@ -112,12 +112,12 @@ describe Puppet::Configurer::FactHandler do
|
|
112
112
|
|
113
113
|
@facthandler.expects(:find_facts).returns facts
|
114
114
|
|
115
|
-
@facthandler.facts_for_uploading.should == {:facts_format => :
|
115
|
+
@facthandler.facts_for_uploading.should == {:facts_format => :b64_zlib_yaml, :facts => text}
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should hard-code yaml as the serialization" do
|
119
119
|
facts = stub 'facts'
|
120
|
-
facts.expects(:render).with(:
|
120
|
+
facts.expects(:render).with(:b64_zlib_yaml).returns "my text"
|
121
121
|
text = CGI.escape("my text")
|
122
122
|
|
123
123
|
@facthandler.expects(:find_facts).returns facts
|
@@ -104,17 +104,31 @@ describe Puppet::FileServing::Configuration do
|
|
104
104
|
|
105
105
|
it "should allow all access to modules and plugins if no fileserver.conf exists" do
|
106
106
|
FileTest.expects(:exists?).returns false # the file doesn't exist
|
107
|
-
modules = stub 'modules'
|
107
|
+
modules = stub 'modules', :empty? => true
|
108
108
|
Puppet::FileServing::Mount::Modules.stubs(:new).returns(modules)
|
109
109
|
modules.expects(:allow).with('*')
|
110
110
|
|
111
|
-
plugins = stub 'plugins'
|
111
|
+
plugins = stub 'plugins', :empty? => true
|
112
112
|
Puppet::FileServing::Mount::Plugins.stubs(:new).returns(plugins)
|
113
113
|
plugins.expects(:allow).with('*')
|
114
114
|
|
115
115
|
Puppet::FileServing::Configuration.create
|
116
116
|
end
|
117
117
|
|
118
|
+
it "should not allow access from all to modules and plugins if the fileserver.conf provided some rules" do
|
119
|
+
FileTest.expects(:exists?).returns false # the file doesn't exist
|
120
|
+
|
121
|
+
modules = stub 'modules', :empty? => false
|
122
|
+
Puppet::FileServing::Mount::Modules.stubs(:new).returns(modules)
|
123
|
+
modules.expects(:allow).with('*').never
|
124
|
+
|
125
|
+
plugins = stub 'plugins', :empty? => false
|
126
|
+
Puppet::FileServing::Mount::Plugins.stubs(:new).returns(plugins)
|
127
|
+
plugins.expects(:allow).with('*').never
|
128
|
+
|
129
|
+
Puppet::FileServing::Configuration.create
|
130
|
+
end
|
131
|
+
|
118
132
|
it "should add modules and plugins mounts even if they are not returned by the parser" do
|
119
133
|
@parser.expects(:parse).returns("one" => mock("mount"))
|
120
134
|
FileTest.expects(:exists?).returns true # the file doesn't exist
|
@@ -20,4 +20,38 @@ describe Puppet::SSL::Certificate::Rest do
|
|
20
20
|
it "should set port_setting to :ca_port" do
|
21
21
|
Puppet::SSL::Certificate::Rest.port_setting.should == :ca_port
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should make sure found certificates have their names set to the search string" do
|
25
|
+
terminus = Puppet::SSL::Certificate::Rest.new
|
26
|
+
|
27
|
+
# This has 'boo.com' in the CN
|
28
|
+
cert_string = "-----BEGIN CERTIFICATE-----
|
29
|
+
MIICPzCCAaigAwIBAgIBBDANBgkqhkiG9w0BAQUFADAWMRQwEgYDVQQDDAtidWNr
|
30
|
+
eS5sb2NhbDAeFw0wOTA5MTcxNzI1MzJaFw0xNDA5MTYxNzI1MzJaMBIxEDAOBgNV
|
31
|
+
BAMMB2Jvby5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKG9B+DkTCNh
|
32
|
+
F5xHchNDfnbC9NzWKM600oxrr84pgUVAG6B2wAZcdfoEtXszhsY9Jzpwqkvxk4Mx
|
33
|
+
AbYqo9+TCi4UoiH6e+vAKOOJD3DHrlf+/RW4hGtyaI41DBhf4+B4/oFz5PH9mvKe
|
34
|
+
NSfHFI/yPW+1IXYjxKLQNwF9E7q3JbnzAgMBAAGjgaAwgZ0wOAYJYIZIAYb4QgEN
|
35
|
+
BCsWKVB1cHBldCBSdWJ5L09wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMAwG
|
36
|
+
A1UdEwEB/wQCMAAwHQYDVR0OBBYEFJOxEUeyf4cNOBmf9zIaE1JTuNdLMAsGA1Ud
|
37
|
+
DwQEAwIFoDAnBgNVHSUEIDAeBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwME
|
38
|
+
MA0GCSqGSIb3DQEBBQUAA4GBAFTJxKprMg6tfhGnvEvURPmlJrINn9c2b5Y4AGYp
|
39
|
+
tO86PFFkWw/EIJvvJzbj3s+Butr+eUo//+f1xxX7UCwwGqGxKqjtVS219oU/wkx8
|
40
|
+
h7rW4Xk7MrLl0auSS1p4wLcAMm+ZImf94+j8Cj+tkr8eGozZceRV13b8+EkdaE3S
|
41
|
+
rn/G
|
42
|
+
-----END CERTIFICATE-----
|
43
|
+
"
|
44
|
+
|
45
|
+
network = stub 'network'
|
46
|
+
terminus.stubs(:network).returns network
|
47
|
+
|
48
|
+
response = stub 'response', :code => "200", :body => cert_string
|
49
|
+
response.stubs(:[]).with('content-type').returns "text/plain"
|
50
|
+
network.expects(:get).returns response
|
51
|
+
|
52
|
+
request = Puppet::Indirector::Request.new(:certificate, :find, "foo.com")
|
53
|
+
result = terminus.find(request)
|
54
|
+
result.should_not be_nil
|
55
|
+
result.name.should == "foo.com"
|
56
|
+
end
|
23
57
|
end
|
@@ -9,25 +9,25 @@ end
|
|
9
9
|
class FooExampleData
|
10
10
|
attr_accessor :name
|
11
11
|
|
12
|
-
def self.
|
13
|
-
new(
|
12
|
+
def self.pson_create(pson)
|
13
|
+
new(pson['data'].to_sym)
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(name = nil)
|
17
17
|
@name = name if name
|
18
18
|
end
|
19
19
|
|
20
|
-
def render(format = :
|
21
|
-
|
20
|
+
def render(format = :pson)
|
21
|
+
to_pson
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
{:
|
24
|
+
def to_pson(*args)
|
25
|
+
{:type => self.class.to_s, :data => name}.to_pson(*args)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe Puppet::Indirector::Queue do
|
30
|
-
confine "
|
30
|
+
confine "PSON library is missing; cannot test queueing" => Puppet.features.pson?
|
31
31
|
|
32
32
|
before :each do
|
33
33
|
@model = mock 'model'
|
@@ -51,8 +51,8 @@ describe Puppet::Indirector::Queue do
|
|
51
51
|
@request = stub 'request', :key => :me, :instance => @subject
|
52
52
|
end
|
53
53
|
|
54
|
-
it "should require
|
55
|
-
Puppet.features.expects(:
|
54
|
+
it "should require PSON" do
|
55
|
+
Puppet.features.expects(:pson?).returns false
|
56
56
|
|
57
57
|
lambda { @store_class.new }.should raise_error(ArgumentError)
|
58
58
|
end
|
@@ -63,16 +63,16 @@ describe Puppet::Indirector::Queue do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "when saving" do
|
66
|
-
it 'should render the instance using
|
67
|
-
@subject.expects(:render).with(:
|
66
|
+
it 'should render the instance using pson' do
|
67
|
+
@subject.expects(:render).with(:pson)
|
68
68
|
@store.client.stubs(:send_message)
|
69
69
|
@store.save(@request)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should send the rendered message to the appropriate queue on the client" do
|
73
|
-
@subject.expects(:render).returns "
|
73
|
+
@subject.expects(:render).returns "mypson"
|
74
74
|
|
75
|
-
@store.client.expects(:send_message).with(:my_queue, "
|
75
|
+
@store.client.expects(:send_message).with(:my_queue, "mypson")
|
76
76
|
|
77
77
|
@store.save(@request)
|
78
78
|
end
|
@@ -89,8 +89,8 @@ describe Puppet::Indirector::Queue do
|
|
89
89
|
@store_class.stubs(:model).returns @model
|
90
90
|
end
|
91
91
|
|
92
|
-
it "should use the model's Format support to intern the message from
|
93
|
-
@model.expects(:convert_from).with(:
|
92
|
+
it "should use the model's Format support to intern the message from pson" do
|
93
|
+
@model.expects(:convert_from).with(:pson, "mymessage")
|
94
94
|
|
95
95
|
@store_class.client.expects(:subscribe).yields("mymessage")
|
96
96
|
@store_class.subscribe {|o| o }
|
@@ -90,15 +90,37 @@ describe Puppet::Indirector::REST do
|
|
90
90
|
@searcher.deserialize(response).should be_nil
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
93
|
+
[300,400,403,405,500,501,502,503,504].each { |rc|
|
94
|
+
describe "when the response code is #{rc}" do
|
95
|
+
before :each do
|
96
|
+
@model.expects(:convert_from).never
|
97
|
+
|
98
|
+
@response = mock 'response'
|
99
|
+
@response.stubs(:code).returns rc.to_s
|
100
|
+
@response.stubs(:message).returns "There was a problem (header)"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should fail" do
|
104
|
+
@response.stubs(:body).returns nil
|
105
|
+
lambda { @searcher.deserialize(@response) }.should raise_error(Net::HTTPError)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should take the error message from the body, if present" do
|
109
|
+
@response.stubs(:body).returns "There was a problem (body)"
|
110
|
+
lambda { @searcher.deserialize(@response) }.should raise_error(Net::HTTPError,"Error #{rc} on SERVER: There was a problem (body)")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should take the error message from the response header if the body is empty" do
|
114
|
+
@response.stubs(:body).returns ""
|
115
|
+
lambda { @searcher.deserialize(@response) }.should raise_error(Net::HTTPError,"Error #{rc} on SERVER: There was a problem (header)")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should take the error message from the response header if the body is absent" do
|
119
|
+
@response.stubs(:body).returns nil
|
120
|
+
lambda { @searcher.deserialize(@response) }.should raise_error(Net::HTTPError,"Error #{rc} on SERVER: There was a problem (header)")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
}
|
102
124
|
|
103
125
|
it "should return the results of converting from the format specified by the content-type header if the response code is in the 200s" do
|
104
126
|
@model.expects(:convert_from).with("myformat", "mydata").returns "myobject"
|
@@ -4,27 +4,78 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
4
4
|
|
5
5
|
require 'puppet/network/authconfig'
|
6
6
|
|
7
|
-
describe Puppet::Network::AuthStore
|
8
|
-
|
9
|
-
describe "when the pattern is simple numeric IP" do
|
7
|
+
describe Puppet::Network::AuthStore do
|
8
|
+
describe "when checking if the acl has some entries" do
|
10
9
|
before :each do
|
11
|
-
@
|
12
|
-
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,@ip)
|
10
|
+
@authstore = Puppet::Network::AuthStore.new
|
13
11
|
end
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
it "should be empty if no ACE have been entered" do
|
14
|
+
@authstore.should be_empty
|
16
15
|
end
|
17
|
-
|
18
|
-
|
16
|
+
|
17
|
+
it "should not be empty if it is a global allow" do
|
18
|
+
@authstore.allow('*')
|
19
|
+
|
20
|
+
@authstore.should_not be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not be empty if at least one allow has been entered" do
|
24
|
+
@authstore.allow('1.1.1.*')
|
25
|
+
|
26
|
+
@authstore.should_not be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not be empty if at least one deny has been entered" do
|
30
|
+
@authstore.deny('1.1.1.*')
|
31
|
+
|
32
|
+
@authstore.should_not be_empty
|
19
33
|
end
|
20
34
|
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe Puppet::Network::AuthStore::Declaration do
|
38
|
+
|
39
|
+
['100.101.99.98','100.100.100.100','1.2.3.4','11.22.33.44'].each { |ip|
|
40
|
+
describe "when the pattern is a simple numeric IP such as #{ip}" do
|
41
|
+
before :each do
|
42
|
+
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,ip)
|
43
|
+
end
|
44
|
+
it "should match the specified IP" do
|
45
|
+
@declaration.should be_match('www.testsite.org',ip)
|
46
|
+
end
|
47
|
+
it "should not match other IPs" do
|
48
|
+
@declaration.should_not be_match('www.testsite.org','200.101.99.98')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
(1..3).each { |n|
|
53
|
+
describe "when the pattern is a IP mask with #{n} numeric segments and a *" do
|
54
|
+
before :each do
|
55
|
+
@ip_pattern = ip.split('.')[0,n].join('.')+'.*'
|
56
|
+
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,@ip_pattern)
|
57
|
+
end
|
58
|
+
it "should match an IP in the range" do
|
59
|
+
@declaration.should be_match('www.testsite.org',ip)
|
60
|
+
end
|
61
|
+
it "should not match other IPs" do
|
62
|
+
@declaration.should_not be_match('www.testsite.org','200.101.99.98')
|
63
|
+
end
|
64
|
+
it "should not match IPs that differ in the last non-wildcard segment" do
|
65
|
+
other = ip.split('.')
|
66
|
+
other[n-1].succ!
|
67
|
+
@declaration.should_not be_match('www.testsite.org',other.join('.'))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
}
|
71
|
+
}
|
21
72
|
|
22
73
|
describe "when the pattern is a numeric IP with a back reference" do
|
23
74
|
before :each do
|
24
75
|
@ip = '100.101.$1'
|
25
76
|
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,@ip).interpolate('12.34'.match(/(.*)/))
|
26
77
|
end
|
27
|
-
it "should match an IP with the
|
78
|
+
it "should match an IP with the appropriate interpolation" do
|
28
79
|
@declaration.should be_match('www.testsite.org',@ip.sub(/\$1/,'12.34'))
|
29
80
|
end
|
30
81
|
it "should not match other IPs" do
|
@@ -32,20 +83,25 @@ describe Puppet::Network::AuthStore::Declaration do
|
|
32
83
|
end
|
33
84
|
end
|
34
85
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
86
|
+
{
|
87
|
+
'spirit.mars.nasa.gov' => 'a PQDN',
|
88
|
+
'ratchet.2ndsiteinc.com' => 'a PQDN with digits',
|
89
|
+
'a.c.ru' => 'a PQDN with short segments',
|
90
|
+
}.each {|pqdn,desc|
|
91
|
+
describe "when the pattern is #{desc}" do
|
92
|
+
before :each do
|
93
|
+
@host = pqdn
|
94
|
+
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,@host)
|
95
|
+
end
|
96
|
+
it "should match the specified PQDN" do
|
97
|
+
@declaration.should be_match(@host,'200.101.99.98')
|
98
|
+
end
|
99
|
+
it "should not match a similar FQDN" do
|
100
|
+
pending "FQDN consensus"
|
101
|
+
@declaration.should_not be_match(@host+'.','200.101.99.98')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
}
|
49
105
|
|
50
106
|
describe "when the pattern is a FQDN" do
|
51
107
|
before :each do
|
@@ -57,7 +113,6 @@ describe Puppet::Network::AuthStore::Declaration do
|
|
57
113
|
@declaration.should be_match(@host,'200.101.99.98')
|
58
114
|
end
|
59
115
|
it "should not match a similar PQDN" do
|
60
|
-
#pending "FQDN consensus"
|
61
116
|
@declaration.should_not be_match(@host[0..-2],'200.101.99.98')
|
62
117
|
end
|
63
118
|
end
|
@@ -70,7 +125,31 @@ describe Puppet::Network::AuthStore::Declaration do
|
|
70
125
|
@pattern = %{^/catalog/([^/]+)$}
|
71
126
|
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,'$1')
|
72
127
|
end
|
73
|
-
it "should match an IP with the
|
128
|
+
it "should match an IP with the appropriate interpolation" do
|
129
|
+
@declaration.interpolate(@item.match(@pattern)).should be_match(@host,'10.0.0.5')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "when the pattern is an opaque string with a back reference and the matched data contains dots" do
|
134
|
+
before :each do
|
135
|
+
@host = 'admin.mgmt.nym1'
|
136
|
+
@item = "/catalog/#{@host}"
|
137
|
+
@pattern = %{^/catalog/([^/]+)$}
|
138
|
+
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,'$1')
|
139
|
+
end
|
140
|
+
it "should match a name with the appropriate interpolation" do
|
141
|
+
@declaration.interpolate(@item.match(@pattern)).should be_match(@host,'10.0.0.5')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "when the pattern is an opaque string with a back reference and the matched data contains dots with an initial prefix that looks like an IP address" do
|
146
|
+
before :each do
|
147
|
+
@host = '01.admin.mgmt.nym1'
|
148
|
+
@item = "/catalog/#{@host}"
|
149
|
+
@pattern = %{^/catalog/([^/]+)$}
|
150
|
+
@declaration = Puppet::Network::AuthStore::Declaration.new(:allow,'$1')
|
151
|
+
end
|
152
|
+
it "should match a name with the appropriate interpolation" do
|
74
153
|
@declaration.interpolate(@item.match(@pattern)).should be_match(@host,'10.0.0.5')
|
75
154
|
end
|
76
155
|
end
|