-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust token refresh offset to prevent immediate renewal (#167)
- Loading branch information
Showing
2 changed files
with
7 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,13 @@ def mock_forge_access_point(): | |
"name": "Test User", | ||
"email": "[email protected]", | ||
"sub": "test_sub", | ||
"exp": (datetime.now(timezone.utc) + timedelta(hours=1)).timestamp(), | ||
"exp": (datetime.now(timezone.utc) + timedelta(seconds=300)).timestamp(), | ||
} | ||
with patch( | ||
"bluepyemodel.access_point.forge_access_point.NexusForgeAccessPoint.refresh_token" | ||
) as mock_refresh_token: | ||
mock_refresh_token.return_value = ( | ||
datetime.now(timezone.utc) + timedelta(hours=1) | ||
datetime.now(timezone.utc) + timedelta(seconds=300) | ||
).timestamp() | ||
with patch( | ||
"bluepyemodel.access_point.forge_access_point.KnowledgeGraphForge" | ||
|
@@ -71,7 +71,7 @@ def test_refresh_token_not_expired(mock_forge_access_point): | |
""" | ||
Test refresh_token method when the token is not expired. | ||
""" | ||
future_exp = (datetime.now(timezone.utc) + timedelta(hours=1)).timestamp() | ||
future_exp = (datetime.now(timezone.utc) + timedelta(seconds=300)).timestamp() | ||
with patch("jwt.decode") as mock_jwt_decode: | ||
mock_jwt_decode.return_value = { | ||
"preferred_username": "test_user", | ||
|
@@ -88,8 +88,8 @@ def test_refresh_token_expired_offset(mock_forge_access_point, caplog): | |
""" | ||
Test refresh_token method when the token is about to expire. | ||
""" | ||
future_exp = (datetime.now(timezone.utc) + timedelta(seconds=299)).timestamp() | ||
new_future_exp = (datetime.now(timezone.utc) + timedelta(hours=1)).timestamp() | ||
future_exp = (datetime.now(timezone.utc) + timedelta(seconds=29)).timestamp() | ||
new_future_exp = (datetime.now(timezone.utc) + timedelta(seconds=300)).timestamp() | ||
with patch("jwt.decode") as mock_jwt_decode: | ||
mock_jwt_decode.side_effect = [ | ||
{ | ||
|
@@ -121,7 +121,7 @@ def test_refresh_token_expired(mock_forge_access_point, caplog): | |
Test refresh_token method when the token has expired. | ||
""" | ||
past_exp = (datetime.now(timezone.utc) - timedelta(seconds=1)).timestamp() | ||
new_future_exp = (datetime.now(timezone.utc) + timedelta(hours=1)).timestamp() | ||
new_future_exp = (datetime.now(timezone.utc) + timedelta(seconds=300)).timestamp() | ||
with patch("jwt.decode") as mock_jwt_decode: | ||
mock_jwt_decode.side_effect = [ | ||
{ | ||
|