From 815c5df89afb840b83d3acc96dc62974b0f5ac65 Mon Sep 17 00:00:00 2001 From: Muhammad Umar Khan Date: Mon, 6 Nov 2023 14:10:04 +0500 Subject: [PATCH] squash! fix quality issues --- lti_consumer/lti_1p3/key_handlers.py | 30 ++++++++++----------- lti_consumer/lti_1p3/tests/test_consumer.py | 16 +++++------ lti_consumer/tests/unit/test_lti_xblock.py | 1 - 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lti_consumer/lti_1p3/key_handlers.py b/lti_consumer/lti_1p3/key_handlers.py index 7993d2e6..b5fac3dd 100644 --- a/lti_consumer/lti_1p3/key_handlers.py +++ b/lti_consumer/lti_1p3/key_handlers.py @@ -112,11 +112,11 @@ def validate_and_decode(self, token): for i in range(len(key_set)): try: message = jwt.decode( - token, - key=key_set[i], - algorithms=['RS256', 'RS512',], - options={'verify_signature': True} - ) + token, + key=key_set[i], + algorithms=['RS256', 'RS512',], + options={'verify_signature': True} + ) return message except Exception: if i == len(key_set) - 1: @@ -201,16 +201,16 @@ def validate_and_decode(self, token, iss=None, aud=None): raise exceptions.RsaKeyNotSet() try: message = jwt.decode( - token, - key=self.key.public_key(), - audience=aud, - issuer=iss, - algorithms=['RS256', 'RS512'], - options={ - 'verify_signature': True, - 'verify_aud': True if aud else False - } - ) + token, + key=self.key.public_key(), + audience=aud, + issuer=iss, + algorithms=['RS256', 'RS512'], + options={ + 'verify_signature': True, + 'verify_aud': True if aud else False + } + ) return message except Exception as token_error: diff --git a/lti_consumer/lti_1p3/tests/test_consumer.py b/lti_consumer/lti_1p3/tests/test_consumer.py index fa7fb1af..f86144a0 100644 --- a/lti_consumer/lti_1p3/tests/test_consumer.py +++ b/lti_consumer/lti_1p3/tests/test_consumer.py @@ -125,14 +125,14 @@ def _decode_token(self, token): for i in range(len(keyset)): try: message = jwt.decode( - token, - key=keyset[i].key, - algorithms=['RS256', 'RS512'], - options={ - 'verify_signature': True, - 'verify_aud': False - } - ) + token, + key=keyset[i].key, + algorithms=['RS256', 'RS512'], + options={ + 'verify_signature': True, + 'verify_aud': False + } + ) return message except Exception as token_error: if i < len(keyset) - 1: diff --git a/lti_consumer/tests/unit/test_lti_xblock.py b/lti_consumer/tests/unit/test_lti_xblock.py index ee3e3faa..c2dde8f5 100644 --- a/lti_consumer/tests/unit/test_lti_xblock.py +++ b/lti_consumer/tests/unit/test_lti_xblock.py @@ -1941,7 +1941,6 @@ def setUp(self): self.key = algo_obj.prepare_key(pem) self.public_key = rsa_key.public_key().export_key('PEM') - self.xblock_attributes = { 'lti_version': 'lti_1p3', 'lti_1p3_launch_url': 'http://tool.example/launch',