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.
- data/CHANGELOG +121 -0
- data/conf/redhat/puppet.spec +16 -7
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/cert.rb +17 -3
- data/lib/puppet/application/device.rb +1 -0
- data/lib/puppet/application/kick.rb +0 -2
- data/lib/puppet/application/resource.rb +73 -66
- data/lib/puppet/configurer/plugin_handler.rb +6 -2
- data/lib/puppet/defaults.rb +60 -5
- data/lib/puppet/face/ca.rb +11 -2
- data/lib/puppet/face/certificate.rb +33 -4
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/file_serving/indirection_hooks.rb +2 -2
- data/lib/puppet/file_serving/metadata.rb +43 -4
- data/lib/puppet/indirector.rb +0 -1
- data/lib/puppet/indirector/request.rb +3 -4
- data/lib/puppet/indirector/resource/active_record.rb +3 -10
- data/lib/puppet/indirector/resource/ral.rb +2 -2
- data/lib/puppet/indirector/rest.rb +1 -1
- data/lib/puppet/network/handler/ca.rb +16 -106
- data/lib/puppet/network/handler/master.rb +0 -3
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/parser/scope.rb +10 -0
- data/lib/puppet/provider/file/posix.rb +72 -34
- data/lib/puppet/provider/file/windows.rb +100 -0
- data/lib/puppet/provider/group/windows_adsi.rb +2 -2
- data/lib/puppet/provider/user/windows_adsi.rb +19 -4
- data/lib/puppet/resource.rb +16 -0
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/ssl/certificate.rb +2 -2
- data/lib/puppet/ssl/certificate_authority.rb +86 -10
- data/lib/puppet/ssl/certificate_authority/interface.rb +64 -19
- data/lib/puppet/ssl/certificate_factory.rb +112 -91
- data/lib/puppet/ssl/certificate_request.rb +88 -1
- data/lib/puppet/ssl/host.rb +20 -3
- data/lib/puppet/type/file.rb +15 -34
- data/lib/puppet/type/file/group.rb +11 -91
- data/lib/puppet/type/file/mode.rb +11 -41
- data/lib/puppet/type/file/owner.rb +18 -34
- data/lib/puppet/type/file/source.rb +22 -7
- data/lib/puppet/type/group.rb +4 -3
- data/lib/puppet/type/user.rb +4 -1
- data/lib/puppet/util.rb +59 -6
- data/lib/puppet/util/adsi.rb +11 -0
- data/lib/puppet/util/log.rb +4 -0
- data/lib/puppet/util/log/destinations.rb +7 -1
- data/lib/puppet/util/monkey_patches.rb +19 -0
- data/lib/puppet/util/network_device/config.rb +4 -5
- data/lib/puppet/util/settings.rb +5 -0
- data/lib/puppet/util/suidmanager.rb +0 -1
- data/lib/puppet/util/windows.rb +4 -0
- data/lib/puppet/util/windows/error.rb +16 -0
- data/lib/puppet/util/windows/security.rb +593 -0
- data/spec/integration/defaults_spec.rb +27 -0
- data/spec/integration/network/handler_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +382 -145
- data/spec/integration/util/windows/security_spec.rb +468 -0
- data/spec/shared_behaviours/file_serving.rb +4 -3
- data/spec/unit/application/agent_spec.rb +1 -0
- data/spec/unit/application/device_spec.rb +5 -0
- data/spec/unit/application/resource_spec.rb +62 -101
- data/spec/unit/configurer/downloader_spec.rb +2 -2
- data/spec/unit/configurer/plugin_handler_spec.rb +15 -8
- data/spec/unit/configurer_spec.rb +2 -2
- data/spec/unit/face/ca_spec.rb +34 -0
- data/spec/unit/face/certificate_spec.rb +168 -1
- data/spec/unit/file_serving/fileset_spec.rb +1 -1
- data/spec/unit/file_serving/indirection_hooks_spec.rb +1 -1
- data/spec/unit/file_serving/metadata_spec.rb +151 -107
- data/spec/unit/indirector/certificate_request/ca_spec.rb +0 -3
- data/spec/unit/indirector/direct_file_server_spec.rb +10 -9
- data/spec/unit/indirector/file_metadata/file_spec.rb +6 -4
- data/spec/unit/indirector/request_spec.rb +13 -3
- data/spec/unit/indirector/resource/active_record_spec.rb +4 -10
- data/spec/unit/indirector/resource/ral_spec.rb +6 -4
- data/spec/unit/indirector/rest_spec.rb +5 -6
- data/spec/unit/network/handler/ca_spec.rb +86 -0
- data/spec/unit/parser/collector_spec.rb +7 -7
- data/spec/unit/parser/scope_spec.rb +20 -0
- data/spec/unit/provider/file/posix_spec.rb +226 -0
- data/spec/unit/provider/file/windows_spec.rb +136 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +7 -2
- data/spec/unit/provider/user/windows_adsi_spec.rb +36 -3
- data/spec/unit/resource/catalog_spec.rb +20 -10
- data/spec/unit/resource_spec.rb +55 -8
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +97 -54
- data/spec/unit/ssl/certificate_authority_spec.rb +133 -23
- data/spec/unit/ssl/certificate_factory_spec.rb +90 -70
- data/spec/unit/ssl/certificate_request_spec.rb +62 -1
- data/spec/unit/ssl/certificate_spec.rb +20 -14
- data/spec/unit/ssl/host_spec.rb +52 -6
- data/spec/unit/type/file/content_spec.rb +4 -4
- data/spec/unit/type/file/group_spec.rb +34 -96
- data/spec/unit/type/file/mode_spec.rb +88 -0
- data/spec/unit/type/file/owner_spec.rb +32 -123
- data/spec/unit/type/file/source_spec.rb +120 -41
- data/spec/unit/type/file_spec.rb +1033 -753
- data/spec/unit/type_spec.rb +19 -1
- data/spec/unit/util/adsi_spec.rb +19 -0
- data/spec/unit/util/log/destinations_spec.rb +75 -0
- data/spec/unit/util/log_spec.rb +15 -0
- data/spec/unit/util/network_device/config_spec.rb +7 -0
- data/spec/unit/util/settings_spec.rb +10 -0
- data/spec/unit/util_spec.rb +126 -13
- data/test/language/functions.rb +0 -1
- data/test/language/snippets.rb +0 -9
- data/test/lib/puppettest/exetest.rb +1 -1
- data/test/lib/puppettest/servertest.rb +0 -1
- data/test/rails/rails.rb +0 -1
- data/test/ral/type/filesources.rb +0 -60
- metadata +13 -33
- data/lib/puppet/network/client.rb +0 -174
- data/lib/puppet/network/client/ca.rb +0 -56
- data/lib/puppet/network/client/file.rb +0 -6
- data/lib/puppet/network/client/proxy.rb +0 -27
- data/lib/puppet/network/client/report.rb +0 -26
- data/lib/puppet/network/client/runner.rb +0 -10
- data/lib/puppet/network/client/status.rb +0 -4
- data/lib/puppet/network/http_server.rb +0 -3
- data/lib/puppet/network/http_server/mongrel.rb +0 -130
- data/lib/puppet/network/http_server/webrick.rb +0 -155
- data/lib/puppet/network/xmlrpc/client.rb +0 -211
- data/lib/puppet/provider/file/win32.rb +0 -72
- data/lib/puppet/sslcertificates.rb +0 -146
- data/lib/puppet/sslcertificates/ca.rb +0 -375
- data/lib/puppet/sslcertificates/certificate.rb +0 -255
- data/lib/puppet/sslcertificates/inventory.rb +0 -38
- data/lib/puppet/sslcertificates/support.rb +0 -146
- data/spec/integration/network/client_spec.rb +0 -18
- data/spec/unit/network/xmlrpc/client_spec.rb +0 -172
- data/spec/unit/sslcertificates/ca_spec.rb +0 -106
- data/test/certmgr/certmgr.rb +0 -308
- data/test/certmgr/inventory.rb +0 -69
- data/test/certmgr/support.rb +0 -105
- data/test/network/client/ca.rb +0 -69
- data/test/network/client/dipper.rb +0 -34
- data/test/network/handler/ca.rb +0 -273
- data/test/network/server/mongrel_test.rb +0 -99
- data/test/network/server/webrick.rb +0 -111
- data/test/network/xmlrpc/client.rb +0 -45
@@ -0,0 +1,136 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
if Puppet.features.microsoft_windows?
|
5
|
+
require 'puppet/util/windows'
|
6
|
+
class WindowsSecurity
|
7
|
+
extend Puppet::Util::Windows::Security
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Puppet::Type.type(:file).provider(:windows), :if => Puppet.features.microsoft_windows? do
|
12
|
+
include PuppetSpec::Files
|
13
|
+
|
14
|
+
let(:path) { tmpfile('windows_file_spec') }
|
15
|
+
let(:resource) { Puppet::Type.type(:file).new :path => path, :mode => 0777, :provider => described_class.name }
|
16
|
+
let(:provider) { resource.provider }
|
17
|
+
|
18
|
+
describe "#mode" do
|
19
|
+
it "should return a string with the higher-order bits stripped away" do
|
20
|
+
FileUtils.touch(path)
|
21
|
+
WindowsSecurity.set_mode(0644, path)
|
22
|
+
|
23
|
+
provider.mode.should == '644'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return absent if the file doesn't exist" do
|
27
|
+
provider.mode.should == :absent
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#mode=" do
|
32
|
+
it "should chmod the file to the specified value" do
|
33
|
+
FileUtils.touch(path)
|
34
|
+
WindowsSecurity.set_mode(0644, path)
|
35
|
+
|
36
|
+
provider.mode = '0755'
|
37
|
+
|
38
|
+
provider.mode.should == '755'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should pass along any errors encountered" do
|
42
|
+
expect do
|
43
|
+
provider.mode = '644'
|
44
|
+
end.to raise_error(Puppet::Error, /failed to set mode/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#id2name" do
|
49
|
+
it "should return the name of the user identified by the sid" do
|
50
|
+
result = [stub('user', :name => 'quinn')]
|
51
|
+
Puppet::Util::ADSI.stubs(:execquery).returns(result)
|
52
|
+
|
53
|
+
provider.id2name('S-1-1-50').should == 'quinn'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return the argument if it's already a name" do
|
57
|
+
provider.id2name('flannigan').should == 'flannigan'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should return nil if the user doesn't exist" do
|
61
|
+
Puppet::Util::ADSI.stubs(:execquery).returns []
|
62
|
+
|
63
|
+
provider.id2name('S-1-1-50').should == nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#name2id" do
|
68
|
+
it "should return the sid of the user" do
|
69
|
+
Puppet::Util::ADSI.stubs(:execquery).returns [stub('account', :Sid => 'S-1-1-50')]
|
70
|
+
|
71
|
+
provider.name2id('anybody').should == 'S-1-1-50'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return the argument if it's already a sid" do
|
75
|
+
provider.name2id('S-1-1-50').should == 'S-1-1-50'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return nil if the user doesn't exist" do
|
79
|
+
Puppet::Util::ADSI.stubs(:execquery).returns []
|
80
|
+
|
81
|
+
provider.name2id('someone').should == nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#owner" do
|
86
|
+
it "should return the sid of the owner if the file does exist" do
|
87
|
+
FileUtils.touch(resource[:path])
|
88
|
+
provider.stubs(:get_owner).with(resource[:path]).returns('S-1-1-50')
|
89
|
+
|
90
|
+
provider.owner.should == 'S-1-1-50'
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return absent if the file doesn't exist" do
|
94
|
+
provider.owner.should == :absent
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#owner=" do
|
99
|
+
it "should set the owner to the specified value" do
|
100
|
+
provider.expects(:set_owner).with('S-1-1-50', resource[:path])
|
101
|
+
provider.owner = 'S-1-1-50'
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should propagate any errors encountered when setting the owner" do
|
105
|
+
provider.stubs(:set_owner).raises(ArgumentError)
|
106
|
+
|
107
|
+
expect { provider.owner = 'S-1-1-50' }.to raise_error(Puppet::Error, /Failed to set owner/)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#group" do
|
112
|
+
it "should return the sid of the group if the file does exist" do
|
113
|
+
FileUtils.touch(resource[:path])
|
114
|
+
provider.stubs(:get_group).with(resource[:path]).returns('S-1-1-50')
|
115
|
+
|
116
|
+
provider.group.should == 'S-1-1-50'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should return absent if the file doesn't exist" do
|
120
|
+
provider.group.should == :absent
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "#group=" do
|
125
|
+
it "should set the group to the specified value" do
|
126
|
+
provider.expects(:set_group).with('S-1-1-50', resource[:path])
|
127
|
+
provider.group = 'S-1-1-50'
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should propagate any errors encountered when setting the group" do
|
131
|
+
provider.stubs(:set_group).raises(ArgumentError)
|
132
|
+
|
133
|
+
expect { provider.group = 'S-1-1-50' }.to raise_error(Puppet::Error, /Failed to set group/)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -72,8 +72,13 @@ describe Puppet::Type.type(:group).provider(:windows_adsi) do
|
|
72
72
|
provider.delete
|
73
73
|
end
|
74
74
|
|
75
|
-
it "should
|
76
|
-
|
75
|
+
it "should report the group's SID as gid" do
|
76
|
+
Puppet::Util::ADSI.expects(:sid_for_account).with('testers').returns('S-1-5-32-547')
|
77
|
+
provider.gid.should == 'S-1-5-32-547'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should fail when trying to manage the gid property" do
|
81
|
+
provider.expects(:fail).with { |msg| msg =~ /gid is read-only/ }
|
77
82
|
provider.send(:gid=, 500)
|
78
83
|
end
|
79
84
|
end
|
@@ -79,6 +79,28 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
|
|
79
79
|
|
80
80
|
provider.create
|
81
81
|
end
|
82
|
+
|
83
|
+
it "should set a user's password" do
|
84
|
+
provider.user.expects(:password=).with('plaintextbad')
|
85
|
+
|
86
|
+
provider.password = "plaintextbad"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should test a valid user password" do
|
90
|
+
resource[:password] = 'plaintext'
|
91
|
+
provider.user.expects(:password_is?).with('plaintext').returns true
|
92
|
+
|
93
|
+
provider.password.should == 'plaintext'
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should test a bad user password" do
|
98
|
+
resource[:password] = 'plaintext'
|
99
|
+
provider.user.expects(:password_is?).with('plaintext').returns false
|
100
|
+
|
101
|
+
provider.password.should == :absent
|
102
|
+
end
|
103
|
+
|
82
104
|
end
|
83
105
|
|
84
106
|
it 'should be able to test whether a user exists' do
|
@@ -101,9 +123,20 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
|
|
101
123
|
provider.flush
|
102
124
|
end
|
103
125
|
|
104
|
-
|
105
|
-
|
106
|
-
|
126
|
+
it "should return the user's SID as uid" do
|
127
|
+
Puppet::Util::ADSI.expects(:sid_for_account).with('testuser').returns('S-1-5-21-1362942247-2130103807-3279964888-1111')
|
128
|
+
|
129
|
+
provider.uid.should == 'S-1-5-21-1362942247-2130103807-3279964888-1111'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should fail when trying to manage the uid property" do
|
133
|
+
provider.expects(:fail).with { |msg| msg =~ /uid is read-only/ }
|
134
|
+
provider.send(:uid=, 500)
|
135
|
+
end
|
136
|
+
|
137
|
+
[:gid, :shell].each do |prop|
|
138
|
+
it "should fail when trying to manage the #{prop} property" do
|
139
|
+
provider.expects(:fail).with { |msg| msg =~ /No support for managing property #{prop}/ }
|
107
140
|
provider.send("#{prop}=", 'foo')
|
108
141
|
end
|
109
142
|
end
|
@@ -10,35 +10,45 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
10
10
|
Puppet::Util::Storage.stubs(:store)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
# audit only resources are unmanaged
|
14
|
+
# as are resources without properties with should values
|
15
|
+
it "should write its managed resources' types, namevars" do
|
14
16
|
catalog = Puppet::Resource::Catalog.new("host")
|
15
17
|
|
16
18
|
resourcefile = tmpfile('resourcefile')
|
17
19
|
Puppet[:resourcefile] = resourcefile
|
18
20
|
|
19
|
-
res = Puppet::Type.type('file').new(:title => '/tmp/sam')
|
21
|
+
res = Puppet::Type.type('file').new(:title => File.expand_path('/tmp/sam'), :ensure => 'present')
|
20
22
|
res.file = 'site.pp'
|
21
23
|
res.line = 21
|
22
24
|
|
23
|
-
res2 = Puppet::Type.type('exec').new(:title => 'bob', :command => '/bin/rm -rf /
|
24
|
-
res2.file = '/modules/bob/manifests/bob.pp'
|
25
|
+
res2 = Puppet::Type.type('exec').new(:title => 'bob', :command => "#{File.expand_path('/bin/rm')} -rf /")
|
26
|
+
res2.file = File.expand_path('/modules/bob/manifests/bob.pp')
|
25
27
|
res2.line = 42
|
26
28
|
|
29
|
+
res3 = Puppet::Type.type('file').new(:title => File.expand_path('/tmp/susan'), :audit => 'all')
|
30
|
+
res3.file = 'site.pp'
|
31
|
+
res3.line = 63
|
32
|
+
|
33
|
+
res4 = Puppet::Type.type('file').new(:title => File.expand_path('/tmp/lilly'))
|
34
|
+
res4.file = 'site.pp'
|
35
|
+
res4.line = 84
|
36
|
+
|
27
37
|
comp_res = Puppet::Type.type('component').new(:title => 'Class[Main]')
|
28
38
|
|
29
|
-
catalog.add_resource(res, res2, comp_res)
|
39
|
+
catalog.add_resource(res, res2, res3, res4, comp_res)
|
30
40
|
catalog.write_resource_file
|
31
|
-
File.
|
32
|
-
"file[/tmp/sam]",
|
33
|
-
"exec[/bin/rm -rf /]"
|
41
|
+
File.readlines(resourcefile).map(&:chomp).should =~ [
|
42
|
+
"file[#{File.expand_path('/tmp/sam')}]",
|
43
|
+
"exec[#{File.expand_path('/bin/rm')} -rf /]"
|
34
44
|
]
|
35
45
|
end
|
36
46
|
|
37
47
|
it "should log an error if unable to write to the resource file" do
|
38
48
|
catalog = Puppet::Resource::Catalog.new("host")
|
39
|
-
Puppet[:resourcefile] = '/not/writable/file'
|
49
|
+
Puppet[:resourcefile] = File.expand_path('/not/writable/file')
|
40
50
|
|
41
|
-
catalog.add_resource(Puppet::Type.type('file').new(:title => '/tmp/foo'))
|
51
|
+
catalog.add_resource(Puppet::Type.type('file').new(:title => File.expand_path('/tmp/foo')))
|
42
52
|
catalog.write_resource_file
|
43
53
|
@logs.size.should == 1
|
44
54
|
@logs.first.message.should =~ /Could not create resource file/
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -501,10 +501,6 @@ type: File
|
|
501
501
|
end
|
502
502
|
end
|
503
503
|
|
504
|
-
it "should be able to convert itself to Puppet code" do
|
505
|
-
Puppet::Resource.new("one::two", "/my/file").should respond_to(:to_manifest)
|
506
|
-
end
|
507
|
-
|
508
504
|
describe "when converting to puppet code" do
|
509
505
|
before do
|
510
506
|
@resource = Puppet::Resource.new("one::two", "/my/file",
|
@@ -527,10 +523,6 @@ type: File
|
|
527
523
|
end
|
528
524
|
end
|
529
525
|
|
530
|
-
it "should be able to convert itself to a TransObject instance" do
|
531
|
-
Puppet::Resource.new("one::two", "/my/file").should respond_to(:to_trans)
|
532
|
-
end
|
533
|
-
|
534
526
|
describe "when converting to a TransObject" do
|
535
527
|
describe "and the resource is not an instance of a builtin type" do
|
536
528
|
before do
|
@@ -808,4 +800,59 @@ type: File
|
|
808
800
|
res.uniqueness_key.should == [ nil, 'root', '/my/file']
|
809
801
|
end
|
810
802
|
end
|
803
|
+
|
804
|
+
describe "#prune_parameters" do
|
805
|
+
before do
|
806
|
+
Puppet.newtype('blond') do
|
807
|
+
newproperty(:ensure)
|
808
|
+
newproperty(:height)
|
809
|
+
newproperty(:weight)
|
810
|
+
newproperty(:sign)
|
811
|
+
newproperty(:friends)
|
812
|
+
newparam(:admits_to_dying_hair)
|
813
|
+
newparam(:admits_to_age)
|
814
|
+
newparam(:name)
|
815
|
+
end
|
816
|
+
end
|
817
|
+
|
818
|
+
it "should strip all parameters and strip properties that are nil, empty or absent except for ensure" do
|
819
|
+
resource = Puppet::Resource.new("blond", "Bambi", :parameters => {
|
820
|
+
:ensure => 'absent',
|
821
|
+
:height => '',
|
822
|
+
:weight => 'absent',
|
823
|
+
:friends => [],
|
824
|
+
:admits_to_age => true,
|
825
|
+
:admits_to_dying_hair => false
|
826
|
+
})
|
827
|
+
|
828
|
+
pruned_resource = resource.prune_parameters
|
829
|
+
pruned_resource.should == Puppet::Resource.new("blond", "Bambi", :parameters => {:ensure => 'absent'})
|
830
|
+
end
|
831
|
+
|
832
|
+
it "should leave parameters alone if in parameters_to_include" do
|
833
|
+
resource = Puppet::Resource.new("blond", "Bambi", :parameters => {
|
834
|
+
:admits_to_age => true,
|
835
|
+
:admits_to_dying_hair => false
|
836
|
+
})
|
837
|
+
|
838
|
+
pruned_resource = resource.prune_parameters(:parameters_to_include => [:admits_to_dying_hair])
|
839
|
+
pruned_resource.should == Puppet::Resource.new("blond", "Bambi", :parameters => {:admits_to_dying_hair => false})
|
840
|
+
end
|
841
|
+
|
842
|
+
it "should leave properties if not nil, absent or empty" do
|
843
|
+
resource = Puppet::Resource.new("blond", "Bambi", :parameters => {
|
844
|
+
:ensure => 'silly',
|
845
|
+
:height => '7 ft 5 in',
|
846
|
+
:friends => ['Oprah'],
|
847
|
+
})
|
848
|
+
|
849
|
+
pruned_resource = resource.prune_parameters
|
850
|
+
pruned_resource.should ==
|
851
|
+
resource = Puppet::Resource.new("blond", "Bambi", :parameters => {
|
852
|
+
:ensure => 'silly',
|
853
|
+
:height => '7 ft 5 in',
|
854
|
+
:friends => ['Oprah'],
|
855
|
+
})
|
856
|
+
end
|
857
|
+
end
|
811
858
|
end
|
@@ -31,13 +31,13 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
31
31
|
end
|
32
32
|
describe "when initializing" do
|
33
33
|
it "should set its method using its settor" do
|
34
|
-
@class.
|
35
|
-
|
34
|
+
instance = @class.new(:generate, :to => :all)
|
35
|
+
instance.method.should == :generate
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should set its subjects using the settor" do
|
39
|
-
@class.
|
40
|
-
|
39
|
+
instance = @class.new(:generate, :to => :all)
|
40
|
+
instance.subjects.should == :all
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should set the digest if given" do
|
@@ -53,23 +53,27 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
53
53
|
|
54
54
|
describe "when setting the method" do
|
55
55
|
it "should set the method" do
|
56
|
-
@class.new(:generate, :to => :all)
|
56
|
+
instance = @class.new(:generate, :to => :all)
|
57
|
+
instance.method = :list
|
58
|
+
|
59
|
+
instance.method.should == :list
|
57
60
|
end
|
58
61
|
|
59
62
|
it "should fail if the method isn't a member of the INTERFACE_METHODS array" do
|
60
|
-
|
61
|
-
|
62
|
-
lambda { @class.new(:thing, :to => :all) }.should raise_error(ArgumentError)
|
63
|
+
lambda { @class.new(:thing, :to => :all) }.should raise_error(ArgumentError, /Invalid method thing to apply/)
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
67
|
describe "when setting the subjects" do
|
67
68
|
it "should set the subjects" do
|
68
|
-
@class.new(:generate, :to => :all)
|
69
|
+
instance = @class.new(:generate, :to => :all)
|
70
|
+
instance.subjects = :signed
|
71
|
+
|
72
|
+
instance.subjects.should == :signed
|
69
73
|
end
|
70
74
|
|
71
|
-
it "should fail if the subjects setting isn't :all or an array"
|
72
|
-
lambda { @class.new(:generate, "other") }.should raise_error(ArgumentError)
|
75
|
+
it "should fail if the subjects setting isn't :all or an array" do
|
76
|
+
lambda { @class.new(:generate, :to => "other") }.should raise_error(ArgumentError, /Subjects must be an array or :all; not other/)
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
@@ -117,8 +121,8 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
117
121
|
it "should call :generate on the CA for each host specified" do
|
118
122
|
@applier = @class.new(:generate, :to => %w{host1 host2})
|
119
123
|
|
120
|
-
@ca.expects(:generate).with("host1")
|
121
|
-
@ca.expects(:generate).with("host2")
|
124
|
+
@ca.expects(:generate).with("host1", {})
|
125
|
+
@ca.expects(:generate).with("host2", {})
|
122
126
|
|
123
127
|
@applier.apply(@ca)
|
124
128
|
end
|
@@ -149,15 +153,24 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
149
153
|
|
150
154
|
describe ":sign" do
|
151
155
|
describe "and an array of names was provided" do
|
152
|
-
|
153
|
-
@applier = @class.new(:sign, :to => %w{host1 host2})
|
154
|
-
end
|
156
|
+
let(:applier) { @class.new(:sign, @options.merge(:to => %w{host1 host2})) }
|
155
157
|
|
156
158
|
it "should sign the specified waiting certificate requests" do
|
157
|
-
@
|
158
|
-
@ca.expects(:sign).with("host2")
|
159
|
+
@options = {:allow_dns_alt_names => false}
|
159
160
|
|
160
|
-
@
|
161
|
+
@ca.expects(:sign).with("host1", false)
|
162
|
+
@ca.expects(:sign).with("host2", false)
|
163
|
+
|
164
|
+
applier.apply(@ca)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should sign the certificate requests with alt names if specified" do
|
168
|
+
@options = {:allow_dns_alt_names => true}
|
169
|
+
|
170
|
+
@ca.expects(:sign).with("host1", true)
|
171
|
+
@ca.expects(:sign).with("host2", true)
|
172
|
+
|
173
|
+
applier.apply(@ca)
|
161
174
|
end
|
162
175
|
end
|
163
176
|
|
@@ -165,8 +178,8 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
165
178
|
it "should sign all waiting certificate requests" do
|
166
179
|
@ca.stubs(:waiting?).returns(%w{cert1 cert2})
|
167
180
|
|
168
|
-
@ca.expects(:sign).with("cert1")
|
169
|
-
@ca.expects(:sign).with("cert2")
|
181
|
+
@ca.expects(:sign).with("cert1", nil)
|
182
|
+
@ca.expects(:sign).with("cert2", nil)
|
170
183
|
|
171
184
|
@applier = @class.new(:sign, :to => :all)
|
172
185
|
@applier.apply(@ca)
|
@@ -182,63 +195,93 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
182
195
|
end
|
183
196
|
|
184
197
|
describe ":list" do
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
@ca.stubs(:verify)
|
198
|
+
before :each do
|
199
|
+
@cert = Puppet::SSL::Certificate.new 'foo'
|
200
|
+
@csr = Puppet::SSL::CertificateRequest.new 'bar'
|
189
201
|
|
190
|
-
|
202
|
+
@cert.stubs(:subject_alt_names).returns []
|
203
|
+
@csr.stubs(:subject_alt_names).returns []
|
191
204
|
|
192
|
-
|
205
|
+
Puppet::SSL::Certificate.indirection.stubs(:find).returns @cert
|
206
|
+
Puppet::SSL::CertificateRequest.indirection.stubs(:find).returns @csr
|
193
207
|
|
194
|
-
|
208
|
+
@ca.expects(:waiting?).returns %w{host1 host2 host3}
|
209
|
+
@ca.expects(:list).returns %w{host4 host5 host6}
|
210
|
+
@ca.stubs(:fingerprint).returns "fingerprint"
|
211
|
+
@ca.stubs(:verify)
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "and an empty array was provided" do
|
215
|
+
it "should print all certificate requests" do
|
216
|
+
applier = @class.new(:list, :to => [])
|
217
|
+
|
218
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
219
|
+
host1 (fingerprint)
|
220
|
+
host2 (fingerprint)
|
221
|
+
host3 (fingerprint)
|
222
|
+
OUTPUT
|
223
|
+
|
224
|
+
applier.apply(@ca)
|
195
225
|
end
|
196
226
|
end
|
197
227
|
|
198
228
|
describe "and :all was provided" do
|
199
229
|
it "should print a string containing all certificate requests and certificates" do
|
200
|
-
@ca.
|
201
|
-
@ca.expects(:list).returns %w{host3 host4}
|
202
|
-
@ca.stubs(:verify)
|
203
|
-
@ca.stubs(:fingerprint).returns "fingerprint"
|
204
|
-
@ca.expects(:verify).with("host3").raises(Puppet::SSL::CertificateAuthority::CertificateVerificationError.new(23), "certificate revoked")
|
230
|
+
@ca.stubs(:verify).with("host4").raises(Puppet::SSL::CertificateAuthority::CertificateVerificationError.new(23), "certificate revoked")
|
205
231
|
|
206
|
-
|
232
|
+
applier = @class.new(:list, :to => :all)
|
207
233
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
234
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
235
|
+
host1 (fingerprint)
|
236
|
+
host2 (fingerprint)
|
237
|
+
host3 (fingerprint)
|
238
|
+
+ host5 (fingerprint)
|
239
|
+
+ host6 (fingerprint)
|
240
|
+
- host4 (fingerprint) (certificate revoked)
|
241
|
+
OUTPUT
|
212
242
|
|
213
|
-
|
243
|
+
applier.apply(@ca)
|
214
244
|
end
|
215
245
|
end
|
216
246
|
|
217
247
|
describe "and :signed was provided" do
|
218
248
|
it "should print a string containing all signed certificate requests and certificates" do
|
219
|
-
@
|
249
|
+
applier = @class.new(:list, :to => :signed)
|
220
250
|
|
221
|
-
|
251
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
252
|
+
+ host4 (fingerprint)
|
253
|
+
+ host5 (fingerprint)
|
254
|
+
+ host6 (fingerprint)
|
255
|
+
OUTPUT
|
222
256
|
|
223
|
-
|
257
|
+
applier.apply(@ca)
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should include subject alt names if they are on the certificate request" do
|
261
|
+
@csr.stubs(:subject_alt_names).returns ["DNS:foo", "DNS:bar"]
|
262
|
+
|
263
|
+
applier = @class.new(:list, :to => ['host1'])
|
264
|
+
|
265
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
266
|
+
host1 (fingerprint) (alt names: DNS:foo, DNS:bar)
|
267
|
+
OUTPUT
|
268
|
+
|
269
|
+
applier.apply(@ca)
|
224
270
|
end
|
225
271
|
end
|
226
272
|
|
227
273
|
describe "and an array of names was provided" do
|
228
|
-
it "should print
|
229
|
-
@
|
230
|
-
@ca.expects(:list).returns %w{host3 host4}
|
231
|
-
@ca.stubs(:fingerprint).returns "fingerprint"
|
232
|
-
@ca.stubs(:verify)
|
233
|
-
|
234
|
-
@applier = @class.new(:list, :to => %w{host1 host2 host3 host4})
|
274
|
+
it "should print all named hosts" do
|
275
|
+
applier = @class.new(:list, :to => %w{host1 host2 host4 host5})
|
235
276
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
277
|
+
applier.expects(:puts).with(<<-OUTPUT.chomp)
|
278
|
+
host1 (fingerprint)
|
279
|
+
host2 (fingerprint)
|
280
|
+
+ host4 (fingerprint)
|
281
|
+
+ host5 (fingerprint)
|
282
|
+
OUTPUT
|
240
283
|
|
241
|
-
|
284
|
+
applier.apply(@ca)
|
242
285
|
end
|
243
286
|
end
|
244
287
|
end
|