mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 20:05:03 -02:30
Fix server error from DAB ValidationError with strings (#15312)
This commit is contained in:
@@ -227,7 +227,10 @@ class APIView(views.APIView):
|
|||||||
if type(response.data) is dict:
|
if type(response.data) is dict:
|
||||||
msg_data['error'] = response.data.get('error', response.status_text)
|
msg_data['error'] = response.data.get('error', response.status_text)
|
||||||
elif type(response.data) is list:
|
elif type(response.data) is list:
|
||||||
msg_data['error'] = ", ".join(list(map(lambda x: x.get('error', response.status_text), response.data)))
|
if len(response.data) > 0 and isinstance(response.data[0], str):
|
||||||
|
msg_data['error'] = str(response.data[0])
|
||||||
|
else:
|
||||||
|
msg_data['error'] = ", ".join(list(map(lambda x: x.get('error', response.status_text), response.data)))
|
||||||
else:
|
else:
|
||||||
msg_data['error'] = response.status_text
|
msg_data['error'] = response.status_text
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import pytest
|
|||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.urls import reverse as django_reverse
|
from django.urls import reverse as django_reverse
|
||||||
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
from awx.api.versioning import reverse
|
from awx.api.versioning import reverse
|
||||||
from awx.main.models import JobTemplate, Inventory, Organization
|
from awx.main.models import JobTemplate, Inventory, Organization
|
||||||
@@ -118,3 +119,12 @@ def test_workflow_creation_permissions(setup_managed_roles, organization, workfl
|
|||||||
org_wf_rd.give_permission(rando, organization)
|
org_wf_rd.give_permission(rando, organization)
|
||||||
|
|
||||||
assert access.can_add({'name': 'foo-flow', 'organization': organization.pk})
|
assert access.can_add({'name': 'foo-flow', 'organization': organization.pk})
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
@override_settings(ALLOW_LOCAL_RESOURCE_MANAGEMENT=False)
|
||||||
|
def test_team_member_role_not_assignable(team, rando, post, admin_user, setup_managed_roles):
|
||||||
|
member_rd = RoleDefinition.objects.get(name='Organization Member')
|
||||||
|
url = django_reverse('roleuserassignment-list')
|
||||||
|
r = post(url, data={'object_id': team.id, 'role_definition': member_rd.id, 'user': rando.id}, user=admin_user, expect=400)
|
||||||
|
assert 'Not managed locally' in str(r.data)
|
||||||
|
|||||||
Reference in New Issue
Block a user