Skip to content

Commit

Permalink
Fix/quicksight-access-bug (#1433)
Browse files Browse the repository at this point in the history
Fixed bug where access would change when button is clicked despite selected inputs not changing
  • Loading branch information
jamesstottmoj authored Jan 15, 2025
1 parent 06d93ef commit 41add7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controlpanel/frontend/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def set_quicksight_embed_access(self, permission_name, quicksight_access):
if permission_name in quicksight_access and not self.user.has_perm(f"api.{codename}"):
identity_store.add_user_to_group(self.user.justice_email, group)
self.user.user_permissions.add(permission)
elif self.user.has_perm(f"api.{codename}"):
elif permission_name not in quicksight_access and self.user.has_perm(f"api.{codename}"):
identity_store.delete_group_membership(self.user.justice_email, group)
self.user.user_permissions.remove(permission)

Expand Down
7 changes: 6 additions & 1 deletion tests/frontend/views/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def test_enable_quicksight_access_legacy(
(
"quicksight_compute_reader",
{"enable_quicksight": ["quicksight_compute_reader"]},
["Mock-Reader-Id", "Mock-Azure-Holding-Id"],
["insert-membership-id", "Mock-Azure-Holding-Id"],
["quicksight_compute_reader", "azure_holding"],
2,
),
Expand Down Expand Up @@ -263,6 +263,11 @@ def test_quicksight_form_add_to_groups(

test_user = users[user]
get_user_id.return_value = test_user.identity_center_id

for i in range(len(group_membership_calls)):
if group_membership_calls[i] == "insert-membership-id":
group_membership_calls[i] = test_user.group_membership_id

get_group_membership_id.side_effect = group_membership_calls

request_user = users["superuser"]
Expand Down

0 comments on commit 41add7c

Please sign in to comment.