This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 348
fix: replace deprecated utcfromtimestamp #1799
Merged
chalmerlowe
merged 23 commits into
googleapis:main
from
andriawang6:replace-utcfromtimestamp
Jan 9, 2026
Merged
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
250f015
chore: replace deprecated utcfromtimestamp
andriawang6 0181b9c
Merge branch 'main' into replace-utcfromtimestamp
gkevinzheng 56c135a
Merge branch 'main' into replace-utcfromtimestamp
gkevinzheng f0cd184
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe 16616cc
fix: updates with helper function for utcfromtimestamp
chalmerlowe e186d3f
fix: remove unneeded import
chalmerlowe 0da5e38
fix: update blank line
chalmerlowe 4109407
fix: restore accidently deleted import: copy
chalmerlowe 93a2c67
fix: remove unneeded import: datetime
chalmerlowe 83371b2
updates tests and imports
chalmerlowe c8b2a84
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe ff5ea3c
test: adds unittests for utcfromtimestamp
chalmerlowe 5ec7842
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe 842ba17
fix: adds specific errortype to pytest.raises statement
chalmerlowe 9f5f6ae
fix: update linting in test__helpers.py
chalmerlowe 93fdf1b
updates formatting to satisfy linting
chalmerlowe c46d482
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe 4d552d1
reverts back in order to remove unneeded mods to test_client_async.py
chalmerlowe 3cd7e3d
ensures that the new helper is used universally
chalmerlowe 098fddc
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe c08a16d
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe d501661
Merge branch 'main' into replace-utcfromtimestamp
chalmerlowe 47555de
removes updates accidnetally added during experimentation and testing…
chalmerlowe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -313,7 +313,7 @@ def test_jwt_grant_no_access_token(): | |
|
|
||
|
|
||
| def test_call_iam_generate_id_token_endpoint(): | ||
| now = _helpers.utcnow() | ||
| now = _helpers.utcnow().astimezone(datetime.timezone.utc) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests pass without the changes to |
||
| id_token_expiry = _helpers.datetime_to_secs(now) | ||
| id_token = jwt.encode(SIGNER, {"exp": id_token_expiry}).decode("utf-8") | ||
| request = make_request({"token": id_token}) | ||
|
|
@@ -343,7 +343,7 @@ def test_call_iam_generate_id_token_endpoint(): | |
| # Check result | ||
| assert token == id_token | ||
| # JWT does not store microseconds | ||
| now = now.replace(microsecond=0) | ||
| now = now.replace(microsecond=0).astimezone(datetime.timezone.utc) | ||
| assert expiry == now | ||
|
|
||
|
|
||
|
|
@@ -368,7 +368,7 @@ def test_call_iam_generate_id_token_endpoint_no_id_token(): | |
|
|
||
|
|
||
| def test_id_token_jwt_grant(): | ||
| now = _helpers.utcnow() | ||
| now = _helpers.utcnow().astimezone(datetime.timezone.utc) | ||
| id_token_expiry = _helpers.datetime_to_secs(now) | ||
| id_token = jwt.encode(SIGNER, {"exp": id_token_expiry}).decode("utf-8") | ||
| request = make_request({"id_token": id_token, "extra": "data"}) | ||
|
|
@@ -385,7 +385,7 @@ def test_id_token_jwt_grant(): | |
| # Check result | ||
| assert token == id_token | ||
| # JWT does not store microseconds | ||
| now = now.replace(microsecond=0) | ||
| now = now.replace(microsecond=0).astimezone(datetime.timezone.utc) | ||
| assert expiry == now | ||
| assert extra_data["extra"] == "data" | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
_helpers.utcfromtimestamp. Applies throughoutThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.