GuardPost icon indicating copy to clipboard operation
GuardPost copied to clipboard

unit test failure: test_jwt_validator_fetches_tokens_again_for_unknown_kid

Open wrobell opened this issue 3 months ago • 1 comments

All unit tests pass on a laptop.

One unit test fails on Raspberry Pi. Please see below. Not sure if this is timing issue, or some aarch64 related bug.

$ pytest tests/test_jwts.py::test_jwt_validator_fetches_tokens_again_for_unknown_kid
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.11.11, pytest-8.4.1, pluggy-1.6.0
rootdir: /tmp/guix-build-python-guardpost-1.0.2.drv-4/source
configfile: pyproject.toml
plugins: hypothesis-6.135.26, asyncio-1.0.0
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item

tests/test_jwts.py F                                                                                                                                                                                         [100%]

===================================================================================================== FAILURES =====================================================================================================
_____________________________________________________________________________ test_jwt_validator_fetches_tokens_again_for_unknown_kid ______________________________________________________________________________

    @pytest.mark.asyncio
    async def test_jwt_validator_fetches_tokens_again_for_unknown_kid():
        keys = get_test_jwks()
        # configure a key provider that returns the given JWKS in sequence
        keys_provider = MockedKeysProvider([JWKS(keys.keys[0:2]), JWKS(keys.keys[2:])])
        validator = JWTValidator(
            valid_audiences=["a"],
            valid_issuers=["b"],
            keys_provider=keys_provider,
            cache_time=10,
            refresh_time=0.2,
        )
        await _valid_token_scenario("0", validator)
        await _valid_token_scenario("1", validator)

        # this must fail because tokens were just fetched, and kid "2" is not present
>       with pytest.raises(InvalidAccessToken):
E       Failed: DID NOT RAISE <class 'guardpost.jwts.InvalidAccessToken'>

tests/test_jwts.py:104: Failed

wrobell avatar Sep 26 '25 20:09 wrobell

Hi @wrobell Thank you for reporting this issue. I don't have time right now to look into this. I would debug to see what's happening exactly as another kind of exception is probably happening.

RobertoPrevato avatar Oct 07 '25 05:10 RobertoPrevato