Skip to content

Commit

Permalink
Merge pull request #1780 from GSA/notify-compliance-48
Browse files Browse the repository at this point in the history
Notify compliance 48
  • Loading branch information
ccostino authored Aug 9, 2024
2 parents 7d6b209 + 191b591 commit 75a69dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
12 changes: 4 additions & 8 deletions app/notify_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def check_inactive_service(self):
):
abort(403)

def is_calling_signin_url(self, arg):
return arg.startswith("('/user")

def check_inactive_user(self, *args):
still_signing_in = False

Expand All @@ -64,14 +67,7 @@ def check_inactive_user(self, *args):
# and we only want to check the first arg
for arg in args:
arg = str(arg)
if (
"get-login-gov-user" in arg
or "user/email" in arg
or "/activate" in arg
or "/email-code" in arg
or "/verify/code" in arg
or "/user" in arg
):
if self.is_calling_signin_url(arg):
still_signing_in = True

# This seems to be a weird edge case that happens intermittently with invites
Expand Down
6 changes: 1 addition & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/app/notify_client/test_notify_admin_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ def test_active_service_can_be_modified(notify_admin, method, user, service):
assert ret == request.return_value


@pytest.mark.parametrize(
("arg", "expected_result"),
[
(
"('/user/c5f8a5c9-56d5-4fa9-8c30-3449ae10c072/verify/code',)",
True,
),
("('/user/get-login-gov-user',)", True),
(
"('/service/blahblahblah',)",
False,
),
],
)
def test_is_calling_signin_url(arg, expected_result):
api_client = NotifyAdminAPIClient()
result = api_client.is_calling_signin_url(arg)
assert result == expected_result


@pytest.mark.parametrize("method", ["put", "post", "delete"])
def test_inactive_service_cannot_be_modified_by_normal_user(
notify_admin, api_user_active, method
Expand Down

0 comments on commit 75a69dc

Please sign in to comment.