mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-20 06:51:48 -05:00
Removed extraneous warning when using garbage credentials for ssh_key_data
added in logic to check if there was an existing error before checking form field entry for ssh_key_unlock, also added a test to ensure that garbage data entered would not trigger the error message for both the incorrect ssh_key_data and the incorrect ssh_key_unlock, rather just the incorrect ssh_key_data
This commit is contained in:
@@ -1360,6 +1360,42 @@ def test_ssh_unlock_with_prior_value(put, organization, admin, credentialtype_ss
|
||||
assert decrypt_field(cred, 'ssh_key_unlock') == 'new-unlock'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('version, params', [
|
||||
['v2', {
|
||||
'name': 'Best credential ever',
|
||||
'credential_type': 1,
|
||||
'inputs': {
|
||||
'username': 'oscar',
|
||||
'ssh_key_data': 'invalid-key',
|
||||
'ssh_key_unlock': 'unchecked-unlock',
|
||||
}
|
||||
}]
|
||||
])
|
||||
def test_ssh_bad_key_unlock_not_checked(put, organization, admin, credentialtype_ssh, version, params):
|
||||
cred = Credential(
|
||||
credential_type=credentialtype_ssh,
|
||||
name='Best credential ever',
|
||||
organization=organization,
|
||||
inputs={
|
||||
'username': u'oscar',
|
||||
'ssh_key_data': 'invalid-key',
|
||||
'ssh_key_unlock': 'unchecked-unlock',
|
||||
}
|
||||
)
|
||||
cred.save()
|
||||
|
||||
params['organization'] = organization.id
|
||||
response = put(
|
||||
reverse('api:credential_detail', kwargs={'version': version, 'pk': cred.pk}),
|
||||
params,
|
||||
admin
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert response.data['inputs']['ssh_key_data'] == ['Invalid certificate or key: invalid-key...']
|
||||
assert 'ssh_key_unlock' not in response.data['inputs']
|
||||
|
||||
|
||||
#
|
||||
# test secret encryption/decryption
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user