mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
Compare commits
5 Commits
0d0dabe166
...
PRWLR-6064
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7b6f03bbe | ||
|
|
52996af891 | ||
|
|
dd16d896a9 | ||
|
|
a53d03e36e | ||
|
|
15e87f5a02 |
@@ -12,6 +12,7 @@ All notable changes to the **Prowler API** are documented in this file.
|
||||
- `/processors` endpoints to post-process findings. Currently, only the Mutelist processor is supported to allow to mute findings.
|
||||
- Optimized the underlying queries for resources endpoints [(#8112)](https://github.com/prowler-cloud/prowler/pull/8112)
|
||||
- Optimized include parameters for resources view [(#8229)](https://github.com/prowler-cloud/prowler/pull/8229)
|
||||
- Improved user deletion error handling with structured JSON response [(#8272)](https://github.com/prowler-cloud/prowler/pull/8272)
|
||||
|
||||
### Fixed
|
||||
- Search filter for findings and resources [(#8112)](https://github.com/prowler-cloud/prowler/pull/8112)
|
||||
|
||||
@@ -324,6 +324,19 @@ class TestUserViewSet:
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
assert User.objects.filter(id=another_user.id).exists()
|
||||
|
||||
def test_users_destroy_unexpected_exception(
|
||||
self, authenticated_client, create_test_user
|
||||
):
|
||||
with patch(
|
||||
"api.v1.views.UserViewSet.perform_destroy",
|
||||
side_effect=Exception("Unexpected"),
|
||||
):
|
||||
response = authenticated_client.delete(
|
||||
reverse("user-detail", kwargs={"pk": create_test_user.id})
|
||||
)
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
assert response.json()["errors"][0]["detail"] == "Failed to delete the user"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"attribute_key, attribute_value, error_field",
|
||||
[
|
||||
|
||||
@@ -779,7 +779,18 @@ class UserViewSet(BaseUserViewset):
|
||||
if kwargs["pk"] != str(self.request.user.id):
|
||||
raise ValidationError("Only the current user can be deleted.")
|
||||
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
try:
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
except Exception:
|
||||
raise ValidationError(
|
||||
[
|
||||
{
|
||||
"detail": "Failed to delete the user",
|
||||
"status": "400",
|
||||
"code": "delete_failed",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
@extend_schema(
|
||||
parameters=[
|
||||
|
||||
Reference in New Issue
Block a user