Skip to content

Commit

Permalink
Merge pull request #29264 from alprs/fix-ssh_auth_absent_test
Browse files Browse the repository at this point in the history
Prevent ssh_auth.absent from running when test=True
  • Loading branch information
Mike Place committed Nov 30, 2015
2 parents 459d30f + 9193676 commit 8d32d8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 12 additions & 12 deletions salt/states/ssh_auth.py
Expand Up @@ -394,6 +394,18 @@ def absent(name,
'result': True,
'comment': ''}

if __opts__['test']:
ret['result'], ret['comment'] = _absent_test(
user,
name,
enc,
comment,
options or [],
source,
config,
)
return ret

# Extract Key from file if source is present
if source != '':
key = __salt__['cp.get_file_str'](
Expand Down Expand Up @@ -438,18 +450,6 @@ def absent(name,
comment = comps[2]
ret['comment'] = __salt__['ssh.rm_auth_key'](user, name, config)

if __opts__['test']:
ret['result'], ret['comment'] = _absent_test(
user,
name,
enc,
comment,
options or [],
source,
config,
)
return ret

if ret['comment'] == 'User authorized keys file not present':
ret['result'] = False
return ret
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/states/ssh_auth_test.py
Expand Up @@ -83,8 +83,6 @@ def test_absent(self):
'comment': ''}

mock = MagicMock(side_effect=['User authorized keys file not present',
'User authorized keys file not present',
'User authorized keys file not present',
'Key removed'])
mock_up = MagicMock(side_effect=['update', 'updated'])
with patch.dict(ssh_auth.__salt__, {'ssh.rm_auth_key': mock,
Expand Down

0 comments on commit 8d32d8d

Please sign in to comment.