Skip to content

Commit c37bf21

Browse files
fix: disable always_use_jwt_access (#395)
fix: disable always_use_jwt_access Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: googleapis/googleapis@513440f Source-Link: googleapis/googleapis-gen@7b1e2c3
1 parent aaf154b commit c37bf21

File tree

16 files changed

+120
-51
lines changed

16 files changed

+120
-51
lines changed

google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __init__(
108108
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
109109

110110
# Save the scopes.
111-
self._scopes = scopes or self.AUTH_SCOPES
111+
self._scopes = scopes
112112

113113
# If no credentials are provided, then determine the appropriate
114114
# defaults.

google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(
6969
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
7070
quota_project_id: Optional[str] = None,
7171
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
72+
always_use_jwt_access: Optional[bool] = False,
7273
) -> None:
7374
"""Instantiate the transport.
7475
@@ -109,6 +110,8 @@ def __init__(
109110
API requests. If ``None``, then default info will be used.
110111
Generally, you only need to set this if you're developing
111112
your own client library.
113+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
114+
be used for service account credentials.
112115
113116
Raises:
114117
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -162,7 +165,7 @@ def __init__(
162165
scopes=scopes,
163166
quota_project_id=quota_project_id,
164167
client_info=client_info,
165-
always_use_jwt_access=True,
168+
always_use_jwt_access=always_use_jwt_access,
166169
)
167170

168171
if not self._grpc_channel:

google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(
115115
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
116116
quota_project_id=None,
117117
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
118+
always_use_jwt_access: Optional[bool] = False,
118119
) -> None:
119120
"""Instantiate the transport.
120121
@@ -156,6 +157,8 @@ def __init__(
156157
API requests. If ``None``, then default info will be used.
157158
Generally, you only need to set this if you're developing
158159
your own client library.
160+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
161+
be used for service account credentials.
159162
160163
Raises:
161164
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -208,7 +211,7 @@ def __init__(
208211
scopes=scopes,
209212
quota_project_id=quota_project_id,
210213
client_info=client_info,
211-
always_use_jwt_access=True,
214+
always_use_jwt_access=always_use_jwt_access,
212215
)
213216

214217
if not self._grpc_channel:

google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ class Database(proto.Message):
121121
sure to account for the time from the moment
122122
when the value is queried to the moment when you
123123
initiate the recovery.
124+
default_leader (str):
125+
Output only. The read-write region which contains the
126+
database's leader replicas.
127+
128+
This is the same as the value of default_leader database
129+
option set using DatabaseAdmin.CreateDatabase or
130+
DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this
131+
is empty.
124132
"""
125133

126134
class State(proto.Enum):
@@ -144,6 +152,7 @@ class State(proto.Enum):
144152
earliest_version_time = proto.Field(
145153
proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,
146154
)
155+
default_leader = proto.Field(proto.STRING, number=9,)
147156

148157

149158
class ListDatabasesRequest(proto.Message):

google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(
106106
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
107107

108108
# Save the scopes.
109-
self._scopes = scopes or self.AUTH_SCOPES
109+
self._scopes = scopes
110110

111111
# If no credentials are provided, then determine the appropriate
112112
# defaults.

google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
8383
quota_project_id: Optional[str] = None,
8484
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
85+
always_use_jwt_access: Optional[bool] = False,
8586
) -> None:
8687
"""Instantiate the transport.
8788
@@ -122,6 +123,8 @@ def __init__(
122123
API requests. If ``None``, then default info will be used.
123124
Generally, you only need to set this if you're developing
124125
your own client library.
126+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
127+
be used for service account credentials.
125128
126129
Raises:
127130
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -175,7 +178,7 @@ def __init__(
175178
scopes=scopes,
176179
quota_project_id=quota_project_id,
177180
client_info=client_info,
178-
always_use_jwt_access=True,
181+
always_use_jwt_access=always_use_jwt_access,
179182
)
180183

181184
if not self._grpc_channel:

google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def __init__(
128128
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
129129
quota_project_id=None,
130130
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
131+
always_use_jwt_access: Optional[bool] = False,
131132
) -> None:
132133
"""Instantiate the transport.
133134
@@ -169,6 +170,8 @@ def __init__(
169170
API requests. If ``None``, then default info will be used.
170171
Generally, you only need to set this if you're developing
171172
your own client library.
173+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
174+
be used for service account credentials.
172175
173176
Raises:
174177
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -221,7 +224,7 @@ def __init__(
221224
scopes=scopes,
222225
quota_project_id=quota_project_id,
223226
client_info=client_info,
224-
always_use_jwt_access=True,
227+
always_use_jwt_access=always_use_jwt_access,
225228
)
226229

227230
if not self._grpc_channel:

google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ class InstanceConfig(proto.Message):
8888
The geographic placement of nodes in this
8989
instance configuration and their replication
9090
properties.
91+
leader_options (Sequence[str]):
92+
Allowed values of the “default_leader” schema option for
93+
databases in instances that use this instance configuration.
9194
"""
9295

9396
name = proto.Field(proto.STRING, number=1,)
9497
display_name = proto.Field(proto.STRING, number=2,)
9598
replicas = proto.RepeatedField(proto.MESSAGE, number=3, message="ReplicaInfo",)
99+
leader_options = proto.RepeatedField(proto.STRING, number=4,)
96100

97101

98102
class Instance(proto.Message):

google/cloud/spanner_v1/services/spanner/transports/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(
103103
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
104104

105105
# Save the scopes.
106-
self._scopes = scopes or self.AUTH_SCOPES
106+
self._scopes = scopes
107107

108108
# If no credentials are provided, then determine the appropriate
109109
# defaults.

google/cloud/spanner_v1/services/spanner/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(
6363
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6464
quota_project_id: Optional[str] = None,
6565
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
66+
always_use_jwt_access: Optional[bool] = False,
6667
) -> None:
6768
"""Instantiate the transport.
6869
@@ -103,6 +104,8 @@ def __init__(
103104
API requests. If ``None``, then default info will be used.
104105
Generally, you only need to set this if you're developing
105106
your own client library.
107+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
108+
be used for service account credentials.
106109
107110
Raises:
108111
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,7 +158,7 @@ def __init__(
155158
scopes=scopes,
156159
quota_project_id=quota_project_id,
157160
client_info=client_info,
158-
always_use_jwt_access=True,
161+
always_use_jwt_access=always_use_jwt_access,
159162
)
160163

161164
if not self._grpc_channel:

google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def __init__(
109109
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
110110
quota_project_id=None,
111111
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
112+
always_use_jwt_access: Optional[bool] = False,
112113
) -> None:
113114
"""Instantiate the transport.
114115
@@ -150,6 +151,8 @@ def __init__(
150151
API requests. If ``None``, then default info will be used.
151152
Generally, you only need to set this if you're developing
152153
your own client library.
154+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
155+
be used for service account credentials.
153156
154157
Raises:
155158
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,7 +204,7 @@ def __init__(
201204
scopes=scopes,
202205
quota_project_id=quota_project_id,
203206
client_info=client_info,
204-
always_use_jwt_access=True,
207+
always_use_jwt_access=always_use_jwt_access,
205208
)
206209

207210
if not self._grpc_channel:

google/cloud/spanner_v1/types/type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class TypeCode(proto.Enum):
4141
ARRAY = 8
4242
STRUCT = 9
4343
NUMERIC = 10
44+
JSON = 11
4445

4546

4647
class Type(proto.Message):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
release_status = "Development Status :: 5 - Production/Stable"
3131
dependencies = [
3232
"google-api-core[grpc] >= 1.26.0, <2.0.0dev",
33-
"" "google-cloud-core >= 1.4.1, < 2.0dev",
33+
"google-cloud-core >= 1.4.1, < 2.0dev",
3434
"grpc-google-iam-v1 >= 0.12.3, < 0.13dev",
3535
"proto-plus >= 1.11.0",
3636
"sqlparse >= 0.3.0",

tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,25 @@ def test_database_admin_client_service_account_always_use_jwt(client_class):
147147
) as use_jwt:
148148
creds = service_account.Credentials(None, None, None)
149149
client = client_class(credentials=creds)
150-
use_jwt.assert_called_with(True)
150+
use_jwt.assert_not_called()
151+
152+
153+
@pytest.mark.parametrize(
154+
"transport_class,transport_name",
155+
[
156+
(transports.DatabaseAdminGrpcTransport, "grpc"),
157+
(transports.DatabaseAdminGrpcAsyncIOTransport, "grpc_asyncio"),
158+
],
159+
)
160+
def test_database_admin_client_service_account_always_use_jwt_true(
161+
transport_class, transport_name
162+
):
163+
with mock.patch.object(
164+
service_account.Credentials, "with_always_use_jwt_access", create=True
165+
) as use_jwt:
166+
creds = service_account.Credentials(None, None, None)
167+
transport = transport_class(credentials=creds, always_use_jwt_access=True)
168+
use_jwt.assert_called_once_with(True)
151169

152170

153171
@pytest.mark.parametrize(
@@ -1085,6 +1103,7 @@ def test_get_database(
10851103
name="name_value",
10861104
state=spanner_database_admin.Database.State.CREATING,
10871105
version_retention_period="version_retention_period_value",
1106+
default_leader="default_leader_value",
10881107
)
10891108
response = client.get_database(request)
10901109

@@ -1098,6 +1117,7 @@ def test_get_database(
10981117
assert response.name == "name_value"
10991118
assert response.state == spanner_database_admin.Database.State.CREATING
11001119
assert response.version_retention_period == "version_retention_period_value"
1120+
assert response.default_leader == "default_leader_value"
11011121

11021122

11031123
def test_get_database_from_dict():
@@ -1140,6 +1160,7 @@ async def test_get_database_async(
11401160
name="name_value",
11411161
state=spanner_database_admin.Database.State.CREATING,
11421162
version_retention_period="version_retention_period_value",
1163+
default_leader="default_leader_value",
11431164
)
11441165
)
11451166
response = await client.get_database(request)
@@ -1154,6 +1175,7 @@ async def test_get_database_async(
11541175
assert response.name == "name_value"
11551176
assert response.state == spanner_database_admin.Database.State.CREATING
11561177
assert response.version_retention_period == "version_retention_period_value"
1178+
assert response.default_leader == "default_leader_value"
11571179

11581180

11591181
@pytest.mark.asyncio
@@ -5046,10 +5068,7 @@ def test_database_admin_grpc_transport_client_cert_source_for_mtls(transport_cla
50465068
"squid.clam.whelk:443",
50475069
credentials=cred,
50485070
credentials_file=None,
5049-
scopes=(
5050-
"https://www.googleapis.com/auth/cloud-platform",
5051-
"https://www.googleapis.com/auth/spanner.admin",
5052-
),
5071+
scopes=None,
50535072
ssl_credentials=mock_ssl_channel_creds,
50545073
quota_project_id=None,
50555074
options=[
@@ -5156,10 +5175,7 @@ def test_database_admin_transport_channel_mtls_with_client_cert_source(transport
51565175
"mtls.squid.clam.whelk:443",
51575176
credentials=cred,
51585177
credentials_file=None,
5159-
scopes=(
5160-
"https://www.googleapis.com/auth/cloud-platform",
5161-
"https://www.googleapis.com/auth/spanner.admin",
5162-
),
5178+
scopes=None,
51635179
ssl_credentials=mock_ssl_cred,
51645180
quota_project_id=None,
51655181
options=[
@@ -5206,10 +5222,7 @@ def test_database_admin_transport_channel_mtls_with_adc(transport_class):
52065222
"mtls.squid.clam.whelk:443",
52075223
credentials=mock_cred,
52085224
credentials_file=None,
5209-
scopes=(
5210-
"https://www.googleapis.com/auth/cloud-platform",
5211-
"https://www.googleapis.com/auth/spanner.admin",
5212-
),
5225+
scopes=None,
52135226
ssl_credentials=mock_ssl_cred,
52145227
quota_project_id=None,
52155228
options=[

0 commit comments

Comments
 (0)