Skip to content

Commit

Permalink
Merge pull request RedHatInsights#1407 from astrozzc/bindingmapping
Browse files Browse the repository at this point in the history
Show output of deletion result
  • Loading branch information
astrozzc authored Dec 20, 2024
2 parents 93a78d6 + b158453 commit 878fbb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rbac/internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from django.db import transaction
from django.urls import resolve
from management.relation_replicator.logging_replicator import stringify_spicedb_relationship
from management.relation_replicator.outbox_replicator import OutboxReplicator
from management.relation_replicator.relation_replicator import PartitionKey, ReplicationEvent, ReplicationEventType

Expand Down Expand Up @@ -81,5 +82,5 @@ def delete_bindings(bindings):
),
)
bindings.delete()
info["relations"] = relations_to_remove
info["relations"] = [stringify_spicedb_relationship(relation) for relation in relations_to_remove]
return info
2 changes: 1 addition & 1 deletion rbac/internal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def list_or_delete_bindings_for_role(request, role_uuid):
return HttpResponse(json.dumps(result), content_type="application/json", status=200)
else:
info = delete_bindings(bindings)
return HttpResponse(info, content_type="application/json", status=204)
return HttpResponse(json.dumps(info), status=200)


def migration_resources(request):
Expand Down
2 changes: 1 addition & 1 deletion tests/internal/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def test_delete_bindings_by_role(self, replicate):
f"/_private/api/utils/bindings/{self.role.uuid}/?mappings__role__is_system=True",
**self.request.META,
)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
self.assertEqual(response.status_code, status.HTTP_200_OK)
with self.assertRaises(BindingMapping.DoesNotExist):
binding_mappings[0].refresh_from_db()
binding_mappings[1].refresh_from_db()
Expand Down

0 comments on commit 878fbb8

Please sign in to comment.