add test for ssh over network ssh key password preference

This commit is contained in:
chris meyers 2018-08-09 12:51:40 -04:00
parent 3c2b18a965
commit bc2b2214a8

View File

@ -765,12 +765,12 @@ class TestJobCredentials(TestJobExecution):
if expected_flag:
assert expected_flag in ' '.join(args)
def test_net_password(self):
def test_net_ssh_key_unlock(self):
net = CredentialType.defaults['net']()
credential = Credential(
pk=1,
credential_type=net,
inputs = {'username': 'bob', 'ssh_key_unlock': 'secret'}
inputs = {'ssh_key_unlock': 'secret'}
)
credential.inputs['ssh_key_unlock'] = encrypt_field(credential, 'ssh_key_unlock')
self.instance.credentials.add(credential)
@ -781,6 +781,32 @@ class TestJobCredentials(TestJobExecution):
assert 'secret' in call_kwargs.get('expect_passwords').values()
def test_prefer_ssh_over_net_ssh_key_unlock(self):
net = CredentialType.defaults['net']()
net_credential = Credential(
pk=1,
credential_type=net,
inputs = {'ssh_key_unlock': 'net_secret'}
)
net_credential.inputs['ssh_key_unlock'] = encrypt_field(net_credential, 'ssh_key_unlock')
ssh = CredentialType.defaults['ssh']()
ssh_credential = Credential(
pk=1,
credential_type=ssh,
inputs = {'ssh_key_unlock': 'ssh_secret'}
)
ssh_credential.inputs['ssh_key_unlock'] = encrypt_field(ssh_credential, 'ssh_key_unlock')
self.instance.credentials.add(net_credential)
self.instance.credentials.add(ssh_credential)
self.task.run(self.pk)
assert self.run_pexpect.call_count == 1
call_args, call_kwargs = self.run_pexpect.call_args_list[0]
assert 'ssh_secret' in call_kwargs.get('expect_passwords').values()
def test_vault_password(self):
vault = CredentialType.defaults['vault']()
credential = Credential(