Skip to content

Commit e9a6ac5

Browse files
feat: enable self signed jwt for http (#1000)
1 parent 2b93783 commit e9a6ac5

File tree

8 files changed

+7
-46
lines changed
  • packages/gapic-generator
    • gapic/templates
    • tests/integration/goldens
      • asset/google/cloud/asset_v1/services/asset_service
      • credentials/google/iam/credentials_v1/services/iam_credentials
      • logging/google/cloud/logging_v2/services
      • redis/google/cloud/redis_v1/services/cloud_redis

8 files changed

+7
-46
lines changed

packages/gapic-generator/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
305305
quota_project_id=client_options.quota_project_id,
306306
client_info=client_info,
307307
{% if "grpc" in opts.transport %}
308-
always_use_jwt_access=(
309-
Transport == type(self).get_transport_class("grpc")
310-
or Transport == type(self).get_transport_class("grpc_asyncio")
311-
),
308+
always_use_jwt_access=True,
312309
{% endif %}
313310
)
314311

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
208208
client_cert_source_for_mtls=None,
209209
quota_project_id=None,
210210
client_info=transports.base.DEFAULT_CLIENT_INFO,
211-
{% if 'grpc' in opts.transport %}
212211
always_use_jwt_access=True,
213-
{% endif %}
214212
)
215213

216214
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -227,9 +225,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
227225
client_cert_source_for_mtls=None,
228226
quota_project_id=None,
229227
client_info=transports.base.DEFAULT_CLIENT_INFO,
230-
{% if 'grpc' in opts.transport %}
231228
always_use_jwt_access=True,
232-
{% endif %}
233229
)
234230

235231
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -246,9 +242,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
246242
client_cert_source_for_mtls=None,
247243
quota_project_id=None,
248244
client_info=transports.base.DEFAULT_CLIENT_INFO,
249-
{% if 'grpc' in opts.transport %}
250245
always_use_jwt_access=True,
251-
{% endif %}
252246
)
253247

254248
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -275,9 +269,7 @@ def test_{{ service.client_name|snake_case }}_client_options(client_class, trans
275269
client_cert_source_for_mtls=None,
276270
quota_project_id="octopus",
277271
client_info=transports.base.DEFAULT_CLIENT_INFO,
278-
{% if 'grpc' in opts.transport %}
279272
always_use_jwt_access=True,
280-
{% endif %}
281273
)
282274

283275
@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [
@@ -323,9 +315,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
323315
client_cert_source_for_mtls=expected_client_cert_source,
324316
quota_project_id=None,
325317
client_info=transports.base.DEFAULT_CLIENT_INFO,
326-
{% if 'grpc' in opts.transport %}
327318
always_use_jwt_access=True,
328-
{% endif %}
329319
)
330320

331321
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -351,9 +341,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
351341
client_cert_source_for_mtls=expected_client_cert_source,
352342
quota_project_id=None,
353343
client_info=transports.base.DEFAULT_CLIENT_INFO,
354-
{% if 'grpc' in opts.transport %}
355344
always_use_jwt_access=True,
356-
{% endif %}
357345
)
358346

359347
# Check the case client_cert_source and ADC client cert are not provided.
@@ -370,9 +358,7 @@ def test_{{ service.client_name|snake_case }}_mtls_env_auto(client_class, transp
370358
client_cert_source_for_mtls=None,
371359
quota_project_id=None,
372360
client_info=transports.base.DEFAULT_CLIENT_INFO,
373-
{% if 'grpc' in opts.transport %}
374361
always_use_jwt_access=True,
375-
{% endif %}
376362
)
377363

378364

@@ -400,9 +386,7 @@ def test_{{ service.client_name|snake_case }}_client_options_scopes(client_class
400386
client_cert_source_for_mtls=None,
401387
quota_project_id=None,
402388
client_info=transports.base.DEFAULT_CLIENT_INFO,
403-
{% if 'grpc' in opts.transport %}
404389
always_use_jwt_access=True,
405-
{% endif %}
406390
)
407391

408392
@pytest.mark.parametrize("client_class,transport_class,transport_name", [
@@ -429,9 +413,7 @@ def test_{{ service.client_name|snake_case }}_client_options_credentials_file(cl
429413
client_cert_source_for_mtls=None,
430414
quota_project_id=None,
431415
client_info=transports.base.DEFAULT_CLIENT_INFO,
432-
{% if 'grpc' in opts.transport %}
433416
always_use_jwt_access=True,
434-
{% endif %}
435417
)
436418
{% if 'grpc' in opts.transport %}
437419

packages/gapic-generator/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,7 @@ def __init__(self, *,
344344
client_cert_source_for_mtls=client_cert_source_func,
345345
quota_project_id=client_options.quota_project_id,
346346
client_info=client_info,
347-
always_use_jwt_access=(
348-
Transport == type(self).get_transport_class("grpc")
349-
or Transport == type(self).get_transport_class("grpc_asyncio")
350-
),
347+
always_use_jwt_access=True,
351348
)
352349

353350
def export_assets(self,

packages/gapic-generator/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,7 @@ def __init__(self, *,
340340
client_cert_source_for_mtls=client_cert_source_func,
341341
quota_project_id=client_options.quota_project_id,
342342
client_info=client_info,
343-
always_use_jwt_access=(
344-
Transport == type(self).get_transport_class("grpc")
345-
or Transport == type(self).get_transport_class("grpc_asyncio")
346-
),
343+
always_use_jwt_access=True,
347344
)
348345

349346
def generate_access_token(self,

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,7 @@ def __init__(self, *,
375375
client_cert_source_for_mtls=client_cert_source_func,
376376
quota_project_id=client_options.quota_project_id,
377377
client_info=client_info,
378-
always_use_jwt_access=(
379-
Transport == type(self).get_transport_class("grpc")
380-
or Transport == type(self).get_transport_class("grpc_asyncio")
381-
),
378+
always_use_jwt_access=True,
382379
)
383380

384381
def list_buckets(self,

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/logging_service_v2/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ def __init__(self, *,
331331
client_cert_source_for_mtls=client_cert_source_func,
332332
quota_project_id=client_options.quota_project_id,
333333
client_info=client_info,
334-
always_use_jwt_access=(
335-
Transport == type(self).get_transport_class("grpc")
336-
or Transport == type(self).get_transport_class("grpc_asyncio")
337-
),
334+
always_use_jwt_access=True,
338335
)
339336

340337
def delete_log(self,

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/metrics_service_v2/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,7 @@ def __init__(self, *,
332332
client_cert_source_for_mtls=client_cert_source_func,
333333
quota_project_id=client_options.quota_project_id,
334334
client_info=client_info,
335-
always_use_jwt_access=(
336-
Transport == type(self).get_transport_class("grpc")
337-
or Transport == type(self).get_transport_class("grpc_asyncio")
338-
),
335+
always_use_jwt_access=True,
339336
)
340337

341338
def list_log_metrics(self,

packages/gapic-generator/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,7 @@ def __init__(self, *,
355355
client_cert_source_for_mtls=client_cert_source_func,
356356
quota_project_id=client_options.quota_project_id,
357357
client_info=client_info,
358-
always_use_jwt_access=(
359-
Transport == type(self).get_transport_class("grpc")
360-
or Transport == type(self).get_transport_class("grpc_asyncio")
361-
),
358+
always_use_jwt_access=True,
362359
)
363360

364361
def list_instances(self,

0 commit comments

Comments
 (0)