Skip to content

Commit

Permalink
chore: pr review improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
johanseto committed Nov 8, 2024
1 parent 3aecd50 commit 8b11e10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions eox_nelp/third_party_auth/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_user_associate_uid_with_national_id(self):
self.backend.get_idp.return_value.get_user_permanent_id.return_value = test_uid
self.backend.strategy.storage.user.get_user.return_value = past_user

pipe_output = safer_associate_user_by_national_id(self.request, self.backend, self.details, self.response)
pipe_output = self.uid_pipe(self.request, self.backend, self.details, self.response)

self.assertEqual({"user": past_user, "is_new": False}, pipe_output)
self.backend.strategy.storage.user.get_user.assert_called_with(**{self.user_query: test_uid})
Expand All @@ -136,7 +136,7 @@ def test_user_associate_uid_with_social_record(self):
self.backend.get_idp.return_value.get_user_permanent_id.return_value = test_uid
self.backend.strategy.storage.user.get_user.return_value = past_user

pipe_output = safer_associate_user_by_social_auth_record(
pipe_output = self.uid_pipe(
self.request,
self.backend,
self.details,
Expand Down Expand Up @@ -182,3 +182,20 @@ def test_not_user_arg(self):
pipe_output = disallow_staff_superuser_users(self.request, self.backend, self.details, self.response)

self.assertIsNone(pipe_output)

def test_not_staff_or_superuser_user(self):
"""Test the pipeline method receives a normal user(not staff and not superuser)
Expected behavior:
- The pipe method returns empty dict
"""
past_user, _ = User.objects.get_or_create(username="notstaffsuperuser")

pipe_output = disallow_staff_superuser_users(
self.request,
self.backend,
self.details,
self.response,
user=past_user
)

self.assertDictEqual({}, pipe_output)
2 changes: 1 addition & 1 deletion requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build==1.2.2.post1
# via pip-tools
click==8.1.7
# via pip-tools
packaging==24.1
packaging==24.2
# via build
pip-tools==7.4.1
# via -r requirements/pip-tools.in
Expand Down

0 comments on commit 8b11e10

Please sign in to comment.