Skip to content

Commit

Permalink
fix: allowing missing expire time in response
Browse files Browse the repository at this point in the history
  • Loading branch information
BigTailWolf committed Jul 22, 2022
1 parent 6f49d1f commit 0f75503
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
6 changes: 1 addition & 5 deletions google/auth/pluggable.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,7 @@ def _parse_subject_token(self, response):
response["code"], response["message"]
)
)
if "expiration_time" not in response:
raise ValueError(
"The executable response is missing the expiration_time field."
)
if response["expiration_time"] < time.time():
if "expiration_time" in response and response["expiration_time"] < time.time():
raise exceptions.RefreshError(
"The token returned by the executable is expired."
)
Expand Down
11 changes: 2 additions & 9 deletions tests/test_pluggable.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def test_retrieve_subject_token_missing_error_code_message(self):
)

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_missing_expiration_time(self):
def test_retrieve_subject_token_missing_expiration_time_should_pass(self):
EXECUTABLE_SUCCESSFUL_OIDC_RESPONSE = {
"version": 1,
"success": True,
Expand All @@ -646,14 +646,7 @@ def test_retrieve_subject_token_missing_expiration_time(self):
returncode=0,
),
):
credentials = self.make_pluggable(credential_source=self.CREDENTIAL_SOURCE)

with pytest.raises(ValueError) as excinfo:
_ = credentials.retrieve_subject_token(None)

assert excinfo.match(
r"The executable response is missing the expiration_time field."
)
self.make_pluggable(credential_source=self.CREDENTIAL_SOURCE)

@mock.patch.dict(os.environ, {"GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES": "1"})
def test_retrieve_subject_token_missing_token_type(self):
Expand Down

0 comments on commit 0f75503

Please sign in to comment.