Skip to content

Commit

Permalink
Remove revoked_by arg
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljcollinsuk committed Oct 18, 2023
1 parent 69b7fba commit e075f92
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
5 changes: 2 additions & 3 deletions controlpanel/api/models/apps3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ def __repr__(self):
def grant_bucket_access(self):
tasks.S3BucketGrantToApp(self, self.current_user).create_task()

def revoke_bucket_access(self, revoked_by=None):
revoked_by = revoked_by or None
tasks.S3BucketRevokeAppAccess(self, revoked_by).create_task()
def revoke_bucket_access(self):
tasks.S3BucketRevokeAppAccess(self, self.current_user).create_task()
4 changes: 2 additions & 2 deletions controlpanel/api/models/policys3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def grant_bucket_access(self):
self.resources,
)

def revoke_bucket_access(self, revoked_by=None):
# TODO update to use a Task to revoke access, to match user/app access{{
def revoke_bucket_access(self):
# TODO update to use a Task to revoke access, to match user/app access
if self.s3bucket.is_folder:
return cluster.RoleGroup(self.policy).revoke_folder_access(
root_folder_path=self.s3bucket.name
Expand Down
5 changes: 2 additions & 3 deletions controlpanel/api/models/users3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ def __repr__(self):
def grant_bucket_access(self):
tasks.S3BucketGrantToUser(self, self.current_user).create_task()

def revoke_bucket_access(self, revoked_by=None):
def revoke_bucket_access(self):
# TODO when soft delete is added, this should be updated to use the user that
# has deleted the parent S3bucket to ensure we store the user that has sent the
# task in the case of cascading deletes
revoked_by = revoked_by or self.current_user
tasks.S3BucketRevokeUserAccess(self, revoked_by).create_task()
tasks.S3BucketRevokeUserAccess(self, self.current_user).create_task()
3 changes: 2 additions & 1 deletion controlpanel/api/tasks/handlers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ def handle(self, *args, **kwargs):
if not issubclass(model, AccessToS3Bucket):
continue

instance.revoke_bucket_access(revoked_by=task_user)
instance.current_user = task_user
instance.revoke_bucket_access()
12 changes: 3 additions & 9 deletions tests/api/tasks/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ def test_revoke_all_access(users):

revoke_all_access_s3bucket(bucket.pk, task.user_id)

user_access.revoke_bucket_access.assert_called_once_with(
revoked_by=users["superuser"],
)
app_access.revoke_bucket_access.assert_called_once_with(
revoked_by=users["superuser"],
)
policy_access.revoke_bucket_access.assert_called_once_with(
revoked_by=users["superuser"],
)
user_access.revoke_bucket_access.assert_called_once()
app_access.revoke_bucket_access.assert_called_once()
policy_access.revoke_bucket_access.assert_called_once()

0 comments on commit e075f92

Please sign in to comment.