make vault_password required for Vault credentials

see: https://github.com/ansible/ansible-tower/issues/7468
This commit is contained in:
Ryan Petrello 2017-08-18 14:10:19 -04:00
parent f1c7286448
commit 438d41c986
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
2 changed files with 20 additions and 0 deletions

View File

@ -690,6 +690,7 @@ def vault(cls):
'secret': True,
'ask_at_runtime': True
}],
'required': ['vault_password'],
}
)

View File

@ -922,6 +922,25 @@ def test_vault_create_ok(post, organization, admin, version, params):
assert decrypt_field(cred, 'vault_password') == 'some_password'
@pytest.mark.django_db
def test_vault_password_required(post, organization, admin):
vault = CredentialType.defaults['vault']()
vault.save()
response = post(
reverse('api:credential_list', kwargs={'version': 'v2'}),
{
'credential_type': vault.pk,
'organization': organization.id,
'name': 'Best credential ever',
'inputs': {}
},
admin
)
assert response.status_code == 400
assert response.data['inputs'] == {'vault_password': ['required for Vault']}
assert Credential.objects.count() == 0
#
# Net Credentials
#