mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add test case which verifies the occurrence of #7409.
This commit is contained in:
parent
b8c58de858
commit
2f3ed58541
@ -7,7 +7,12 @@ import os
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
from salttesting import skipIf
|
||||
from salttesting.helpers import (
|
||||
destructiveTest,
|
||||
ensure_in_syspath,
|
||||
with_system_account
|
||||
)
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import salt libs
|
||||
@ -139,6 +144,45 @@ class SSHKnownHostsStateTest(integration.ModuleCase,
|
||||
self.assertSaltNoneReturn(ret)
|
||||
|
||||
|
||||
class SSHAuthStateTests(integration.ModuleCase,
|
||||
integration.SaltReturnAssertsMixIn):
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(os.geteuid() != 0, 'you must be root to run this test')
|
||||
@with_system_account('issue_7409', on_existing='delete', delete=True)
|
||||
def test_issue_7409_no_linebreaks_between_keys(self, username):
|
||||
|
||||
userdetails = self.run_function('user.info', [username])
|
||||
user_ssh_dir = os.path.join(userdetails['home'], '.ssh')
|
||||
authorized_keys_file = os.path.join(user_ssh_dir, 'authorized_keys')
|
||||
|
||||
ret = self.run_state(
|
||||
'file.managed',
|
||||
name=authorized_keys_file,
|
||||
user=username,
|
||||
makedirs=True,
|
||||
# Explicit no ending line break
|
||||
contents='ssh-rsa AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY== root'
|
||||
)
|
||||
|
||||
ret = self.run_state(
|
||||
'ssh_auth.present',
|
||||
name='AAAAB3NzaC1kcQ9J5bYTEyZ==',
|
||||
enc='ssh-rsa',
|
||||
user=username,
|
||||
comment=username
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
self.assertSaltStateChangesEqual(
|
||||
ret, {'AAAAB3NzaC1kcQ9J5bYTEyZ==': 'New'}
|
||||
)
|
||||
self.assertEqual(
|
||||
open(authorized_keys_file, 'r').read(),
|
||||
'ssh-rsa AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY== root\n'
|
||||
'ssh-rsa AAAAB3NzaC1kcQ9J5bYTEyZ== {0}'.format(username)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(SSHKnownHostsStateTest)
|
||||
|
Loading…
Reference in New Issue
Block a user