async def test_token_expiry(default_data): token = manager.create_access_token( data=default_data, expires_delta=timedelta(microseconds=1) # should be invalid instantly ) time.sleep(1) with pytest.raises(HTTPException): await manager.get_current_user(token)
def invalid_user_token() -> str: return manager.create_access_token(data={'sub': 'not-a-user-id'})
def default_token(default_data) -> str: return manager.create_access_token(data=default_data)
async def test_bad_data(data): bad_token = manager.create_access_token(data=data) with pytest.raises(HTTPException): await manager.get_current_user(bad_token)