Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
fix: disable always_use_jwt_access (#65)
Browse files Browse the repository at this point in the history
fix: disable always_use_jwt_access

Committer: @busunkim96
PiperOrigin-RevId: 382142900

Source-Link: googleapis/googleapis@513440f

Source-Link: googleapis/googleapis-gen@7b1e2c3
  • Loading branch information
gcf-owl-bot[bot] committed Jun 30, 2021
1 parent 36f7d83 commit 5c043fa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
Expand Up @@ -104,7 +104,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)

# Save the scopes.
self._scopes = scopes or self.AUTH_SCOPES
self._scopes = scopes

# If no credentials are provided, then determine the appropriate
# defaults.
Expand Down
Expand Up @@ -71,6 +71,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Expand Down Expand Up @@ -111,6 +112,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
Expand Down Expand Up @@ -163,7 +166,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
always_use_jwt_access=True,
always_use_jwt_access=always_use_jwt_access,
)

if not self._grpc_channel:
Expand Down
Expand Up @@ -117,6 +117,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Expand Down Expand Up @@ -158,6 +159,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
Expand Down Expand Up @@ -209,7 +212,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
always_use_jwt_access=True,
always_use_jwt_access=always_use_jwt_access,
)

if not self._grpc_channel:
Expand Down
47 changes: 22 additions & 25 deletions tests/unit/gapic/tables_v1alpha1/test_tables_service.py
Expand Up @@ -131,7 +131,25 @@ def test_tables_service_client_service_account_always_use_jwt(client_class):
) as use_jwt:
creds = service_account.Credentials(None, None, None)
client = client_class(credentials=creds)
use_jwt.assert_called_with(True)
use_jwt.assert_not_called()


@pytest.mark.parametrize(
"transport_class,transport_name",
[
(transports.TablesServiceGrpcTransport, "grpc"),
(transports.TablesServiceGrpcAsyncIOTransport, "grpc_asyncio"),
],
)
def test_tables_service_client_service_account_always_use_jwt_true(
transport_class, transport_name
):
with mock.patch.object(
service_account.Credentials, "with_always_use_jwt_access", create=True
) as use_jwt:
creds = service_account.Credentials(None, None, None)
transport = transport_class(credentials=creds, always_use_jwt_access=True)
use_jwt.assert_called_once_with(True)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -3146,14 +3164,7 @@ def test_tables_service_grpc_transport_client_cert_source_for_mtls(transport_cla
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
scopes=(
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/tables",
),
scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
Expand Down Expand Up @@ -3260,14 +3271,7 @@ def test_tables_service_transport_channel_mtls_with_client_cert_source(transport
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
scopes=(
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/tables",
),
scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
Expand Down Expand Up @@ -3314,14 +3318,7 @@ def test_tables_service_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
scopes=(
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/tables",
),
scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
Expand Down

0 comments on commit 5c043fa

Please sign in to comment.