-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
37 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
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
Binary file not shown.
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 |
---|---|---|
|
@@ -499,7 +499,7 @@ def test_with_target_audience_integration(self): | |
responses.add( | ||
responses.POST, | ||
"https://iamcredentials.googleapis.com/v1/projects/-/" | ||
"serviceAccounts/[email protected]:signBlob?alt=json", | ||
"serviceAccounts/[email protected]:signBlob", | ||
status=200, | ||
content_type="application/json", | ||
json={"keyId": "some-key-id", "signedBlob": signature}, | ||
|
@@ -657,7 +657,7 @@ def test_with_quota_project_integration(self): | |
responses.add( | ||
responses.POST, | ||
"https://iamcredentials.googleapis.com/v1/projects/-/" | ||
"serviceAccounts/[email protected]:signBlob?alt=json", | ||
"serviceAccounts/[email protected]:signBlob", | ||
status=200, | ||
content_type="application/json", | ||
json={"keyId": "some-key-id", "signedBlob": signature}, | ||
|
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
from google.auth import _helpers | ||
from google.auth import crypt | ||
from google.auth import exceptions | ||
from google.auth import iam | ||
from google.auth import jwt | ||
from google.auth import transport | ||
from google.auth.credentials import DEFAULT_UNIVERSE_DOMAIN | ||
|
@@ -771,10 +772,36 @@ def test_refresh_iam_flow(self, call_iam_generate_id_token_endpoint): | |
) | ||
request = mock.Mock() | ||
credentials.refresh(request) | ||
req, signer_email, target_audience, access_token = call_iam_generate_id_token_endpoint.call_args[ | ||
req, iam_endpoint, signer_email, target_audience, access_token = call_iam_generate_id_token_endpoint.call_args[ | ||
0 | ||
] | ||
assert req == request | ||
assert iam_endpoint == iam._IAM_IDTOKEN_ENDPOINT | ||
assert signer_email == "[email protected]" | ||
assert target_audience == "https://example.com" | ||
decoded_access_token = jwt.decode(access_token, verify=False) | ||
assert decoded_access_token["scope"] == "https://www.googleapis.com/auth/iam" | ||
|
||
@mock.patch( | ||
"google.oauth2._client.call_iam_generate_id_token_endpoint", autospec=True | ||
) | ||
def test_refresh_iam_flow_non_gdu(self, call_iam_generate_id_token_endpoint): | ||
credentials = self.make_credentials(universe_domain="fake-universe") | ||
token = "id_token" | ||
call_iam_generate_id_token_endpoint.return_value = ( | ||
token, | ||
_helpers.utcnow() + datetime.timedelta(seconds=500), | ||
) | ||
request = mock.Mock() | ||
credentials.refresh(request) | ||
req, iam_endpoint, signer_email, target_audience, access_token = call_iam_generate_id_token_endpoint.call_args[ | ||
0 | ||
] | ||
assert req == request | ||
assert ( | ||
iam_endpoint | ||
== "https://iamcredentials.fake-universe/v1/projects/-/serviceAccounts/{}:generateIdToken" | ||
) | ||
assert signer_email == "[email protected]" | ||
assert target_audience == "https://example.com" | ||
decoded_access_token = jwt.decode(access_token, verify=False) | ||
|