There are some flaky tests related to our JWTs (i.e. passed on re-run) in edx-platform.
FAILED openedx/core/lib/tests/test_jwt.py::TestSign::test_create_jwt - jwt.exceptions.ExpiredSignatureError: Signature has expired
FAILED openedx/core/lib/tests/test_jwt.py::TestSign::test_create_jwt_with_claims - jwt.exceptions.ExpiredSignatureError: Signature has expired
FAILED openedx/core/lib/tests/test_jwt.py::TestUnpack::test_missing_expired_lms_user_id - jwt.exceptions.ExpiredSignatureError: Signature has expired
FAILED openedx/core/lib/tests/test_jwt.py::TestUnpack::test_unpack_jwt - jwt.exceptions.ExpiredSignatureError: Signature has expired
FAILED openedx/core/lib/tests/test_jwt.py::TestUnpack::test_unpack_jwt_with_claims - jwt.exceptions.ExpiredSignatureError: Signature has expired
FAILED openedx/core/lib/tests/test_jwt.py::TestUnpack::test_unpack_token_with_invalid_user - jwt.exceptions.ExpiredSignatureError: Signature has expired
___________________________ TestSign.test_create_jwt ___________________________
self = <openedx.core.lib.tests.test_jwt.TestSign testMethod=test_create_jwt>
def test_create_jwt(self):
token = create_jwt(test_user_id, test_timeout, {}, test_now)
> decoded = unpack_and_verify(token)
openedx/core/lib/tests/test_jwt.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
openedx/core/lib/jwt.py:89: in unpack_and_verify
decoded = jwt.decode(
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/jwt/api_jwt.py:365: in decode
decoded = self.decode_complete(
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/jwt/api_jwt.py:272: in decode_complete
self._validate_claims(
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/jwt/api_jwt.py:405: in _validate_claims
self._validate_exp(payload, now, leeway)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <jwt.api_jwt.PyJWT object at 0x7f9ec75c7440>
payload = {'exp': 1776957758, 'iat': 1776956758, 'iss': 'token-test-issuer', 'lms_user_id': 121, ...}
now = 1776957784.86637, leeway = 0
def _validate_exp(
self,
payload: dict[str, Any],
now: float,
leeway: float,
) -> None:
try:
exp = int(payload["exp"])
except ValueError:
raise DecodeError(
"Expiration Time claim (exp) must be an integer."
) from None
if exp <= (now - leeway):
> raise ExpiredSignatureError("Signature has expired")
E jwt.exceptions.ExpiredSignatureError: Signature has expired
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/jwt/api_jwt.py:508: ExpiredSignatureError
There are some flaky tests related to our JWTs (i.e. passed on re-run) in edx-platform.
Other notes:
Here is the list of failures:
Here is an example failure: