Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Commit 4e6e3fc

Browse files
chore: use gapic-generator-python 0.62.1 (#150)
- [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: googleapis/googleapis@84b1a5a Source-Link: https://github.com/googleapis/googleapis-gen/commit/4fb761bbd8506ac156f49bac5f18306aa8eb3aa8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
1 parent 8145ace commit 4e6e3fc

File tree

5 files changed

+100
-21
lines changed

5 files changed

+100
-21
lines changed

google/cloud/iam_credentials_v1/services/iam_credentials/async_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class IAMCredentialsAsyncClient:
4848
4949
Service account credentials are used to temporarily assume the
5050
identity of the service account. Supported credential types
51-
include OAuth 2.0 access tokens, OpenID Connect ID tokens, self-
52-
signed JSON Web Tokens (JWTs), and more.
51+
include OAuth 2.0 access tokens, OpenID Connect ID tokens,
52+
self-signed JSON Web Tokens (JWTs), and more.
5353
"""
5454

5555
_client: IAMCredentialsClient
@@ -295,7 +295,7 @@ async def generate_access_token(
295295
296296
"""
297297
# Create or coerce a protobuf request object.
298-
# Sanity check: If we got a request object, we should *not* have
298+
# Quick check: If we got a request object, we should *not* have
299299
# gotten any keyword arguments that map to the request.
300300
has_flattened_params = any([name, delegates, scope, lifetime])
301301
if request is not None and has_flattened_params:
@@ -421,7 +421,7 @@ async def generate_id_token(
421421
422422
"""
423423
# Create or coerce a protobuf request object.
424-
# Sanity check: If we got a request object, we should *not* have
424+
# Quick check: If we got a request object, we should *not* have
425425
# gotten any keyword arguments that map to the request.
426426
has_flattened_params = any([name, delegates, audience, include_email])
427427
if request is not None and has_flattened_params:
@@ -535,7 +535,7 @@ async def sign_blob(
535535
536536
"""
537537
# Create or coerce a protobuf request object.
538-
# Sanity check: If we got a request object, we should *not* have
538+
# Quick check: If we got a request object, we should *not* have
539539
# gotten any keyword arguments that map to the request.
540540
has_flattened_params = any([name, delegates, payload])
541541
if request is not None and has_flattened_params:
@@ -650,7 +650,7 @@ async def sign_jwt(
650650
651651
"""
652652
# Create or coerce a protobuf request object.
653-
# Sanity check: If we got a request object, we should *not* have
653+
# Quick check: If we got a request object, we should *not* have
654654
# gotten any keyword arguments that map to the request.
655655
has_flattened_params = any([name, delegates, payload])
656656
if request is not None and has_flattened_params:

google/cloud/iam_credentials_v1/services/iam_credentials/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class IAMCredentialsClient(metaclass=IAMCredentialsClientMeta):
8484
8585
Service account credentials are used to temporarily assume the
8686
identity of the service account. Supported credential types
87-
include OAuth 2.0 access tokens, OpenID Connect ID tokens, self-
88-
signed JSON Web Tokens (JWTs), and more.
87+
include OAuth 2.0 access tokens, OpenID Connect ID tokens,
88+
self-signed JSON Web Tokens (JWTs), and more.
8989
"""
9090

9191
@staticmethod
@@ -490,7 +490,7 @@ def generate_access_token(
490490
491491
"""
492492
# Create or coerce a protobuf request object.
493-
# Sanity check: If we got a request object, we should *not* have
493+
# Quick check: If we got a request object, we should *not* have
494494
# gotten any keyword arguments that map to the request.
495495
has_flattened_params = any([name, delegates, scope, lifetime])
496496
if request is not None and has_flattened_params:
@@ -606,7 +606,7 @@ def generate_id_token(
606606
607607
"""
608608
# Create or coerce a protobuf request object.
609-
# Sanity check: If we got a request object, we should *not* have
609+
# Quick check: If we got a request object, we should *not* have
610610
# gotten any keyword arguments that map to the request.
611611
has_flattened_params = any([name, delegates, audience, include_email])
612612
if request is not None and has_flattened_params:
@@ -710,7 +710,7 @@ def sign_blob(
710710
711711
"""
712712
# Create or coerce a protobuf request object.
713-
# Sanity check: If we got a request object, we should *not* have
713+
# Quick check: If we got a request object, we should *not* have
714714
# gotten any keyword arguments that map to the request.
715715
has_flattened_params = any([name, delegates, payload])
716716
if request is not None and has_flattened_params:
@@ -815,7 +815,7 @@ def sign_jwt(
815815
816816
"""
817817
# Create or coerce a protobuf request object.
818-
# Sanity check: If we got a request object, we should *not* have
818+
# Quick check: If we got a request object, we should *not* have
819819
# gotten any keyword arguments that map to the request.
820820
has_flattened_params = any([name, delegates, payload])
821821
if request is not None and has_flattened_params:

google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class IAMCredentialsGrpcTransport(IAMCredentialsTransport):
3939
4040
Service account credentials are used to temporarily assume the
4141
identity of the service account. Supported credential types
42-
include OAuth 2.0 access tokens, OpenID Connect ID tokens, self-
43-
signed JSON Web Tokens (JWTs), and more.
42+
include OAuth 2.0 access tokens, OpenID Connect ID tokens,
43+
self-signed JSON Web Tokens (JWTs), and more.
4444
4545
This class defines the same methods as the primary client, so the
4646
primary client can load the underlying transport implementation
@@ -167,8 +167,11 @@ def __init__(
167167
if not self._grpc_channel:
168168
self._grpc_channel = type(self).create_channel(
169169
self._host,
170+
# use the credentials which are saved
170171
credentials=self._credentials,
171-
credentials_file=credentials_file,
172+
# Set ``credentials_file`` to ``None`` here as
173+
# the credentials that we saved earlier should be used.
174+
credentials_file=None,
172175
scopes=self._scopes,
173176
ssl_credentials=self._ssl_channel_credentials,
174177
quota_project_id=quota_project_id,

google/cloud/iam_credentials_v1/services/iam_credentials/transports/grpc_asyncio.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class IAMCredentialsGrpcAsyncIOTransport(IAMCredentialsTransport):
4040
4141
Service account credentials are used to temporarily assume the
4242
identity of the service account. Supported credential types
43-
include OAuth 2.0 access tokens, OpenID Connect ID tokens, self-
44-
signed JSON Web Tokens (JWTs), and more.
43+
include OAuth 2.0 access tokens, OpenID Connect ID tokens,
44+
self-signed JSON Web Tokens (JWTs), and more.
4545
4646
This class defines the same methods as the primary client, so the
4747
primary client can load the underlying transport implementation
@@ -212,8 +212,11 @@ def __init__(
212212
if not self._grpc_channel:
213213
self._grpc_channel = type(self).create_channel(
214214
self._host,
215+
# use the credentials which are saved
215216
credentials=self._credentials,
216-
credentials_file=credentials_file,
217+
# Set ``credentials_file`` to ``None`` here as
218+
# the credentials that we saved earlier should be used.
219+
credentials_file=None,
217220
scopes=self._scopes,
218221
ssl_credentials=self._ssl_channel_credentials,
219222
quota_project_id=quota_project_id,

tests/unit/gapic/iam_credentials_v1/test_iam_credentials.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,21 +513,28 @@ def test_iam_credentials_client_client_options_scopes(
513513

514514

515515
@pytest.mark.parametrize(
516-
"client_class,transport_class,transport_name",
516+
"client_class,transport_class,transport_name,grpc_helpers",
517517
[
518-
(IAMCredentialsClient, transports.IAMCredentialsGrpcTransport, "grpc"),
518+
(
519+
IAMCredentialsClient,
520+
transports.IAMCredentialsGrpcTransport,
521+
"grpc",
522+
grpc_helpers,
523+
),
519524
(
520525
IAMCredentialsAsyncClient,
521526
transports.IAMCredentialsGrpcAsyncIOTransport,
522527
"grpc_asyncio",
528+
grpc_helpers_async,
523529
),
524530
],
525531
)
526532
def test_iam_credentials_client_client_options_credentials_file(
527-
client_class, transport_class, transport_name
533+
client_class, transport_class, transport_name, grpc_helpers
528534
):
529535
# Check the case credentials file is provided.
530536
options = client_options.ClientOptions(credentials_file="credentials.json")
537+
531538
with mock.patch.object(transport_class, "__init__") as patched:
532539
patched.return_value = None
533540
client = client_class(client_options=options, transport=transport_name)
@@ -563,6 +570,72 @@ def test_iam_credentials_client_client_options_from_dict():
563570
)
564571

565572

573+
@pytest.mark.parametrize(
574+
"client_class,transport_class,transport_name,grpc_helpers",
575+
[
576+
(
577+
IAMCredentialsClient,
578+
transports.IAMCredentialsGrpcTransport,
579+
"grpc",
580+
grpc_helpers,
581+
),
582+
(
583+
IAMCredentialsAsyncClient,
584+
transports.IAMCredentialsGrpcAsyncIOTransport,
585+
"grpc_asyncio",
586+
grpc_helpers_async,
587+
),
588+
],
589+
)
590+
def test_iam_credentials_client_create_channel_credentials_file(
591+
client_class, transport_class, transport_name, grpc_helpers
592+
):
593+
# Check the case credentials file is provided.
594+
options = client_options.ClientOptions(credentials_file="credentials.json")
595+
596+
with mock.patch.object(transport_class, "__init__") as patched:
597+
patched.return_value = None
598+
client = client_class(client_options=options, transport=transport_name)
599+
patched.assert_called_once_with(
600+
credentials=None,
601+
credentials_file="credentials.json",
602+
host=client.DEFAULT_ENDPOINT,
603+
scopes=None,
604+
client_cert_source_for_mtls=None,
605+
quota_project_id=None,
606+
client_info=transports.base.DEFAULT_CLIENT_INFO,
607+
always_use_jwt_access=True,
608+
)
609+
610+
# test that the credentials from file are saved and used as the credentials.
611+
with mock.patch.object(
612+
google.auth, "load_credentials_from_file", autospec=True
613+
) as load_creds, mock.patch.object(
614+
google.auth, "default", autospec=True
615+
) as adc, mock.patch.object(
616+
grpc_helpers, "create_channel"
617+
) as create_channel:
618+
creds = ga_credentials.AnonymousCredentials()
619+
file_creds = ga_credentials.AnonymousCredentials()
620+
load_creds.return_value = (file_creds, None)
621+
adc.return_value = (creds, None)
622+
client = client_class(client_options=options, transport=transport_name)
623+
create_channel.assert_called_with(
624+
"iamcredentials.googleapis.com:443",
625+
credentials=file_creds,
626+
credentials_file=None,
627+
quota_project_id=None,
628+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
629+
scopes=None,
630+
default_host="iamcredentials.googleapis.com",
631+
ssl_credentials=None,
632+
options=[
633+
("grpc.max_send_message_length", -1),
634+
("grpc.max_receive_message_length", -1),
635+
],
636+
)
637+
638+
566639
@pytest.mark.parametrize("request_type", [common.GenerateAccessTokenRequest, dict,])
567640
def test_generate_access_token(request_type, transport: str = "grpc"):
568641
client = IAMCredentialsClient(

0 commit comments

Comments
 (0)