Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expiry in impersonated_credentials.IDTokenCredentials #1330

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,6 @@ def refresh(self, request):

id_token = response.json()["token"]
self.token = id_token
self.expiry = datetime.fromtimestamp(jwt.decode(id_token, verify=False)["exp"])
self.expiry = datetime.utcfromtimestamp(
jwt.decode(id_token, verify=False)["exp"]
)
6 changes: 3 additions & 3 deletions tests/test_impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def test_id_token_success(
id_creds.refresh(request)

assert id_creds.token == ID_TOKEN_DATA
assert id_creds.expiry == datetime.datetime.fromtimestamp(ID_TOKEN_EXPIRY)
assert id_creds.expiry == datetime.datetime.utcfromtimestamp(ID_TOKEN_EXPIRY)

def test_id_token_metrics(self, mock_donor_credentials):
credentials = self.make_credentials(lifetime=None)
Expand All @@ -512,7 +512,7 @@ def test_id_token_metrics(self, mock_donor_credentials):
id_creds.refresh(None)

assert id_creds.token == ID_TOKEN_DATA
assert id_creds.expiry == datetime.datetime.fromtimestamp(
assert id_creds.expiry == datetime.datetime.utcfromtimestamp(
ID_TOKEN_EXPIRY
)
assert (
Expand Down Expand Up @@ -581,7 +581,7 @@ def test_id_token_with_target_audience(
id_creds.refresh(request)

assert id_creds.token == ID_TOKEN_DATA
assert id_creds.expiry == datetime.datetime.fromtimestamp(ID_TOKEN_EXPIRY)
assert id_creds.expiry == datetime.datetime.utcfromtimestamp(ID_TOKEN_EXPIRY)
assert id_creds._include_email is True

def test_id_token_invalid_cred(
Expand Down