puppet 6.17.0-x64-mingw32 → 6.18.0-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.lock +6 -5
- data/lib/puppet/application/apply.rb +18 -20
- data/lib/puppet/application/lookup.rb +16 -4
- data/lib/puppet/configurer/downloader.rb +31 -10
- data/lib/puppet/confine.rb +1 -1
- data/lib/puppet/confine/any.rb +1 -1
- data/lib/puppet/defaults.rb +21 -3
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/file_serving/mount/locales.rb +1 -2
- data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
- data/lib/puppet/file_serving/mount/plugins.rb +1 -2
- data/lib/puppet/file_system/file_impl.rb +3 -3
- data/lib/puppet/functions/lstrip.rb +4 -4
- data/lib/puppet/functions/reverse_each.rb +1 -1
- data/lib/puppet/functions/rstrip.rb +4 -4
- data/lib/puppet/functions/step.rb +1 -1
- data/lib/puppet/functions/strip.rb +4 -4
- data/lib/puppet/gettext/config.rb +5 -5
- data/lib/puppet/gettext/module_translations.rb +4 -4
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +3 -3
- data/lib/puppet/indirector/file_metadata/http.rb +1 -0
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/indirection.rb +1 -1
- data/lib/puppet/indirector/report/processor.rb +2 -2
- data/lib/puppet/module.rb +1 -2
- data/lib/puppet/network/format_support.rb +2 -2
- data/lib/puppet/network/http/route.rb +2 -2
- data/lib/puppet/node/environment.rb +12 -5
- data/lib/puppet/pal/pal_impl.rb +27 -3
- data/lib/puppet/parameter.rb +1 -1
- data/lib/puppet/parser/functions.rb +21 -17
- data/lib/puppet/parser/functions/create_resources.rb +11 -7
- data/lib/puppet/parser/type_loader.rb +2 -2
- data/lib/puppet/pops/adaptable.rb +7 -13
- data/lib/puppet/pops/adapters.rb +8 -4
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +4 -2
- data/lib/puppet/pops/loaders.rb +18 -11
- data/lib/puppet/pops/lookup/context.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +14 -1
- data/lib/puppet/pops/types/iterable.rb +34 -8
- data/lib/puppet/pops/validation/checker4_0.rb +19 -15
- data/lib/puppet/provider/file/windows.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +34 -0
- data/lib/puppet/provider/package/gem.rb +4 -2
- data/lib/puppet/provider/package/puppet_gem.rb +5 -0
- data/lib/puppet/provider/package/zypper.rb +3 -0
- data/lib/puppet/provider/user/aix.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/windows_adsi.rb +18 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/ssl/validator/default_validator.rb +1 -1
- data/lib/puppet/test/test_helper.rb +10 -3
- data/lib/puppet/transaction.rb +2 -2
- data/lib/puppet/transaction/persistence.rb +1 -1
- data/lib/puppet/transaction/report.rb +1 -1
- data/lib/puppet/trusted_external.rb +2 -2
- data/lib/puppet/type.rb +4 -3
- data/lib/puppet/type/file.rb +2 -2
- data/lib/puppet/type/file/source.rb +27 -7
- data/lib/puppet/type/notify.rb +2 -2
- data/lib/puppet/type/service.rb +4 -0
- data/lib/puppet/type/user.rb +18 -3
- data/lib/puppet/util.rb +26 -12
- data/lib/puppet/util/autoload.rb +9 -7
- data/lib/puppet/util/character_encoding.rb +9 -5
- data/lib/puppet/util/execution.rb +2 -2
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/api_types.rb +15 -1
- data/lib/puppet/util/windows/monkey_patches/dir.rb +40 -0
- data/lib/puppet/util/windows/security.rb +4 -4
- data/lib/puppet/util/windows/user.rb +219 -0
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +78 -69
- data/man/man5/puppet.conf.5 +22 -3
- data/man/man8/puppet-agent.8 +1 -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-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +2 -2
- data/man/man8/puppet-man.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-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/provider/applytest/applytest.rb +2 -0
- data/spec/fixtures/integration/application/apply/environments/spec/modules/amod/lib/puppet/type/applytest.rb +25 -0
- data/spec/fixtures/unit/forge/bacula-releases.json +128 -0
- data/spec/fixtures/unit/forge/bacula.tar.gz +0 -0
- data/spec/integration/application/agent_spec.rb +29 -37
- data/spec/integration/application/apply_spec.rb +149 -149
- data/spec/integration/application/config_spec.rb +74 -0
- data/spec/integration/application/doc_spec.rb +16 -6
- data/spec/integration/application/filebucket_spec.rb +65 -16
- data/spec/integration/application/help_spec.rb +42 -0
- data/spec/integration/application/lookup_spec.rb +13 -0
- data/spec/integration/application/module_spec.rb +68 -0
- data/spec/integration/application/plugin_spec.rb +50 -0
- data/spec/integration/data_binding_spec.rb +82 -0
- data/spec/integration/directory_environments_spec.rb +17 -17
- data/spec/integration/indirector/facts/facter_spec.rb +8 -6
- data/spec/integration/node/environment_spec.rb +1 -1
- data/spec/integration/util/execution_spec.rb +22 -0
- data/spec/integration/util/windows/monkey_patches/dir_spec.rb +11 -0
- data/spec/integration/util/windows/process_spec.rb +26 -32
- data/spec/integration/util/windows/user_spec.rb +7 -0
- data/spec/integration/util_spec.rb +7 -33
- data/spec/lib/puppet_spec/matchers.rb +0 -80
- data/spec/lib/puppet_spec/puppetserver.rb +8 -0
- data/spec/unit/application/agent_spec.rb +3 -4
- data/spec/unit/application/face_base_spec.rb +6 -4
- data/spec/unit/application/facts_spec.rb +39 -10
- data/spec/unit/application/man_spec.rb +52 -0
- data/spec/unit/application/resource_spec.rb +3 -1
- data/spec/unit/application/ssl_spec.rb +15 -2
- data/spec/unit/configurer/downloader_spec.rb +10 -0
- data/spec/unit/configurer_spec.rb +47 -31
- data/spec/unit/confine_spec.rb +2 -1
- data/spec/unit/face/config_spec.rb +3 -1
- data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
- data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
- data/spec/unit/file_system/uniquefile_spec.rb +18 -0
- data/spec/unit/http/client_spec.rb +0 -1
- data/spec/unit/http/resolver_spec.rb +0 -1
- data/spec/unit/http/service/ca_spec.rb +0 -1
- data/spec/unit/http/service/compiler_spec.rb +0 -1
- data/spec/unit/http/service/file_server_spec.rb +0 -1
- data/spec/unit/http/service/report_spec.rb +0 -1
- data/spec/unit/http/service_spec.rb +0 -1
- data/spec/unit/http/session_spec.rb +0 -1
- data/spec/unit/module_tool/tar/mini_spec.rb +20 -0
- data/spec/unit/network/format_support_spec.rb +3 -2
- data/spec/unit/node/environment_spec.rb +18 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +70 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +25 -0
- data/spec/unit/provider/package/apt_spec.rb +77 -0
- data/spec/unit/provider/package/aptitude_spec.rb +1 -0
- data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/service/init_spec.rb +41 -0
- data/spec/unit/provider/service/systemd_spec.rb +1 -6
- data/spec/unit/provider/service/windows_spec.rb +28 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +82 -0
- data/spec/unit/puppet_pal_2pec.rb +40 -0
- data/spec/unit/reports/store_spec.rb +17 -13
- data/spec/unit/transaction/persistence_spec.rb +15 -0
- data/spec/unit/type/service_spec.rb +35 -2
- data/spec/unit/type/user_spec.rb +31 -2
- data/spec/unit/util/character_encoding_spec.rb +4 -4
- data/spec/unit/util/command_line_spec.rb +11 -6
- metadata +21 -44
- data/spec/integration/faces/config_spec.rb +0 -91
- data/spec/integration/faces/documentation_spec.rb +0 -57
- data/spec/integration/file_bucket/file_spec.rb +0 -50
- data/spec/integration/file_serving/content_spec.rb +0 -7
- data/spec/integration/file_serving/fileset_spec.rb +0 -12
- data/spec/integration/file_serving/metadata_spec.rb +0 -8
- data/spec/integration/file_serving/terminus_helper_spec.rb +0 -20
- data/spec/integration/file_system/uniquefile_spec.rb +0 -26
- data/spec/integration/module_tool/forge_spec.rb +0 -51
- data/spec/integration/module_tool/tar/mini_spec.rb +0 -28
- data/spec/integration/provider/service/init_spec.rb +0 -48
- data/spec/integration/provider/service/systemd_spec.rb +0 -25
- data/spec/integration/provider/service/windows_spec.rb +0 -50
- data/spec/integration/reference/providers_spec.rb +0 -21
- data/spec/integration/reports_spec.rb +0 -13
- data/spec/integration/ssl/certificate_request_spec.rb +0 -44
- data/spec/integration/ssl/host_spec.rb +0 -72
- data/spec/integration/ssl/key_spec.rb +0 -99
- data/spec/shared_behaviours/file_serving_model.rb +0 -51
- data/spec/unit/face/man_spec.rb +0 -25
- data/spec/unit/man_spec.rb +0 -31
@@ -1,12 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platform.jruby? do
|
3
|
+
describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platform.jruby? || Puppet::Util::Platform.windows? do
|
4
4
|
let(:provider_class) { Puppet::Type.type(:service).provider(:systemd) }
|
5
|
-
if Puppet::Util::Platform.windows?
|
6
|
-
# Get a pid for $CHILD_STATUS to latch on to
|
7
|
-
command = "cmd.exe /c \"exit 0\""
|
8
|
-
Puppet::Util::Execution.execute(command, {:failonfail => false})
|
9
|
-
end
|
10
5
|
|
11
6
|
before :each do
|
12
7
|
allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class)
|
@@ -127,6 +127,34 @@ describe 'Puppet::Type::Service::Provider::Windows',
|
|
127
127
|
expect(provider.status).to eq(:running)
|
128
128
|
end
|
129
129
|
end
|
130
|
+
|
131
|
+
context 'when querying lmhosts', if: Puppet::Util::Platform.windows? do
|
132
|
+
# This service should be ubiquitous across all supported Windows platforms
|
133
|
+
let(:service) { Puppet::Type.type(:service).new(:name => 'lmhosts') }
|
134
|
+
|
135
|
+
before :each do
|
136
|
+
allow(service_util).to receive(:exists?).with(service.name).and_call_original
|
137
|
+
end
|
138
|
+
|
139
|
+
it "reports if the service is enabled" do
|
140
|
+
expect([:true, :false, :manual]).to include(service.provider.enabled?)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "reports on the service status" do
|
144
|
+
expect(
|
145
|
+
[
|
146
|
+
:running,
|
147
|
+
:'continue pending',
|
148
|
+
:'pause pending',
|
149
|
+
:paused,
|
150
|
+
:running,
|
151
|
+
:'start pending',
|
152
|
+
:'stop pending',
|
153
|
+
:stopped
|
154
|
+
]
|
155
|
+
).to include(service.provider.status)
|
156
|
+
end
|
157
|
+
end
|
130
158
|
end
|
131
159
|
|
132
160
|
describe "#restart" do
|
@@ -72,6 +72,88 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet::Util::
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe "when setting roles" do
|
76
|
+
context "when role_membership => minimum" do
|
77
|
+
before :each do
|
78
|
+
resource[:role_membership] = :minimum
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should set the given role when user has no roles" do
|
82
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
|
83
|
+
|
84
|
+
expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
|
85
|
+
provider.roles = 'givenRole1'
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should set only the misssing role when user already has other roles" do
|
89
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1')
|
90
|
+
|
91
|
+
expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole2']).and_return(nil)
|
92
|
+
provider.roles = 'givenRole1,givenRole2'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should never remove any roles" do
|
96
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1')
|
97
|
+
allow(Puppet::Util::Windows::User).to receive(:set_rights).and_return(nil)
|
98
|
+
|
99
|
+
expect(Puppet::Util::Windows::User).not_to receive(:remove_rights)
|
100
|
+
provider.roles = 'givenRole1,givenRole2'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "when role_membership => inclusive" do
|
105
|
+
before :each do
|
106
|
+
resource[:role_membership] = :inclusive
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should remove the unwanted role" do
|
110
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
|
111
|
+
|
112
|
+
expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
|
113
|
+
provider.roles = 'givenRole1'
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should add the missing role and remove the unwanted one" do
|
117
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
|
118
|
+
|
119
|
+
expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole3']).and_return(nil)
|
120
|
+
expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
|
121
|
+
provider.roles = 'givenRole1,givenRole3'
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should not set any roles when the user already has given role" do
|
125
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
|
126
|
+
allow(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole2']).and_return(nil)
|
127
|
+
|
128
|
+
expect(Puppet::Util::Windows::User).not_to receive(:set_rights)
|
129
|
+
provider.roles = 'givenRole1'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should set the given role when user has no roles" do
|
133
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
|
134
|
+
|
135
|
+
expect(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
|
136
|
+
provider.roles = 'givenRole1'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should not remove any roles when user has no roles" do
|
140
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('')
|
141
|
+
allow(Puppet::Util::Windows::User).to receive(:set_rights).with('testuser', ['givenRole1']).and_return(nil)
|
142
|
+
|
143
|
+
expect(Puppet::Util::Windows::User).not_to receive(:remove_rights)
|
144
|
+
provider.roles = 'givenRole1'
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should remove all roles when none given" do
|
148
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('givenRole1,givenRole2')
|
149
|
+
|
150
|
+
expect(Puppet::Util::Windows::User).not_to receive(:set_rights)
|
151
|
+
expect(Puppet::Util::Windows::User).to receive(:remove_rights).with('testuser', ['givenRole1', 'givenRole2']).and_return(nil)
|
152
|
+
provider.roles = ''
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
75
157
|
describe "#groups_insync?" do
|
76
158
|
let(:group1) { double(:account => 'group1', :domain => '.', :sid => 'group1sid') }
|
77
159
|
let(:group2) { double(:account => 'group2', :domain => '.', :sid => 'group2sid') }
|
@@ -708,6 +708,46 @@ describe 'Puppet Pal' do
|
|
708
708
|
end
|
709
709
|
end
|
710
710
|
|
711
|
+
context 'facts are supported such that' do
|
712
|
+
it 'they are obtained if they are not given' do
|
713
|
+
facts = Puppet::Node::Facts.new(Puppet[:certname], 'puppetversion' => Puppet.version)
|
714
|
+
Puppet::Node::Facts.indirection.save(facts)
|
715
|
+
|
716
|
+
testing_env_dir # creates the structure
|
717
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath ) do |ctx|
|
718
|
+
ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[puppetversion] == '#{Puppet.version}'") }
|
719
|
+
end
|
720
|
+
expect(result).to eq(true)
|
721
|
+
end
|
722
|
+
|
723
|
+
it 'can be given as a hash when creating the environment' do
|
724
|
+
testing_env_dir # creates the structure
|
725
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
|
726
|
+
ctx.with_script_compiler {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 42") }
|
727
|
+
end
|
728
|
+
expect(result).to eq(true)
|
729
|
+
end
|
730
|
+
|
731
|
+
it 'can be overridden with a hash when creating a script compiler' do
|
732
|
+
testing_env_dir # creates the structure
|
733
|
+
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42 }) do |ctx|
|
734
|
+
ctx.with_script_compiler(facts: { 'myfact' => 43 }) {|c| c.evaluate_string("$facts =~ Hash and $facts[myfact] == 43") }
|
735
|
+
end
|
736
|
+
expect(result).to eq(true)
|
737
|
+
end
|
738
|
+
|
739
|
+
it 'can be disabled with the :set_local_facts option' do
|
740
|
+
Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: { 'myfact' => 42}) do |ctx|
|
741
|
+
ctx.with_script_compiler(facts: { 'myfact' => 42 }, set_local_facts: false) do |compiler|
|
742
|
+
expect { compiler.evaluate_string('$facts') }.to raise_error(
|
743
|
+
Puppet::PreformattedError,
|
744
|
+
/Unknown variable: 'facts'/
|
745
|
+
)
|
746
|
+
end
|
747
|
+
end
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
711
751
|
context 'supports tasks such that' do
|
712
752
|
it '"task_signature" returns the signatures of a generic task' do
|
713
753
|
result = Puppet::Pal.in_tmp_environment('pal_env', modulepath: modulepath, facts: node_facts) do |ctx|
|
@@ -6,53 +6,57 @@ require 'pathname'
|
|
6
6
|
require 'tempfile'
|
7
7
|
require 'fileutils'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
describe processor do
|
9
|
+
describe Puppet::Reports.report(:store) do
|
12
10
|
describe "#process" do
|
13
11
|
include PuppetSpec::Files
|
12
|
+
|
14
13
|
before :each do
|
15
14
|
Puppet[:reportdir] = File.join(tmpdir('reports'), 'reports')
|
16
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:report) do
|
18
|
+
report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml'))
|
19
|
+
report.extend(described_class)
|
20
|
+
report
|
17
21
|
end
|
18
22
|
|
19
23
|
it "should create a report directory for the client if one doesn't exist" do
|
20
|
-
|
24
|
+
report.process
|
21
25
|
|
22
|
-
expect(File).to be_directory(File.join(Puppet[:reportdir],
|
26
|
+
expect(File).to be_directory(File.join(Puppet[:reportdir], report.host))
|
23
27
|
end
|
24
28
|
|
25
29
|
it "should write the report to the file in YAML" do
|
26
30
|
allow(Time).to receive(:now).and_return(Time.utc(2011,01,06,12,00,00))
|
27
|
-
|
31
|
+
report.process
|
28
32
|
|
29
|
-
expect(File.read(File.join(Puppet[:reportdir],
|
33
|
+
expect(File.read(File.join(Puppet[:reportdir], report.host, "201101061200.yaml"))).to eq(report.to_yaml)
|
30
34
|
end
|
31
35
|
|
32
36
|
it "rejects invalid hostnames" do
|
33
|
-
|
37
|
+
report.host = ".."
|
34
38
|
expect(Puppet::FileSystem).not_to receive(:exist?)
|
35
|
-
expect {
|
39
|
+
expect { report.process }.to raise_error(ArgumentError, /Invalid node/)
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
describe "::destroy" do
|
40
44
|
it "rejects invalid hostnames" do
|
41
45
|
expect(Puppet::FileSystem).not_to receive(:unlink)
|
42
|
-
expect {
|
46
|
+
expect { described_class.destroy("..") }.to raise_error(ArgumentError, /Invalid node/)
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
46
50
|
describe "::validate_host" do
|
47
51
|
['..', 'hello/', '/hello', 'he/llo', 'hello/..', '.'].each do |node|
|
48
52
|
it "rejects #{node.inspect}" do
|
49
|
-
expect {
|
53
|
+
expect { described_class.validate_host(node) }.to raise_error(ArgumentError, /Invalid node/)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
57
|
['.hello', 'hello.', '..hi', 'hi..'].each do |node|
|
54
58
|
it "accepts #{node.inspect}" do
|
55
|
-
|
59
|
+
described_class.validate_host(node)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
@@ -123,6 +123,21 @@ describe Puppet::Transaction::Persistence do
|
|
123
123
|
persistence = Puppet::Transaction::Persistence.new
|
124
124
|
persistence.load
|
125
125
|
end
|
126
|
+
|
127
|
+
it 'should load Time and Symbols' do
|
128
|
+
write_state_file(<<~END)
|
129
|
+
File[/tmp/audit]:
|
130
|
+
parameters:
|
131
|
+
mtime:
|
132
|
+
system_value:
|
133
|
+
- 2020-07-15 05:38:12.427678398 +00:00
|
134
|
+
ensure:
|
135
|
+
system_value:
|
136
|
+
END
|
137
|
+
|
138
|
+
persistence = Puppet::Transaction::Persistence.new
|
139
|
+
expect(persistence.load.dig("File[/tmp/audit]", "parameters", "mtime", "system_value")).to contain_exactly(be_a(Time))
|
140
|
+
end
|
126
141
|
end
|
127
142
|
end
|
128
143
|
|
@@ -165,8 +165,38 @@ describe test_title, "when validating attribute values" do
|
|
165
165
|
|
166
166
|
context "when on Windows", :if => Puppet::Util::Platform.windows? do
|
167
167
|
before do
|
168
|
+
allow(Puppet::Util::Windows::User).to receive(:password_is?).and_return(true)
|
168
169
|
allow(Puppet::Util::Windows::ADSI).to receive(:computer_name).and_return("myPC")
|
170
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('SeServiceLogonRight')
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should fail when the `Log On As A Service` right is missing from given user" do
|
174
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(Puppet::Util::Windows::SID::Principal.new("myUser", nil, nil, "myPC", :SidTypeUser))
|
175
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).with('myPC\\myUser').and_return("")
|
176
|
+
|
177
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'myUser') }.to raise_error(Puppet::Error, /"myPC\\myUser" is missing the 'Log On As A Service' right./)
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should fail when the `Log On As A Service` right is set to denied for given user" do
|
181
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(Puppet::Util::Windows::SID::Principal.new("myUser", nil, nil, "myPC", :SidTypeUser))
|
182
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).with('myPC\\myUser').and_return("SeDenyServiceLogonRight")
|
183
|
+
|
184
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'myUser') }.to raise_error(Puppet::Error, /"myPC\\myUser" has the 'Log On As A Service' right set to denied./)
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should not fail when given user has the `Log On As A Service` right" do
|
188
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(Puppet::Util::Windows::SID::Principal.new("myUser", nil, nil, "myPC", :SidTypeUser))
|
189
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).with('myPC\\myUser').and_return("SeServiceLogonRight")
|
190
|
+
|
191
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'myUser') }.not_to raise_error
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should not fail when given user is a default system account even if the `Log On As A Service` right is missing" do
|
195
|
+
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(Puppet::Util::Windows::SID::Principal.new("LOCAL SERVICE", nil, nil, "NT AUTHORITY", :SidTypeUser))
|
169
196
|
allow(Puppet::Util::Windows::User).to receive(:default_system_account?).and_return(true)
|
197
|
+
|
198
|
+
expect(Puppet::Util::Windows::User).not_to receive(:get_rights)
|
199
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'myUser') }.not_to raise_error
|
170
200
|
end
|
171
201
|
|
172
202
|
['LocalSystem', '.\LocalSystem', 'myPC\LocalSystem', 'lOcALsysTem'].each do |user_input|
|
@@ -212,12 +242,12 @@ describe test_title, "when validating attribute values" do
|
|
212
242
|
|
213
243
|
it "should fail when account is invalid" do
|
214
244
|
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(nil)
|
215
|
-
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'InvalidUser') }.to raise_error(Puppet::Error,
|
245
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'InvalidUser') }.to raise_error(Puppet::Error, /"InvalidUser" is not a valid account/)
|
216
246
|
end
|
217
247
|
|
218
248
|
it "should fail when sid type is not user or well known user" do
|
219
249
|
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(Puppet::Util::Windows::SID::Principal.new("Administrators", nil, nil, "BUILTIN", :SidTypeAlias))
|
220
|
-
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'Administrators') }.to raise_error(Puppet::Error,
|
250
|
+
expect { Puppet::Type.type(:service).new(:name => "yay", :logonaccount => 'Administrators') }.to raise_error(Puppet::Error, /"Administrators" is not a valid account/)
|
221
251
|
end
|
222
252
|
end
|
223
253
|
end
|
@@ -254,6 +284,7 @@ describe test_title, "when validating attribute values" do
|
|
254
284
|
before do
|
255
285
|
allow(Puppet::Util::Windows::ADSI).to receive(:computer_name).and_return("myPC")
|
256
286
|
allow(Puppet::Util::Windows::SID).to receive(:name_to_principal).and_return(name_to_principal_result)
|
287
|
+
allow(Puppet::Util::Windows::User).to receive(:get_rights).and_return('SeServiceLogonRight')
|
257
288
|
end
|
258
289
|
|
259
290
|
it "should pass validation when given account is 'LocalSystem'" do
|
@@ -273,6 +304,7 @@ describe test_title, "when validating attribute values" do
|
|
273
304
|
|
274
305
|
it "should pass validation" do
|
275
306
|
allow(Puppet::Util::Windows::User).to receive(:localsystem?).with(predefined_local_account).and_return(false)
|
307
|
+
expect(Puppet::Util::Windows::User).to receive(:default_system_account?).with(predefined_local_account).and_return(true)
|
276
308
|
expect(Puppet::Util::Windows::User).to receive(:default_system_account?).with("NT AUTHORITY\\#{predefined_local_account}").and_return(true)
|
277
309
|
|
278
310
|
expect(Puppet::Util::Windows::User).not_to receive(:password_is?)
|
@@ -288,6 +320,7 @@ describe test_title, "when validating attribute values" do
|
|
288
320
|
describe "when given logonaccount is not a predefined local account" do
|
289
321
|
before do
|
290
322
|
allow(Puppet::Util::Windows::User).to receive(:localsystem?).with('myUser').and_return(false)
|
323
|
+
allow(Puppet::Util::Windows::User).to receive(:default_system_account?).with('myUser').and_return(false)
|
291
324
|
allow(Puppet::Util::Windows::User).to receive(:default_system_account?).with('.\\myUser').and_return(false)
|
292
325
|
end
|
293
326
|
|
data/spec/unit/type/user_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
describe Puppet::Type.type(:user) do
|
5
5
|
before :each do
|
6
6
|
@provider_class = described_class.provide(:simple) do
|
7
|
-
has_features :manages_expiry, :manages_password_age, :manages_passwords, :manages_solaris_rbac, :manages_shell
|
7
|
+
has_features :manages_expiry, :manages_password_age, :manages_passwords, :manages_solaris_rbac, :manages_roles, :manages_shell
|
8
8
|
mk_resource_methods
|
9
9
|
def create; end
|
10
10
|
def delete; end
|
@@ -35,6 +35,10 @@ describe Puppet::Type.type(:user) do
|
|
35
35
|
expect(described_class.provider_feature(:manages_solaris_rbac)).not_to be_nil
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should have a manages_roles feature" do
|
39
|
+
expect(described_class.provider_feature(:manages_roles)).not_to be_nil
|
40
|
+
end
|
41
|
+
|
38
42
|
it "should have a manages_expiry feature" do
|
39
43
|
expect(described_class.provider_feature(:manages_expiry)).not_to be_nil
|
40
44
|
end
|
@@ -401,7 +405,7 @@ describe Puppet::Type.type(:user) do
|
|
401
405
|
end
|
402
406
|
|
403
407
|
describe "when user has roles" do
|
404
|
-
it "should autorequire roles" do
|
408
|
+
it "should autorequire roles on non-Windows", :unless => Puppet::Util::Platform.windows? do
|
405
409
|
testuser = described_class.new(:name => "testuser", :roles => ['testrole'] )
|
406
410
|
testrole = described_class.new(:name => "testrole")
|
407
411
|
|
@@ -413,6 +417,31 @@ describe Puppet::Type.type(:user) do
|
|
413
417
|
expect(rel.source.ref).to eq(testrole.ref)
|
414
418
|
expect(rel.target.ref).to eq(testuser.ref)
|
415
419
|
end
|
420
|
+
|
421
|
+
it "should not autorequire roles on Windows", :if => Puppet::Util::Platform.windows? do
|
422
|
+
testuser = described_class.new(:name => "testuser", :roles => ['testrole'] )
|
423
|
+
testrole = described_class.new(:name => "testrole")
|
424
|
+
|
425
|
+
Puppet::Resource::Catalog.new :testing do |conf|
|
426
|
+
[testuser, testrole].each { |resource| conf.add_resource resource }
|
427
|
+
end
|
428
|
+
|
429
|
+
expect(testuser.autorequire).to be_empty
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should sync the user roles when changing the state of :ensure if :roles is being managed" do
|
433
|
+
user = Puppet::Type.type(:user).new(:name => "myUser", :ensure => :present)
|
434
|
+
user[:roles] = 'testRole'
|
435
|
+
|
436
|
+
allow(user.provider.class).to receive(:supports_parameter?).and_return(true)
|
437
|
+
expect(user.property(:roles)).to receive(:retrieve).and_return("other")
|
438
|
+
expect(user.property(:roles)).to receive(:insync?).and_return(false)
|
439
|
+
expect(user.property(:roles)).to receive(:sync)
|
440
|
+
|
441
|
+
allow(user.provider).to receive(:create)
|
442
|
+
|
443
|
+
user.property(:ensure).sync
|
444
|
+
end
|
416
445
|
end
|
417
446
|
|
418
447
|
describe "when setting shell" do
|
@@ -21,7 +21,7 @@ describe Puppet::Util::CharacterEncoding do
|
|
21
21
|
let(:invalid_utf8_string) { "\xfd\xf1".force_encoding(Encoding::UTF_8) }
|
22
22
|
|
23
23
|
it "should issue a debug message" do
|
24
|
-
expect(Puppet).to receive(:debug).
|
24
|
+
expect(Puppet).to receive(:debug) { |&b| expect(b.call).to match(/encoding is invalid/) }
|
25
25
|
Puppet::Util::CharacterEncoding.convert_to_utf_8(invalid_utf8_string)
|
26
26
|
end
|
27
27
|
|
@@ -80,7 +80,7 @@ describe Puppet::Util::CharacterEncoding do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should issue a debug message that the string was not transcodable" do
|
83
|
-
expect(Puppet).to receive(:debug).
|
83
|
+
expect(Puppet).to receive(:debug) { |&b| expect(b.call).to match(/cannot be transcoded/) }
|
84
84
|
PuppetSpec::CharacterEncoding.with_external_encoding(Encoding::Windows_31J) do
|
85
85
|
Puppet::Util::CharacterEncoding.convert_to_utf_8(invalid_win_31j)
|
86
86
|
end
|
@@ -124,7 +124,7 @@ describe Puppet::Util::CharacterEncoding do
|
|
124
124
|
let(:euc_kr) { [253, 241].pack('C*').force_encoding(Encoding::ASCII) }
|
125
125
|
|
126
126
|
it "should issue a debug message" do
|
127
|
-
expect(Puppet).to receive(:debug).
|
127
|
+
expect(Puppet).to receive(:debug) { |&b| expect(b.call).to match(/cannot be transcoded/) }
|
128
128
|
Puppet::Util::CharacterEncoding.convert_to_utf_8(euc_kr)
|
129
129
|
end
|
130
130
|
|
@@ -168,7 +168,7 @@ describe Puppet::Util::CharacterEncoding do
|
|
168
168
|
let(:foo) { 'foo' }
|
169
169
|
|
170
170
|
it "should issue a debug message" do
|
171
|
-
expect(Puppet).to receive(:debug).
|
171
|
+
expect(Puppet).to receive(:debug) { |&b| expect(b.call).to match(/not valid UTF-8/) }
|
172
172
|
Puppet::Util::CharacterEncoding.override_encoding_to_utf_8(oslash)
|
173
173
|
end
|
174
174
|
|