mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 15:14:45 -03:30
add test for ssh over network ssh key password preference
This commit is contained in:
@@ -765,12 +765,12 @@ class TestJobCredentials(TestJobExecution):
|
|||||||
if expected_flag:
|
if expected_flag:
|
||||||
assert expected_flag in ' '.join(args)
|
assert expected_flag in ' '.join(args)
|
||||||
|
|
||||||
def test_net_password(self):
|
def test_net_ssh_key_unlock(self):
|
||||||
net = CredentialType.defaults['net']()
|
net = CredentialType.defaults['net']()
|
||||||
credential = Credential(
|
credential = Credential(
|
||||||
pk=1,
|
pk=1,
|
||||||
credential_type=net,
|
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')
|
credential.inputs['ssh_key_unlock'] = encrypt_field(credential, 'ssh_key_unlock')
|
||||||
self.instance.credentials.add(credential)
|
self.instance.credentials.add(credential)
|
||||||
@@ -781,6 +781,32 @@ class TestJobCredentials(TestJobExecution):
|
|||||||
|
|
||||||
assert 'secret' in call_kwargs.get('expect_passwords').values()
|
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):
|
def test_vault_password(self):
|
||||||
vault = CredentialType.defaults['vault']()
|
vault = CredentialType.defaults['vault']()
|
||||||
credential = Credential(
|
credential = Credential(
|
||||||
|
|||||||
Reference in New Issue
Block a user