From 88f78799a9f87326b328f3da6adee839078d94be Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 21 Jul 2023 12:49:11 -0400 Subject: [PATCH] test: Fix a test that didn't run correctly. This test was missing an assert to ensure that authentication succeeded. However when we add the assert, I learned that the test was failing because the Authorization header was not being submitted correctly into the initial request. I updated the test so that it would pass as expected. --- .../auth/jwt/tests/test_authentication.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edx_rest_framework_extensions/auth/jwt/tests/test_authentication.py b/edx_rest_framework_extensions/auth/jwt/tests/test_authentication.py index fd38b35e..4265e952 100644 --- a/edx_rest_framework_extensions/auth/jwt/tests/test_authentication.py +++ b/edx_rest_framework_extensions/auth/jwt/tests/test_authentication.py @@ -224,8 +224,8 @@ def test_authenticate_with_correct_jwt_authorization(self): Note: CSRF protection should be skipped for this case, with no PermissionDenied. """ jwt_token = self._get_test_jwt_token() - request = RequestFactory().get('/', HTTP_AUTHORIZATION=jwt_token) - JwtAuthentication().authenticate(request) + request = RequestFactory().get('/', HTTP_AUTHORIZATION=f"JWT {jwt_token}") + assert JwtAuthentication().authenticate(request) def test_authenticate_with_incorrect_jwt_authorization(self): """ With JWT header it continues and validates the credentials and throws error. """