mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-28 10:51:49 -05:00
require url scheme for credential type url inputs
This adds a url formatting type for credential input string fields The validator for this formatting type will throw an error if the provided url string doesn't have a url schema.
This commit is contained in:
@@ -1942,3 +1942,34 @@ def test_create_credential_missing_user_team_org_xfail(post, admin, credentialty
|
||||
admin
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create_credential_with_missing_url_schema_xfail(post, organization, admin):
|
||||
credential_type = CredentialType(
|
||||
kind='test',
|
||||
name='MyTestCredentialType',
|
||||
inputs = {
|
||||
'fields': [{
|
||||
'id': 'server_url',
|
||||
'label': 'Server Url',
|
||||
'type': 'string',
|
||||
'format': 'url'
|
||||
}]
|
||||
}
|
||||
)
|
||||
credential_type.save()
|
||||
|
||||
params = {
|
||||
'name': 'Second Best credential ever',
|
||||
'organization': organization.pk,
|
||||
'credential_type': credential_type.pk,
|
||||
'inputs': {'server_url': 'foo.com'}
|
||||
}
|
||||
endpoint = reverse('api:credential_list', kwargs={'version': 'v2'})
|
||||
response = post(endpoint, params, admin)
|
||||
assert response.status_code == 400
|
||||
|
||||
params['inputs'] = {'server_url': 'http://foo.com'}
|
||||
response = post(endpoint, params, admin)
|
||||
assert response.status_code == 201
|
||||
|
||||
Reference in New Issue
Block a user