puppet 7.10.0-universal-darwin → 7.11.0-universal-darwin
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 +2 -2
- data/Gemfile.lock +9 -9
- data/lib/puppet/application/agent.rb +4 -0
- data/lib/puppet/application/apply.rb +20 -2
- data/lib/puppet/application/resource.rb +15 -13
- data/lib/puppet/concurrent/thread_local_singleton.rb +1 -0
- data/lib/puppet/configurer.rb +14 -4
- data/lib/puppet/confine/variable.rb +1 -1
- data/lib/puppet/defaults.rb +9 -3
- data/lib/puppet/facter_impl.rb +96 -0
- data/lib/puppet/file_serving/mount/file.rb +4 -4
- data/lib/puppet/file_system/file_impl.rb +3 -1
- data/lib/puppet/forge.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +3 -3
- data/lib/puppet/indirector/facts/facter.rb +6 -6
- data/lib/puppet/indirector/indirection.rb +1 -1
- data/lib/puppet/module_tool/applications/uninstaller.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +1 -1
- data/lib/puppet/pal/pal_impl.rb +1 -1
- data/lib/puppet/parser/scope.rb +8 -7
- data/lib/puppet/parser/templatewrapper.rb +1 -0
- data/lib/puppet/pops/lookup/lookup_adapter.rb +3 -2
- data/lib/puppet/pops/model/ast.rb +1 -0
- data/lib/puppet/pops/model/factory.rb +14 -13
- data/lib/puppet/pops/parser/egrammar.ra +2 -2
- data/lib/puppet/pops/parser/eparser.rb +752 -753
- data/lib/puppet/pops/parser/lexer2.rb +69 -68
- data/lib/puppet/pops/parser/slurp_support.rb +1 -0
- data/lib/puppet/pops/serialization/to_stringified_converter.rb +1 -1
- data/lib/puppet/pops/types/type_formatter.rb +7 -6
- data/lib/puppet/pops/types/types.rb +1 -1
- data/lib/puppet/provider/aix_object.rb +1 -1
- data/lib/puppet/provider/group/groupadd.rb +5 -2
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/lib/puppet/provider/package/puppetserver_gem.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/init.rb +5 -5
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +3 -3
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +5 -5
- data/lib/puppet/provider/user/aix.rb +44 -1
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +10 -7
- data/lib/puppet/provider.rb +1 -1
- data/lib/puppet/reference/providers.rb +2 -2
- data/lib/puppet/resource/type_collection.rb +2 -1
- data/lib/puppet/runtime.rb +11 -1
- data/lib/puppet/settings/file_setting.rb +3 -8
- data/lib/puppet/settings.rb +2 -2
- data/lib/puppet/test/test_helper.rb +4 -1
- data/lib/puppet/type/exec.rb +9 -1
- data/lib/puppet/type/group.rb +0 -1
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/user.rb +0 -1
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/filetype.rb +2 -2
- data/lib/puppet/util/log.rb +1 -2
- data/lib/puppet/util/logging.rb +1 -25
- data/lib/puppet/util/pidlock.rb +1 -1
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +1 -2
- data/lib/puppet/util/tagging.rb +1 -0
- data/lib/puppet/util/windows/user.rb +0 -1
- data/lib/puppet/util.rb +4 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +2 -6
- data/man/man5/puppet.conf.5 +10 -2
- data/man/man8/puppet-agent.8 +4 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.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-lookup.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-ssl.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/integration/application/agent_spec.rb +16 -0
- data/spec/integration/configurer_spec.rb +1 -1
- data/spec/integration/indirector/facts/facter_spec.rb +3 -3
- data/spec/integration/transaction/report_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +2 -2
- data/spec/integration/type/package_spec.rb +6 -6
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/integration/util/windows/process_spec.rb +1 -9
- data/spec/unit/application/apply_spec.rb +76 -56
- data/spec/unit/application/resource_spec.rb +29 -0
- data/spec/unit/configurer_spec.rb +13 -3
- data/spec/unit/facter_impl_spec.rb +31 -0
- data/spec/unit/file_bucket/dipper_spec.rb +2 -2
- data/spec/unit/file_system_spec.rb +7 -0
- data/spec/unit/functions/lookup_spec.rb +64 -0
- data/spec/unit/indirector/indirection_spec.rb +10 -3
- data/spec/unit/pops/serialization/to_stringified_spec.rb +5 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +6 -0
- data/spec/unit/provider/package/gem_spec.rb +1 -1
- data/spec/unit/provider/package/pip2_spec.rb +1 -1
- data/spec/unit/provider/package/pip3_spec.rb +1 -1
- data/spec/unit/provider/package/pip_spec.rb +1 -1
- data/spec/unit/provider/package/puppet_gem_spec.rb +1 -1
- data/spec/unit/provider/package/puppetserver_gem_spec.rb +1 -1
- data/spec/unit/provider/user/aix_spec.rb +100 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
- data/spec/unit/provider_spec.rb +4 -4
- data/spec/unit/puppet_spec.rb +12 -4
- data/spec/unit/settings/file_setting_spec.rb +10 -7
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/logging_spec.rb +2 -0
- data/tasks/parallel.rake +3 -3
- metadata +5 -2
@@ -129,6 +129,35 @@ describe Puppet::Application::Resource do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
describe "when printing output" do
|
132
|
+
it "should not emit puppet class tags when printing yaml" do
|
133
|
+
Puppet::Type.newtype(:stringify) do
|
134
|
+
ensurable
|
135
|
+
newparam(:name, isnamevar: true)
|
136
|
+
newproperty(:string)
|
137
|
+
end
|
138
|
+
|
139
|
+
Puppet::Type.type(:stringify).provide(:stringify) do
|
140
|
+
def exists?
|
141
|
+
true
|
142
|
+
end
|
143
|
+
|
144
|
+
def string
|
145
|
+
Puppet::Util::Execution::ProcessOutput.new('test', 0)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
@resource_app.options[:to_yaml] = true
|
150
|
+
allow(@resource_app.command_line).to receive(:args).and_return(['stringify', 'hello', 'ensure=present', 'string=asd'])
|
151
|
+
expect(@resource_app).to receive(:puts).with(<<~YAML)
|
152
|
+
---
|
153
|
+
stringify:
|
154
|
+
hello:
|
155
|
+
ensure: present
|
156
|
+
string: test
|
157
|
+
YAML
|
158
|
+
expect { @resource_app.main }.not_to raise_error
|
159
|
+
end
|
160
|
+
|
132
161
|
it "should ensure all values to be printed are in the external encoding" do
|
133
162
|
resources = [
|
134
163
|
Puppet::Type.type(:user).new(:name => "\u2603".force_encoding(Encoding::UTF_8)).to_resource,
|
@@ -191,7 +191,7 @@ describe Puppet::Configurer do
|
|
191
191
|
}
|
192
192
|
Puppet::Node::Facts.indirection.save(facts)
|
193
193
|
|
194
|
-
expect(Puppet).to receive(:warning).with(/Payload with the current size of: '
|
194
|
+
expect(Puppet).to receive(:warning).with(/Payload with the current size of: '\d*' exceeds the payload size limit: \d*/)
|
195
195
|
configurer.run
|
196
196
|
end
|
197
197
|
|
@@ -583,7 +583,7 @@ describe Puppet::Configurer do
|
|
583
583
|
it "should save the report if reporting is enabled" do
|
584
584
|
Puppet.settings[:report] = true
|
585
585
|
|
586
|
-
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, instance_of(Hash))
|
586
|
+
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, instance_of(Hash)).twice
|
587
587
|
configurer.send_report(report)
|
588
588
|
end
|
589
589
|
|
@@ -611,12 +611,22 @@ describe Puppet::Configurer do
|
|
611
611
|
it "should log but not fail if saving the report fails" do
|
612
612
|
Puppet.settings[:report] = true
|
613
613
|
|
614
|
-
expect(Puppet::Transaction::Report.indirection).to receive(:save).and_raise("whatever")
|
614
|
+
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, hash_including(ignore_cache: true)).and_raise("whatever")
|
615
|
+
expect(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, hash_including(ignore_terminus: true))
|
615
616
|
|
616
617
|
configurer.send_report(report)
|
617
618
|
|
618
619
|
expect(@logs).to include(an_object_having_attributes(level: :err, message: 'Could not send report: whatever'))
|
619
620
|
end
|
621
|
+
|
622
|
+
it "should save the cached report if fails to send the report" do
|
623
|
+
allow(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, hash_including(ignore_terminus: true)).and_call_original
|
624
|
+
allow(Puppet::Transaction::Report.indirection).to receive(:save).with(report, nil, hash_including(ignore_cache: true)).and_raise("whatever")
|
625
|
+
|
626
|
+
expect(File).to_not be_exist(Puppet[:lastrunfile])
|
627
|
+
configurer.send_report(report)
|
628
|
+
expect(File.read(Puppet[:lastrunfile])).to match(/puppet: #{Puppet::PUPPETVERSION}/)
|
629
|
+
end
|
620
630
|
end
|
621
631
|
|
622
632
|
describe "when saving the summary report file" do
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Puppet::FacterImpl' do
|
4
|
+
subject(:facter_impl) { Puppet::FacterImpl.new }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to(:value) }
|
7
|
+
it { is_expected.to respond_to(:add) }
|
8
|
+
|
9
|
+
describe '.value' do
|
10
|
+
let(:method_name) { :value }
|
11
|
+
|
12
|
+
before { allow(Facter).to receive(method_name) }
|
13
|
+
|
14
|
+
it 'delegates to Facter API' do
|
15
|
+
facter_impl.value('test_fact')
|
16
|
+
expect(Facter).to have_received(method_name).with('test_fact')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.add' do
|
21
|
+
let(:block) { Proc.new { setcode 'test' } }
|
22
|
+
let(:method_name) { :add }
|
23
|
+
|
24
|
+
before { allow(Facter).to receive(method_name) }
|
25
|
+
|
26
|
+
it 'delegates to Facter API' do
|
27
|
+
facter_impl.add('test_fact', &block)
|
28
|
+
expect(Facter).to have_received(method_name).with('test_fact', &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -104,8 +104,8 @@ describe Puppet::FileBucket::Dipper, :uses_checksums => true do
|
|
104
104
|
# Diff without the context
|
105
105
|
# Lines we need to see match 'Content' instead of trimming diff output filter out
|
106
106
|
# surrounding noise...or hard code the check values
|
107
|
-
if
|
108
|
-
Puppet::Util::Package.versioncmp(
|
107
|
+
if Puppet.runtime[:facter].value(:osfamily) == 'Solaris' &&
|
108
|
+
Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.0') >= 0
|
109
109
|
# Use gdiff on Solaris
|
110
110
|
diff12 = Puppet::Util::Execution.execute("gdiff -uN #{file1} #{file2}| grep Content")
|
111
111
|
diff21 = Puppet::Util::Execution.execute("gdiff -uN #{file2} #{file1}| grep Content")
|
@@ -296,6 +296,13 @@ describe "Puppet::FileSystem" do
|
|
296
296
|
expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \n")
|
297
297
|
end
|
298
298
|
end
|
299
|
+
|
300
|
+
it "should not warn about misusage of BOM with non-UTF encoding" do
|
301
|
+
allow(Encoding).to receive(:default_external).and_return(Encoding::US_ASCII)
|
302
|
+
with_file_content("file content \n") do |file|
|
303
|
+
expect{ Puppet::FileSystem.read_preserve_line_endings(file) }.not_to output(/BOM with non-UTF encoding US-ASCII is nonsense/).to_stderr
|
304
|
+
end
|
305
|
+
end
|
299
306
|
end
|
300
307
|
|
301
308
|
context "read without an encoding specified" do
|
@@ -870,6 +870,46 @@ describe "The lookup function" do
|
|
870
870
|
end
|
871
871
|
end
|
872
872
|
|
873
|
+
context 'with lookup_options' do
|
874
|
+
let(:environment_files) do
|
875
|
+
{
|
876
|
+
env_name => {
|
877
|
+
'hiera.yaml' => <<-YAML.unindent,
|
878
|
+
---
|
879
|
+
version: 5
|
880
|
+
YAML
|
881
|
+
'data' => {
|
882
|
+
'common.yaml' => common_yaml
|
883
|
+
}
|
884
|
+
}
|
885
|
+
}
|
886
|
+
end
|
887
|
+
|
888
|
+
context 'that are empty' do
|
889
|
+
let(:common_yaml) { <<-YAML.unindent }
|
890
|
+
lookup_options:
|
891
|
+
a: b
|
892
|
+
YAML
|
893
|
+
|
894
|
+
it 'ignores empty options' do
|
895
|
+
expect(lookup('a')).to eq("b")
|
896
|
+
end
|
897
|
+
end
|
898
|
+
|
899
|
+
context 'that contains a legal yaml hash with unexpected types' do
|
900
|
+
let(:common_yaml) { <<-YAML.unindent }
|
901
|
+
lookup_options:
|
902
|
+
:invalid_symbol
|
903
|
+
YAML
|
904
|
+
|
905
|
+
it 'fails lookup and reports a type mismatch' do
|
906
|
+
expect {
|
907
|
+
lookup('a')
|
908
|
+
}.to raise_error(Puppet::DataBinding::LookupError, /has wrong type, expects Puppet::LookupValue, got Runtime\[ruby, 'Symbol'\]/)
|
909
|
+
end
|
910
|
+
end
|
911
|
+
end
|
912
|
+
|
873
913
|
context 'with lookup_options configured using patterns' do
|
874
914
|
let(:mod_common) {
|
875
915
|
<<-YAML.unindent
|
@@ -1019,6 +1059,30 @@ describe "The lookup function" do
|
|
1019
1059
|
})
|
1020
1060
|
end
|
1021
1061
|
|
1062
|
+
context 'and lookup_options is empty' do
|
1063
|
+
let(:mod_common) { <<-YAML.unindent }
|
1064
|
+
lookup_options:
|
1065
|
+
mod::a: b
|
1066
|
+
YAML
|
1067
|
+
|
1068
|
+
it 'ignores empty options' do
|
1069
|
+
expect(lookup('mod::a')).to eq("b")
|
1070
|
+
end
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
context 'and lookup_options contains a legal hash with unexpected types' do
|
1074
|
+
let(:mod_common) { <<-YAML.unindent }
|
1075
|
+
lookup_options:
|
1076
|
+
:invalid_symbol
|
1077
|
+
YAML
|
1078
|
+
|
1079
|
+
it 'fails lookup and reports a type mismatch' do
|
1080
|
+
expect {
|
1081
|
+
lookup('mod::a')
|
1082
|
+
}.to raise_error(Puppet::DataBinding::LookupError, /has wrong type, expects Puppet::LookupValue, got Runtime\[ruby, 'Symbol'\]/)
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1022
1086
|
context 'and patterns in module are not limited to module keys' do
|
1023
1087
|
let(:mod_common) {
|
1024
1088
|
<<-YAML.unindent
|
@@ -499,7 +499,7 @@ describe Puppet::Indirector::Indirection do
|
|
499
499
|
end
|
500
500
|
|
501
501
|
it "should return the result of saving to the terminus" do
|
502
|
-
request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false)
|
502
|
+
request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false, :ignore_terminus? => false)
|
503
503
|
|
504
504
|
expect(@indirection).to receive(:request).and_return(request)
|
505
505
|
|
@@ -509,7 +509,7 @@ describe Puppet::Indirector::Indirection do
|
|
509
509
|
end
|
510
510
|
|
511
511
|
it "should use a request to save the object to the cache" do
|
512
|
-
request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false)
|
512
|
+
request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false, :ignore_terminus? => false)
|
513
513
|
|
514
514
|
expect(@indirection).to receive(:request).and_return(request)
|
515
515
|
|
@@ -519,7 +519,7 @@ describe Puppet::Indirector::Indirection do
|
|
519
519
|
end
|
520
520
|
|
521
521
|
it "should not save to the cache if the normal save fails" do
|
522
|
-
request = double('request', :instance => @instance, :node => nil)
|
522
|
+
request = double('request', :instance => @instance, :node => nil, :ignore_terminus? => false)
|
523
523
|
|
524
524
|
expect(@indirection).to receive(:request).and_return(request)
|
525
525
|
|
@@ -534,6 +534,13 @@ describe Puppet::Indirector::Indirection do
|
|
534
534
|
|
535
535
|
@indirection.save(@instance, '/my/key', :ignore_cache_save => true)
|
536
536
|
end
|
537
|
+
|
538
|
+
it "should only save to the cache if the request specifies not to use the terminus" do
|
539
|
+
expect(@terminus).not_to receive(:save)
|
540
|
+
expect(@cache).to receive(:save)
|
541
|
+
|
542
|
+
@indirection.save(@instance, "/my/key", :ignore_terminus => true)
|
543
|
+
end
|
537
544
|
end
|
538
545
|
end
|
539
546
|
|
@@ -154,4 +154,9 @@ describe 'ToStringifiedConverter' do
|
|
154
154
|
unassigned = [243, 176, 128, 128].pack("C*").force_encoding(Encoding::UTF_8)
|
155
155
|
expect(transform(unassigned)).to eq("")
|
156
156
|
end
|
157
|
+
|
158
|
+
it 'converts ProcessOutput objects to string' do
|
159
|
+
object = Puppet::Util::Execution::ProcessOutput.new('object', 0)
|
160
|
+
expect(transform(object)).to be_instance_of(String)
|
161
|
+
end
|
157
162
|
end
|
@@ -1980,6 +1980,12 @@ describe 'The type calculator' do
|
|
1980
1980
|
expect(calculator.instance?(tuple, [1, 'a', 1])).to eq(false)
|
1981
1981
|
end
|
1982
1982
|
|
1983
|
+
it 'should not consider ProcessOutput objects as instanceof PScalarDataType' do
|
1984
|
+
object = Puppet::Util::Execution::ProcessOutput.new('object', 0)
|
1985
|
+
|
1986
|
+
expect(calculator.instance?(PScalarDataType::DEFAULT, object)).to eq(false)
|
1987
|
+
end
|
1988
|
+
|
1983
1989
|
context 'and t is Struct' do
|
1984
1990
|
it 'should consider hash[cont] as instance of Struct[cont-t]' do
|
1985
1991
|
struct = struct_t({'a'=>Integer, 'b'=>String, 'c'=>Float})
|
@@ -476,7 +476,7 @@ context Puppet::Type.type(:package).provider(:gem) do
|
|
476
476
|
end
|
477
477
|
|
478
478
|
context 'when is defaultfor' do
|
479
|
-
let(:os) {
|
479
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
480
480
|
subject do
|
481
481
|
described_class.defaultfor(operatingsystem: os)
|
482
482
|
described_class.specificity
|
@@ -26,7 +26,7 @@ describe Puppet::Type.type(:package).provider(:pip2) do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'when is defaultfor' do
|
29
|
-
let(:os) {
|
29
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
30
30
|
subject do
|
31
31
|
described_class.defaultfor(operatingsystem: os)
|
32
32
|
described_class.specificity
|
@@ -26,7 +26,7 @@ describe Puppet::Type.type(:package).provider(:pip3) do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'when is defaultfor' do
|
29
|
-
let(:os) {
|
29
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
30
30
|
subject do
|
31
31
|
described_class.defaultfor(operatingsystem: os)
|
32
32
|
described_class.specificity
|
@@ -493,7 +493,7 @@ describe Puppet::Type.type(:package).provider(:pip) do
|
|
493
493
|
end
|
494
494
|
|
495
495
|
context 'when is defaultfor' do
|
496
|
-
let(:os) {
|
496
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
497
497
|
subject do
|
498
498
|
described_class.defaultfor(operatingsystem: os)
|
499
499
|
described_class.specificity
|
@@ -118,7 +118,7 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
context 'when is defaultfor' do
|
121
|
-
let(:os) {
|
121
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
122
122
|
subject do
|
123
123
|
described_class.defaultfor(operatingsystem: os)
|
124
124
|
described_class.specificity
|
@@ -127,7 +127,7 @@ describe Puppet::Type.type(:package).provider(:puppetserver_gem) do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
context 'when is defaultfor' do
|
130
|
-
let(:os) {
|
130
|
+
let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
|
131
131
|
subject do
|
132
132
|
described_class.defaultfor(operatingsystem: os)
|
133
133
|
described_class.specificity
|
@@ -217,4 +217,104 @@ describe 'Puppet::Type::User::Provider::Aix' do
|
|
217
217
|
provider.create
|
218
218
|
end
|
219
219
|
end
|
220
|
+
|
221
|
+
describe '#list_all_homes' do
|
222
|
+
it "should return empty array and output debug on failure" do
|
223
|
+
allow(Puppet::Util::Execution).to receive(:execute).and_raise(Puppet::ExecutionFailure, 'Execution failed')
|
224
|
+
expect(Puppet).to receive(:debug).with('Could not list home of all users: Execution failed')
|
225
|
+
expect(provider.list_all_homes).to eql({})
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe '#delete' do
|
230
|
+
before(:each) do
|
231
|
+
allow(File).to receive(:realpath).and_call_original
|
232
|
+
allow(FileUtils).to receive(:remove_entry_secure).and_call_original
|
233
|
+
|
234
|
+
allow(provider.resource).to receive(:should).with(anything).and_return(nil)
|
235
|
+
allow(provider).to receive(:home).and_return(Dir.tmpdir)
|
236
|
+
allow(provider).to receive(:execute).and_return(nil)
|
237
|
+
allow(provider).to receive(:object_info).and_return(nil)
|
238
|
+
allow(FileUtils).to receive(:remove_entry_secure).with(Dir.tmpdir, true).and_return(nil)
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'with managehome true' do
|
242
|
+
before(:each) do
|
243
|
+
allow(provider.resource).to receive(:managehome?).and_return(true)
|
244
|
+
allow(provider).to receive(:list_all_homes).and_return([])
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should delete the user without error' do
|
248
|
+
expect{ provider.delete }.not_to raise_error
|
249
|
+
end
|
250
|
+
|
251
|
+
it "should not remove home when relative" do
|
252
|
+
allow(provider).to receive(:home).and_return('relative_path')
|
253
|
+
|
254
|
+
expect(Puppet).to receive(:debug).with(/Please make sure the path is not relative, symlink or '\/'./)
|
255
|
+
provider.delete
|
256
|
+
end
|
257
|
+
|
258
|
+
it "should not remove home when '/'" do
|
259
|
+
allow(provider).to receive(:home).and_return('/')
|
260
|
+
|
261
|
+
expect(Puppet).to receive(:debug).with(/Please make sure the path is not relative, symlink or '\/'./)
|
262
|
+
provider.delete
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should not remove home when symlink" do
|
266
|
+
allow(Puppet::FileSystem).to receive(:symlink?).with(Dir.tmpdir).and_return(true)
|
267
|
+
|
268
|
+
expect(Puppet).to receive(:debug).with(/Please make sure the path is not relative, symlink or '\/'./)
|
269
|
+
provider.delete
|
270
|
+
end
|
271
|
+
|
272
|
+
it "should not remove home when other users would be affected" do
|
273
|
+
allow(provider).to receive(:home).and_return('/special')
|
274
|
+
allow(File).to receive(:realpath).with('/special').and_return('/special')
|
275
|
+
allow(Puppet::Util).to receive(:absolute_path?).with('/special').and_return(true)
|
276
|
+
allow(provider).to receive(:list_all_homes).and_return([{:name => 'other_user', :home => '/special/other_user'}])
|
277
|
+
|
278
|
+
expect(Puppet).to receive(:debug).with(/it would remove the home directory '\/special\/other_user' of user 'other_user' also./)
|
279
|
+
provider.delete
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'should remove homedir' do
|
283
|
+
expect(FileUtils).to receive(:remove_entry_secure).with(Dir.tmpdir, true)
|
284
|
+
provider.delete
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context 'with managehome false' do
|
289
|
+
before(:each) do
|
290
|
+
allow(provider.resource).to receive(:managehome?).and_return(false)
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'should delete the user without error' do
|
294
|
+
expect{ provider.delete }.not_to raise_error
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'should not remove homedir' do
|
298
|
+
expect(FileUtils).not_to receive(:remove_entry_secure).with(Dir.tmpdir, true)
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should not print manage home debug messages' do
|
302
|
+
expect(Puppet).not_to receive(:debug).with(/Please make sure the path is not relative, symlink or '\/'./)
|
303
|
+
expect(Puppet).not_to receive(:debug).with(/it would remove the home directory '\/special\/other_user' of user 'other_user' also./)
|
304
|
+
|
305
|
+
provider.delete
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe '#deletecmd' do
|
311
|
+
it 'uses the -p flag when removing the user' do
|
312
|
+
allow(provider.class).to receive(:command).with(:delete).and_return('delete')
|
313
|
+
allow(provider).to receive(:ia_module_args).and_return(['ia_module_args'])
|
314
|
+
|
315
|
+
expect(provider.deletecmd).to eql(
|
316
|
+
['delete', '-p', 'ia_module_args', provider.resource.name]
|
317
|
+
)
|
318
|
+
end
|
319
|
+
end
|
220
320
|
end
|