diff options
author | ciprianbadescu <51971875+ciprianbadescu@users.noreply.github.com> | 2020-06-22 11:41:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 11:41:19 +0300 |
commit | d3af1ba4deca0b24c3f5e31738b9175c489309a9 (patch) | |
tree | 31039815fada0c69a3cf8211412ab4fffd35a170 | |
parent | 333b8a02d3d4f44d57bdd0e8898cd1cb712d5486 (diff) | |
parent | e5abd58287cdb1589fbb46f228ce7a1283b3d4dd (diff) | |
download | puppet-sshkeys_core-d3af1ba4deca0b24c3f5e31738b9175c489309a9.tar.gz puppet-sshkeys_core-d3af1ba4deca0b24c3f5e31738b9175c489309a9.tar.bz2 |
Merge pull request #30 from GabrielNagy/maint/update-user-tests
(maint) Update user type specs to match new behavior
-rw-r--r-- | spec/unit/type/user_spec.rb | 32 |
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 } |