puppet 5.5.6-x64-mingw32 → 5.5.7-x64-mingw32
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.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +12 -12
- data/Rakefile +9 -0
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/application/apply.rb +1 -0
- data/lib/puppet/application/master.rb +9 -7
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/defaults.rb +51 -31
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions.rb +123 -0
- data/lib/puppet/functions/new.rb +37 -53
- data/lib/puppet/functions/warning.rb +1 -1
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/parser/functions.rb +3 -1
- data/lib/puppet/parser/functions/sprintf.rb +12 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +16 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
- data/lib/puppet/pops/issues.rb +8 -0
- data/lib/puppet/pops/loader/loader.rb +2 -2
- data/lib/puppet/pops/loader/loader_paths.rb +3 -1
- data/lib/puppet/pops/loader/module_loaders.rb +1 -1
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
- data/lib/puppet/pops/loaders.rb +5 -21
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +31 -6
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/property/keyvalue.rb +70 -8
- data/lib/puppet/provider/aix_object.rb +483 -0
- data/lib/puppet/provider/exec.rb +54 -57
- data/lib/puppet/provider/group/aix.rb +40 -115
- data/lib/puppet/provider/group/pw.rb +4 -8
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -3
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +3 -10
- data/lib/puppet/provider/package/zypper.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/windows.rb +49 -40
- data/lib/puppet/provider/user/aix.rb +180 -246
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/exec.rb +16 -14
- data/lib/puppet/type/file.rb +2 -2
- data/lib/puppet/type/file/source.rb +9 -5
- data/lib/puppet/type/group.rb +65 -23
- data/lib/puppet/type/k5login.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +3 -6
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +8 -1
- data/lib/puppet/type/selboolean.rb +2 -2
- data/lib/puppet/type/selmodule.rb +3 -4
- data/lib/puppet/type/service.rb +2 -5
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +15 -20
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zone.rb +2 -2
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows.rb +4 -2
- data/lib/puppet/util/windows/adsi.rb +235 -205
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +977 -0
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/version.rb +1 -1
- data/locales/ja/puppet.po +705 -374
- data/locales/puppet.pot +485 -261
- data/man/man5/puppet.conf.5 +36 -15
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out +1 -0
- data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out +1 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +32 -0
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/adsi_spec.rb +6 -5
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/apply_spec.rb +41 -2
- data/spec/unit/application/master_spec.rb +7 -0
- data/spec/unit/application_spec.rb +21 -3
- data/spec/unit/defaults_spec.rb +20 -0
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/gettext/config_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +6 -6
- data/spec/unit/pops/loaders/loaders_spec.rb +40 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/validator/validator_spec.rb +129 -10
- data/spec/unit/property/keyvalue_spec.rb +97 -6
- data/spec/unit/provider/aix_object_spec.rb +805 -0
- data/spec/unit/provider/group/aix_spec.rb +57 -0
- data/spec/unit/provider/group/pw_spec.rb +0 -6
- data/spec/unit/provider/group/windows_adsi_spec.rb +34 -35
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -2
- data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- data/spec/unit/provider/service/launchd_spec.rb +19 -0
- data/spec/unit/provider/service/windows_spec.rb +71 -78
- data/spec/unit/provider/user/aix_spec.rb +162 -116
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/ssl/certificate_authority_spec.rb +0 -1
- data/spec/unit/type/group_spec.rb +111 -13
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/windows/adsi_spec.rb +108 -13
- data/spec/unit/util/windows/service_spec.rb +669 -0
- metadata +17 -5
- data/lib/puppet/provider/aixobject.rb +0 -392
- data/spec/unit/provider/aixobject_spec.rb +0 -101
@@ -1,169 +1,215 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let(:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
describe 'Puppet::Type::User::Provider::Aix' do
|
4
|
+
let(:provider_class) { Puppet::Type.type(:user).provider(:aix) }
|
5
|
+
let(:group_provider_class) { Puppet::Type.type(:group).provider(:aix) }
|
6
|
+
|
7
|
+
let(:resource) do
|
8
|
+
Puppet::Type.type(:user).new(
|
9
|
+
:name => 'test_aix_user',
|
10
|
+
:ensure => :present
|
11
|
+
)
|
12
12
|
end
|
13
|
-
|
14
|
-
|
15
|
-
<<-OUTPUT
|
16
|
-
root id=0 pgrp=system groups=system,bin,sys,security,cron,audit,lp home=/root shell=/usr/bin/bash
|
17
|
-
guest id=100 pgrp=usr groups=usr home=/home/guest
|
18
|
-
OUTPUT
|
13
|
+
let(:provider) do
|
14
|
+
provider_class.new(resource)
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
describe '.pgrp_to_gid' do
|
18
|
+
it "finds the primary group's gid" do
|
19
|
+
provider.stubs(:ia_module_args).returns(['-R', 'module'])
|
20
|
+
|
21
|
+
group_provider_class.expects(:list_all)
|
22
|
+
.with(provider.ia_module_args)
|
23
|
+
.returns([{ :name => 'group', :id => 1}])
|
24
|
+
|
25
|
+
expect(provider_class.pgrp_to_gid(provider, 'group')).to eql(1)
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
describe '.gid_to_pgrp' do
|
30
|
+
it "finds the gid's primary group" do
|
31
|
+
provider.stubs(:ia_module_args).returns(['-R', 'module'])
|
28
32
|
|
29
|
-
|
33
|
+
group_provider_class.expects(:list_all)
|
34
|
+
.with(provider.ia_module_args)
|
35
|
+
.returns([{ :name => 'group', :id => 1}])
|
30
36
|
|
31
|
-
|
37
|
+
expect(provider_class.gid_to_pgrp(provider, 1)).to eql('group')
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
describe '.expires_to_expiry' do
|
42
|
+
it 'returns absent if expires is 0' do
|
43
|
+
expect(provider_class.expires_to_expiry(provider, '0')).to eql(:absent)
|
44
|
+
end
|
36
45
|
|
37
|
-
|
46
|
+
it 'returns absent if the expiry attribute is not formatted properly' do
|
47
|
+
expect(provider_class.expires_to_expiry(provider, 'bad_format')).to eql(:absent)
|
48
|
+
end
|
38
49
|
|
39
|
-
|
50
|
+
it 'returns the password expiration date' do
|
51
|
+
expect(provider_class.expires_to_expiry(provider, '0910122314')).to eql('2014-09-10')
|
52
|
+
end
|
40
53
|
end
|
41
54
|
|
42
|
-
describe
|
43
|
-
|
44
|
-
|
45
|
-
:admin => 'false',
|
46
|
-
:login => 'true',
|
47
|
-
'su' => 'true'
|
48
|
-
}
|
55
|
+
describe '.expiry_to_expires' do
|
56
|
+
it 'returns 0 if the expiry date is 0000-00-00' do
|
57
|
+
expect(provider_class.expiry_to_expires('0000-00-00')).to eql('0')
|
49
58
|
end
|
50
59
|
|
51
|
-
|
52
|
-
|
53
|
-
@resource.stubs(:original_parameters).returns(original_parameters)
|
60
|
+
it 'returns 0 if the expiry date is "absent"' do
|
61
|
+
expect(provider_class.expiry_to_expires('absent')).to eql('0')
|
54
62
|
end
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
64
|
+
it 'returns 0 if the expiry date is :absent' do
|
65
|
+
expect(provider_class.expiry_to_expires(:absent)).to eql('0')
|
66
|
+
end
|
59
67
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
expect(keys).not_to be_include(:su)
|
65
|
-
end
|
68
|
+
it 'returns the expires attribute value' do
|
69
|
+
expect(provider_class.expiry_to_expires('2014-09-10')).to eql('0910000014')
|
70
|
+
end
|
71
|
+
end
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
73
|
+
describe '.groups_attribute_to_property' do
|
74
|
+
it "reads the user's groups from the etc/groups file" do
|
75
|
+
groups = ['system', 'adm']
|
76
|
+
Puppet::Util::POSIX.stubs(:groups_of).with(resource[:name]).returns(groups)
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
expect(keys.size).to eq(attribute_array.size)
|
76
|
-
end
|
78
|
+
actual_groups = provider_class.groups_attribute_to_property(provider, 'unused_value')
|
79
|
+
expected_groups = groups.join(',')
|
77
80
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
expect(all_symbols).to be_truthy
|
82
|
-
end
|
81
|
+
expect(actual_groups).to eql(expected_groups)
|
82
|
+
end
|
83
|
+
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
describe '.groups_property_to_attribute' do
|
86
|
+
it 'raises an ArgumentError if the groups are space-separated' do
|
87
|
+
groups = "foo bar baz"
|
88
|
+
expect do
|
89
|
+
provider_class.groups_property_to_attribute(groups)
|
90
|
+
end.to raise_error do |error|
|
91
|
+
expect(error).to be_a(ArgumentError)
|
92
|
+
|
93
|
+
expect(error.message).to match(groups)
|
94
|
+
expect(error.message).to match("Groups")
|
88
95
|
end
|
89
96
|
end
|
97
|
+
end
|
90
98
|
|
91
|
-
|
92
|
-
|
99
|
+
describe '#gid=' do
|
100
|
+
let(:value) { 'new_pgrp' }
|
93
101
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
let(:old_pgrp) { 'old_pgrp' }
|
103
|
+
let(:cur_groups) { 'system,adm' }
|
104
|
+
before(:each) do
|
105
|
+
provider.stubs(:gid).returns(old_pgrp)
|
106
|
+
provider.stubs(:groups).returns(cur_groups)
|
107
|
+
provider.stubs(:set)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'raises a Puppet::Error if it fails to set the groups property' do
|
111
|
+
provider.stubs(:set)
|
112
|
+
.with(:groups, cur_groups)
|
113
|
+
.raises(Puppet::ExecutionFailure, 'failed to reset the groups!')
|
100
114
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(
|
115
|
+
expect { provider.gid = value }.to raise_error do |error|
|
116
|
+
expect(error).to be_a(Puppet::Error)
|
117
|
+
|
118
|
+
expect(error.message).to match('groups')
|
119
|
+
expect(error.message).to match(cur_groups)
|
120
|
+
expect(error.message).to match(old_pgrp)
|
121
|
+
expect(error.message).to match(value)
|
105
122
|
end
|
106
123
|
end
|
107
124
|
end
|
108
125
|
|
109
|
-
describe
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
expect(@provider.should_include?(:rlogin, managed_keys)).to be_falsey
|
126
|
+
describe '#parse_password' do
|
127
|
+
def call_parse_password
|
128
|
+
File.open(my_fixture('aix_passwd_file.out')) do |f|
|
129
|
+
provider.parse_password(f)
|
130
|
+
end
|
115
131
|
end
|
116
132
|
|
117
|
-
it "
|
118
|
-
|
119
|
-
|
120
|
-
@provider.class.stubs(:attribute_ignore).returns([:rlogin])
|
121
|
-
expect(@provider.should_include?(:rlogin, managed_keys)).to be_falsey
|
133
|
+
it "returns :absent if the user stanza doesn't exist" do
|
134
|
+
resource[:name] = 'nonexistent_user'
|
135
|
+
expect(call_parse_password).to eql(:absent)
|
122
136
|
end
|
123
137
|
|
124
|
-
it "
|
125
|
-
|
126
|
-
|
127
|
-
@provider.class.stubs(:attribute_ignore).returns([])
|
128
|
-
expect(@provider.should_include?(:rlogin, managed_keys)).to be_falsey
|
138
|
+
it "returns absent if the user does not have a password" do
|
139
|
+
resource[:name] = 'no_password_user'
|
140
|
+
expect(call_parse_password).to eql(:absent)
|
129
141
|
end
|
130
142
|
|
131
|
-
it "
|
132
|
-
|
133
|
-
@provider.class.attribute_mapping_from.stubs(:include?).with(:rlogin).returns(false)
|
134
|
-
@provider.class.stubs(:attribute_ignore).returns([])
|
135
|
-
expect(@provider.should_include?(:rlogin, managed_keys)).to be_truthy
|
143
|
+
it "returns the user's password" do
|
144
|
+
expect(call_parse_password).to eql('some_password')
|
136
145
|
end
|
137
146
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
+
|
148
|
+
# TODO: If we move from using Mocha to rspec's mocks,
|
149
|
+
# or a better and more robust mocking library, we should
|
150
|
+
# remove #parse_password and copy over its tests to here.
|
151
|
+
describe '#password' do
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#password=' do
|
155
|
+
let(:mock_tempfile) do
|
156
|
+
mock_tempfile_obj = mock()
|
157
|
+
mock_tempfile_obj.stubs(:<<)
|
158
|
+
mock_tempfile_obj.stubs(:close)
|
159
|
+
mock_tempfile_obj.stubs(:delete)
|
160
|
+
mock_tempfile_obj.stubs(:path).returns('tempfile_path')
|
161
|
+
|
162
|
+
Tempfile.stubs(:new)
|
163
|
+
.with("puppet_#{provider.name}_pw", :encoding => Encoding::ASCII)
|
164
|
+
.returns(mock_tempfile_obj)
|
165
|
+
|
166
|
+
mock_tempfile_obj
|
167
|
+
end
|
168
|
+
let(:cmd) do
|
169
|
+
[provider.class.command(:chpasswd), *provider.ia_module_args, '-e', '-c']
|
170
|
+
end
|
171
|
+
let(:execute_options) do
|
172
|
+
{
|
173
|
+
:failonfail => false,
|
174
|
+
:combine => true,
|
175
|
+
:stdinfile => mock_tempfile.path
|
176
|
+
}
|
147
177
|
end
|
148
178
|
|
149
|
-
|
150
|
-
|
151
|
-
|
179
|
+
it 'raises a Puppet::Error if chpasswd fails' do
|
180
|
+
provider.stubs(:execute).with(cmd, execute_options).returns("failed to change passwd!")
|
181
|
+
expect { provider.password = 'foo' }.to raise_error do |error|
|
182
|
+
expect(error).to be_a(Puppet::Error)
|
183
|
+
expect(error.message).to match("failed to change passwd!")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
it "changes the user's password" do
|
188
|
+
provider.expects(:execute).with(cmd, execute_options).returns("")
|
189
|
+
provider.password = 'foo'
|
152
190
|
end
|
153
191
|
|
192
|
+
it "closes and deletes the tempfile" do
|
193
|
+
provider.stubs(:execute).with(cmd, execute_options).returns("")
|
154
194
|
|
155
|
-
|
156
|
-
|
157
|
-
@resource.stubs(:[]).returns('smith')
|
195
|
+
mock_tempfile.expects(:close).times(2)
|
196
|
+
mock_tempfile.expects(:delete)
|
158
197
|
|
159
|
-
|
198
|
+
provider.password = 'foo'
|
160
199
|
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe '#create' do
|
203
|
+
it 'should create the user' do
|
204
|
+
provider.resource.stubs(:should).with(anything).returns(nil)
|
205
|
+
provider.resource.stubs(:should).with(:groups).returns('g1,g2')
|
206
|
+
provider.resource.stubs(:should).with(:password).returns('password')
|
161
207
|
|
162
|
-
|
163
|
-
|
164
|
-
|
208
|
+
provider.expects(:execute)
|
209
|
+
provider.expects(:groups=).with('g1,g2')
|
210
|
+
provider.expects(:password=).with('password')
|
165
211
|
|
166
|
-
|
212
|
+
provider.create
|
167
213
|
end
|
168
214
|
end
|
169
215
|
end
|
@@ -218,6 +218,9 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "should set a user's password" do
|
221
|
+
provider.user.expects(:disabled?).returns(false)
|
222
|
+
provider.user.expects(:locked_out?).returns(false)
|
223
|
+
provider.user.expects(:expired?).returns(false)
|
221
224
|
provider.user.expects(:password=).with('plaintextbad')
|
222
225
|
|
223
226
|
provider.password = "plaintextbad"
|
@@ -259,10 +262,7 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
|
|
259
262
|
connection.expects(:Put).with('UserFlags', true)
|
260
263
|
connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
|
261
264
|
|
262
|
-
expect{ provider.create }.to raise_error(
|
263
|
-
Puppet::Error,
|
264
|
-
/not able to create\/delete domain users/
|
265
|
-
)
|
265
|
+
expect{ provider.create }.to raise_error(Puppet::Error)
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
@@ -48,8 +48,8 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
48
48
|
catalog.add_resource(res, res2, res3, res4, comp_res)
|
49
49
|
catalog.write_resource_file
|
50
50
|
expect(File.readlines(resourcefile).map(&:chomp)).to match_array([
|
51
|
-
"file[#{
|
52
|
-
"exec[#{
|
51
|
+
"file[#{res.title.downcase}]",
|
52
|
+
"exec[#{res2.title.downcase}]"
|
53
53
|
])
|
54
54
|
end
|
55
55
|
|
@@ -943,7 +943,6 @@ describe Puppet::SSL::CertificateAuthority do
|
|
943
943
|
end
|
944
944
|
|
945
945
|
it "should be deprecated" do
|
946
|
-
Puppet.expects(:deprecation_warning).with(regexp_matches(/Accessing 'cacert' as a setting is deprecated/))
|
947
946
|
Puppet.expects(:deprecation_warning).with(regexp_matches(/certificate_is_alive\? is deprecated/))
|
948
947
|
@ca.certificate_is_alive?(@cert)
|
949
948
|
end
|
@@ -2,8 +2,21 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Puppet::Type.type(:group) do
|
5
|
-
|
5
|
+
let(:mock_group_provider) do
|
6
|
+
described_class.provide(:mock_group_provider) do
|
7
|
+
has_features :manages_members
|
8
|
+
mk_resource_methods
|
9
|
+
def create; end
|
10
|
+
def delete; end
|
11
|
+
def exists?; get(:ensure) != :absent; end
|
12
|
+
def flush; end
|
13
|
+
def self.instances; []; end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
6
18
|
@class = Puppet::Type.type(:group)
|
19
|
+
described_class.stubs(:defaultprovider).returns mock_group_provider
|
7
20
|
end
|
8
21
|
|
9
22
|
it "should have a system_groups feature" do
|
@@ -70,23 +83,108 @@ describe Puppet::Type.type(:group) do
|
|
70
83
|
expect(type.exists?).to eq(true)
|
71
84
|
end
|
72
85
|
|
73
|
-
describe "
|
86
|
+
describe "when managing members" do
|
87
|
+
def stub_property(resource_hash)
|
88
|
+
described_class.new(resource_hash).property(:members)
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "validation" do
|
92
|
+
it "raises an error for a non-String value" do
|
93
|
+
expect {
|
94
|
+
described_class.new(:name => 'foo', :members => true)
|
95
|
+
}.to raise_error(Puppet::Error)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "raises an error for an array value containing a non-String element" do
|
99
|
+
expect {
|
100
|
+
described_class.new(:name => 'foo', :members => [ true, 'foo' ])
|
101
|
+
}.to raise_error(Puppet::Error)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "raises an error when the members are specified as UIDs instead of usernames" do
|
105
|
+
expect {
|
106
|
+
described_class.new(:name => 'foo', :members => [ '123', '456' ])
|
107
|
+
}.to raise_error(Puppet::Error)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "raises an error when an empty string is passed for a member's username" do
|
111
|
+
expect {
|
112
|
+
described_class.new(:name => 'foo', :members => [ 'foo', '' ])
|
113
|
+
}.to raise_error(Puppet::Error)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "passes for a single member" do
|
117
|
+
expect {
|
118
|
+
described_class.new(:name => 'foo', :members => 'foo')
|
119
|
+
}.to_not raise_error
|
120
|
+
end
|
121
|
+
|
122
|
+
it "passes for a member whose username has a number" do
|
123
|
+
expect {
|
124
|
+
described_class.new(:name => 'foo', :members => 'foo123')
|
125
|
+
}.to_not raise_error
|
126
|
+
end
|
127
|
+
|
128
|
+
it "passes for an array of members" do
|
129
|
+
expect {
|
130
|
+
described_class.new(:name => 'foo', :members => [ 'foo', 'bar' ])
|
131
|
+
}.to_not raise_error
|
132
|
+
end
|
74
133
|
|
75
|
-
|
76
|
-
|
77
|
-
|
134
|
+
it "passes for a comma-separated list of members" do
|
135
|
+
expect {
|
136
|
+
described_class.new(:name => 'foo', :members => 'foo,bar')
|
137
|
+
}.to_not raise_error
|
138
|
+
end
|
139
|
+
end
|
78
140
|
|
79
|
-
|
80
|
-
|
81
|
-
|
141
|
+
describe "#inclusive?" do
|
142
|
+
it "returns false when auth_membership == false" do
|
143
|
+
members_property = stub_property(
|
144
|
+
:name => 'foo',
|
145
|
+
:auth_membership => false,
|
146
|
+
:members => []
|
147
|
+
)
|
148
|
+
|
149
|
+
expect(members_property.inclusive?).to be false
|
150
|
+
end
|
151
|
+
|
152
|
+
it "returns true when auth_membership == true" do
|
153
|
+
members_property = stub_property(
|
154
|
+
:name => 'foo',
|
155
|
+
:auth_membership => true,
|
156
|
+
:members => []
|
157
|
+
)
|
158
|
+
|
159
|
+
expect(members_property.inclusive?).to be true
|
160
|
+
end
|
82
161
|
end
|
83
162
|
|
84
|
-
|
85
|
-
|
86
|
-
|
163
|
+
describe "#should= munging the @should instance variable" do
|
164
|
+
def should_var_of(property)
|
165
|
+
property.instance_variable_get(:@should)
|
166
|
+
end
|
87
167
|
|
88
|
-
|
89
|
-
|
168
|
+
it "leaves a single member as-is" do
|
169
|
+
members_property = stub_property(:name => 'foo', :members => [])
|
170
|
+
members_property.should = 'foo'
|
171
|
+
|
172
|
+
expect(should_var_of(members_property)).to eql([ 'foo' ])
|
173
|
+
end
|
174
|
+
|
175
|
+
it "leaves an array of members as-is" do
|
176
|
+
members_property = stub_property(:name => 'foo', :members => [])
|
177
|
+
members_property.should = [ 'foo', 'bar' ]
|
178
|
+
|
179
|
+
expect(should_var_of(members_property)).to eql(['foo', 'bar'])
|
180
|
+
end
|
181
|
+
|
182
|
+
it "munges a comma-separated list of members into an array" do
|
183
|
+
members_property = stub_property(:name => 'foo', :members => [])
|
184
|
+
members_property.should = 'foo,bar'
|
185
|
+
|
186
|
+
expect(should_var_of(members_property)).to eql(['foo', 'bar'])
|
187
|
+
end
|
90
188
|
end
|
91
189
|
end
|
92
190
|
end
|