aboutsummaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorGabriel Nagy <gabriel.nagy@puppet.com>2020-05-20 14:11:33 +0300
committerGabriel Nagy <gabriel.nagy@puppet.com>2020-06-22 11:34:34 +0300
commite5abd58287cdb1589fbb46f228ce7a1283b3d4dd (patch)
tree31039815fada0c69a3cf8211412ab4fffd35a170 /spec/unit
parent333b8a02d3d4f44d57bdd0e8898cd1cb712d5486 (diff)
downloadpuppet-sshkeys_core-e5abd58287cdb1589fbb46f228ce7a1283b3d4dd.tar.gz
puppet-sshkeys_core-e5abd58287cdb1589fbb46f228ce7a1283b3d4dd.tar.bz2
(maint) Update user type specs to match new behavior
`purge_ssh_keys` behavior will change with the next Puppet release (6.16.0). This commit updates the tests to reflect the updated behavior. See https://github.com/puppetlabs/puppet/pull/8157.
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/type/user_spec.rb32
1 files changed, 20 insertions, 12 deletions
diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb
index 122434f..449f3dd 100644
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@ -55,23 +55,23 @@ describe Puppet::Type.type(:user) do
end
end
- context 'with no home directory specified' do
- it 'does not accept true' do
- expect {
+ if Puppet.version.start_with?('6')
+ context 'with no home directory specified' do
+ before(:each) do
+ Dir.stubs(:home).with('a').returns('/home/a')
+ end
+
+ it 'does accept true' do
described_class.new(name: 'a', purge_ssh_keys: true)
- }.to raise_error(Puppet::Error, %r{purge_ssh_keys can only be true for users with a defined home directory})
- end
+ end
- it 'does not accept the ~ wildcard' do
- expect {
+ it 'does accept the ~ wildcard' do
described_class.new(name: 'a', purge_ssh_keys: '~/keys')
- }.to raise_error(Puppet::Error, %r{meta character ~ or %h only allowed for users with a defined home directory})
- end
+ end
- it 'does not accept the %h wildcard' do
- expect {
+ it 'does accept the %h wildcard' do
described_class.new(name: 'a', purge_ssh_keys: '%h/keys')
- }.to raise_error(Puppet::Error, %r{meta character ~ or %h only allowed for users with a defined home directory})
+ end
end
end
@@ -82,6 +82,10 @@ describe Puppet::Type.type(:user) do
res
end
+ before(:each) do
+ Dir.stubs(:home).with('test').returns('/home/test')
+ end
+
let(:paths) do
['/dev/null', '/tmp/keyfile'].map { |path| File.expand_path(path) }
end
@@ -106,6 +110,10 @@ describe Puppet::Type.type(:user) do
res
end
+ before(:each) do
+ Dir.stubs(:home).with('test_user_name').returns('/home/test_user_name')
+ end
+
context 'when purging is disabled' do
let(:purge_param) { false }