Skip to content

Commit

Permalink
Added URL test
Browse files Browse the repository at this point in the history
  • Loading branch information
toavina committed Jan 31, 2025
1 parent 1ef9109 commit cc928c2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ckanext/fjelltopp_security/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_user_update_without_image_url(self, base_user):
# API Tests
def test_api_user_create_with_external_image(self, app):
"""Test that the API blocks external images during user creation."""
sysadmin = factories.Sysadmin()
sysadmin = factories.Sysadmin(image_url=None)

user_dict = {
'name': 'apitestuser',
Expand All @@ -91,10 +91,12 @@ def test_api_user_create_with_external_image(self, app):
url,
json=user_dict,
headers={'Authorization': sysadmin['apikey']},
status=500 # Setting expected status code to 500
status=409
)

# Check error message in response
response_dict = response.json
assert 'message' in response_dict
assert 'Image URL must be a local path. External URLs are not allowed' in str(response_dict['message'])
assert not response_dict['success']
assert 'error' in response_dict
assert 'image_url' in response_dict['error']
assert 'Image URL must be a local path. External URLs are not allowed' in response_dict['error']['image_url'][0]

0 comments on commit cc928c2

Please sign in to comment.