From 781629d4899c9410d6cf8ca9224ae7552d405071 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 27 Feb 2020 15:53:48 -0500 Subject: [PATCH] Correct docs and test of restricted JWTs. The comment is misleading beacuse now that restricted JWTs are enforced everywhere, we don't need to set the expiry to be in the past for JWT tokens. --- .../djangoapps/oauth_dispatch/tests/test_views.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/openedx/core/djangoapps/oauth_dispatch/tests/test_views.py b/openedx/core/djangoapps/oauth_dispatch/tests/test_views.py index f9a4a8c282..61458c1f8e 100644 --- a/openedx/core/djangoapps/oauth_dispatch/tests/test_views.py +++ b/openedx/core/djangoapps/oauth_dispatch/tests/test_views.py @@ -270,25 +270,22 @@ class TestAccessTokenView(AccessTokenLoginMixin, mixins.AccessTokenMixin, _Dispa ] mock_set_custom_metric.assert_has_calls(expected_calls, any_order=True) - @ddt.data(True, False) - def test_restricted_jwt_access_token(self, expiration_expected): + def test_restricted_jwt_access_token(self): """ - Verify that when requesting a JWT token from a restricted Application - within the DOT subsystem, that our claims is marked as already expired - (i.e. expiry set to Jan 1, 1970) + Verify that we get a restricted JWT that is not expired. """ response = self._post_request(self.user, self.restricted_dot_app, token_type='jwt') self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertIn('expires_in', data) - self.assertEqual(data['expires_in'] < 0, expiration_expected) + assert data['expires_in'] > 0 self.assertEqual(data['token_type'], 'JWT') self.assert_valid_jwt_access_token( data['access_token'], self.user, data['scope'].split(' '), - should_be_expired=expiration_expected, + should_be_expired=False, should_be_asymmetric_key=True, should_be_restricted=True, )