Merge branch 'downstream' into devel

This commit is contained in:
Ryan Petrello
2019-05-03 07:58:25 -04:00
33 changed files with 198 additions and 76 deletions

View File

@@ -1942,3 +1942,39 @@ def test_create_credential_missing_user_team_org_xfail(post, admin, credentialty
admin
)
assert response.status_code == 400
@pytest.mark.parametrize('url, status, msg', [
('foo.com', 400, 'Invalid URL: Missing url scheme (http, https, etc.)'),
('https://[dead:beef', 400, 'Invalid IPv6 URL'),
('http:domain:8080', 400, 'Invalid URL: http:domain:8080'),
('http:/domain:8080', 400, 'Invalid URL: http:/domain:8080'),
('http://foo.com', 201, None)
])
@pytest.mark.django_db
def test_create_credential_with_invalid_url_xfail(post, organization, admin, url, status, msg):
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': url}
}
endpoint = reverse('api:credential_list', kwargs={'version': 'v2'})
response = post(endpoint, params, admin)
assert response.status_code == status
if status != 201:
assert response.data['inputs']['server_url'] == [msg]