From ed51178e833b6684e5c09e41e3e1b29ef672ffe2 Mon Sep 17 00:00:00 2001 From: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:56:28 +0100 Subject: [PATCH] Call complete when revoking all access succeeds --- controlpanel/api/tasks/handlers/s3.py | 2 ++ tests/api/tasks/test_s3.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/controlpanel/api/tasks/handlers/s3.py b/controlpanel/api/tasks/handlers/s3.py index 69b7ab0d7..6fc766932 100644 --- a/controlpanel/api/tasks/handlers/s3.py +++ b/controlpanel/api/tasks/handlers/s3.py @@ -95,3 +95,5 @@ def handle(self, *args, **kwargs): instance.current_user = task_user instance.revoke_bucket_access() + + self.complete() diff --git a/tests/api/tasks/test_s3.py b/tests/api/tasks/test_s3.py index 368283731..b8134dd01 100644 --- a/tests/api/tasks/test_s3.py +++ b/tests/api/tasks/test_s3.py @@ -121,7 +121,8 @@ def test_revoke_app_access(cluster, complete): @patch("controlpanel.api.models.UserS3Bucket.revoke_bucket_access", new=MagicMock()) @patch("controlpanel.api.models.AppS3Bucket.revoke_bucket_access", new=MagicMock()) @patch("controlpanel.api.models.PolicyS3Bucket.revoke_bucket_access", new=MagicMock()) -def test_revoke_all_access(users): +@patch("controlpanel.api.tasks.handlers.base.BaseTaskHandler.complete") +def test_revoke_all_access(complete, users): bucket = mommy.make("api.S3Bucket") user_access = mommy.make("api.UserS3Bucket", s3bucket=bucket) app_access = mommy.make("api.AppS3Bucket", s3bucket=bucket) @@ -133,3 +134,4 @@ def test_revoke_all_access(users): user_access.revoke_bucket_access.assert_called_once() app_access.revoke_bucket_access.assert_called_once() policy_access.revoke_bucket_access.assert_called_once() + complete.assert_called_once()