diff --git a/tests/test_json_token_file_cache.py b/tests/test_json_token_file_cache.py index 3d4a7bf..57b732d 100644 --- a/tests/test_json_token_file_cache.py +++ b/tests/test_json_token_file_cache.py @@ -15,11 +15,11 @@ def token_cache(request): def test_add_bearer_tokens(token_cache): expiry_in_1_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) - token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret").decode("unicode_escape") + token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret") token_cache.add_bearer_token("key1", token1) expiry_in_2_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=2) - token2 = jwt.encode({"exp": expiry_in_2_hour}, "secret").decode("unicode_escape") + token2 = jwt.encode({"exp": expiry_in_2_hour}, "secret") token_cache.add_bearer_token("key2", token2) # Assert that tokens can be retrieved properly even after other token were inserted @@ -33,11 +33,11 @@ def test_add_bearer_tokens(token_cache): def test_save_bearer_tokens(token_cache, request): expiry_in_1_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) - token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret").decode("unicode_escape") + token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret") token_cache.add_bearer_token("key1", token1) expiry_in_2_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=2) - token2 = jwt.encode({"exp": expiry_in_2_hour}, "secret").decode("unicode_escape") + token2 = jwt.encode({"exp": expiry_in_2_hour}, "secret") token_cache.add_bearer_token("key2", token2) same_cache = requests_auth.JsonTokenFileCache(request.node.name + ".cache") @@ -52,7 +52,7 @@ def failing_dump(*args): monkeypatch.setattr(requests_auth.oauth2_tokens.json, "dump", failing_dump) expiry_in_1_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) - token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret").decode("unicode_escape") + token1 = jwt.encode({"exp": expiry_in_1_hour}, "secret") # Assert that the exception is not thrown token_cache.add_bearer_token("key1", token1) @@ -70,7 +70,7 @@ def test_missing_token(token_cache): def test_missing_token_function(token_cache): expiry_in_1_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) - token = jwt.encode({"exp": expiry_in_1_hour}, "secret").decode("unicode_escape") + token = jwt.encode({"exp": expiry_in_1_hour}, "secret") retrieved_token = token_cache.get_token( "key1", on_missing_token=lambda: ("key1", token) ) @@ -80,7 +80,7 @@ def test_missing_token_function(token_cache): def test_token_without_refresh_token(token_cache): expiry_in_1_hour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) # add token without refresh token - token = jwt.encode({"exp": expiry_in_1_hour}, "secret").decode("unicode_escape") + token = jwt.encode({"exp": expiry_in_1_hour}, "secret") token_cache.tokens["key1"] = ( token, expiry_in_1_hour.replace(tzinfo=datetime.timezone.utc).timestamp(),