Skip to content

Commit

Permalink
fix: tests can now generate JWT tokens with absent user_ids
Browse files Browse the repository at this point in the history
ENT-7926
  • Loading branch information
pwnage101 committed Jan 17, 2024
1 parent 44fe99a commit f18067a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions enterprise_subsidy/apps/api/v1/tests/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def _jwt_token_from_role_context_pairs(self, role_context_pairs, include_user_id
payload['roles'] = roles
if include_user_id:
payload['user_id'] = STATIC_LMS_USER_ID
else:
# For some reason, generate_unversioned_payload() automatically borrows the `id` from the provided user for
# the `user_id` in the generated payload, so we should delete it when the caller doesn't want to include a
# user_id. In the real world, the JWT user_id being the exact same as the IDA User's `id` would be
# extremely unlikely.
del payload['user_id']
return generate_jwt_token(payload)

def set_jwt_cookie(self, role_context_pairs=None, include_user_id=True):
Expand Down

0 comments on commit f18067a

Please sign in to comment.