]> gitweb.fluxo.info Git - puppet-sshkeys_core.git/commitdiff
(maint) Update user type specs to match new behavior
authorGabriel Nagy <gabriel.nagy@puppet.com>
Wed, 20 May 2020 11:11:33 +0000 (14:11 +0300)
committerGabriel Nagy <gabriel.nagy@puppet.com>
Mon, 22 Jun 2020 08:34:34 +0000 (11:34 +0300)
`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.

spec/unit/type/user_spec.rb

index 122434ffa52bee79e61bccfb7b84de32e9b3da03..449f3dd227491107925af33e0b6d1f995328a3f1 100644 (file)
@@ -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 }