Skip to content

Commit 9954e16

Browse files
committed
update goldens
1 parent fcf62d9 commit 9954e16

12 files changed

Lines changed: 84 additions & 72 deletions

File tree

packages/gapic-generator/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ def test_use_client_cert_effective():
244244
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
245245
# the GOOGLE_API_CONFIG environment variable is unset.
246246
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
247-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
247+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
248248
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
249-
assert AssetServiceClient._use_client_cert_effective() is False
249+
with mock.patch("os.path.exists", return_value=False):
250+
assert AssetServiceClient._use_client_cert_effective() is False
250251

251252
def test__get_client_cert_source():
252253
mock_provided_cert_source = mock.Mock()
@@ -650,7 +651,7 @@ def test_asset_service_client_get_mtls_endpoint_and_cert_source(client_class):
650651
config_filename = "mock_certificate_config.json"
651652
config_file_content = json.dumps(config_data)
652653
m = mock.mock_open(read_data=config_file_content)
653-
with mock.patch("builtins.open", m):
654+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
654655
with mock.patch.dict(
655656
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
656657
):
@@ -698,7 +699,7 @@ def test_asset_service_client_get_mtls_endpoint_and_cert_source(client_class):
698699
config_filename = "mock_certificate_config.json"
699700
config_file_content = json.dumps(config_data)
700701
m = mock.mock_open(read_data=config_file_content)
701-
with mock.patch("builtins.open", m):
702+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
702703
with mock.patch.dict(
703704
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
704705
):
@@ -714,13 +715,13 @@ def test_asset_service_client_get_mtls_endpoint_and_cert_source(client_class):
714715
assert cert_source is expected_cert_source
715716

716717
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
717-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
718+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
718719
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
719720
assert api_endpoint == client_class.DEFAULT_ENDPOINT
720721
assert cert_source is None
721722

722723
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
723-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
724+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
724725
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
725726
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
726727
assert cert_source is None

packages/gapic-generator/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ def test_use_client_cert_effective():
235235
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
236236
# the GOOGLE_API_CONFIG environment variable is unset.
237237
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
238-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
238+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
239239
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
240-
assert IAMCredentialsClient._use_client_cert_effective() is False
240+
with mock.patch("os.path.exists", return_value=False):
241+
assert IAMCredentialsClient._use_client_cert_effective() is False
241242

242243
def test__get_client_cert_source():
243244
mock_provided_cert_source = mock.Mock()
@@ -641,7 +642,7 @@ def test_iam_credentials_client_get_mtls_endpoint_and_cert_source(client_class):
641642
config_filename = "mock_certificate_config.json"
642643
config_file_content = json.dumps(config_data)
643644
m = mock.mock_open(read_data=config_file_content)
644-
with mock.patch("builtins.open", m):
645+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
645646
with mock.patch.dict(
646647
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
647648
):
@@ -689,7 +690,7 @@ def test_iam_credentials_client_get_mtls_endpoint_and_cert_source(client_class):
689690
config_filename = "mock_certificate_config.json"
690691
config_file_content = json.dumps(config_data)
691692
m = mock.mock_open(read_data=config_file_content)
692-
with mock.patch("builtins.open", m):
693+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
693694
with mock.patch.dict(
694695
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
695696
):
@@ -705,13 +706,13 @@ def test_iam_credentials_client_get_mtls_endpoint_and_cert_source(client_class):
705706
assert cert_source is expected_cert_source
706707

707708
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
708-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
709+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
709710
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
710711
assert api_endpoint == client_class.DEFAULT_ENDPOINT
711712
assert cert_source is None
712713

713714
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
714-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
715+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
715716
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
716717
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
717718
assert cert_source is None

packages/gapic-generator/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ def test_use_client_cert_effective():
263263
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
264264
# the GOOGLE_API_CONFIG environment variable is unset.
265265
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
266-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
266+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
267267
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
268-
assert EventarcClient._use_client_cert_effective() is False
268+
with mock.patch("os.path.exists", return_value=False):
269+
assert EventarcClient._use_client_cert_effective() is False
269270

270271
def test__get_client_cert_source():
271272
mock_provided_cert_source = mock.Mock()
@@ -669,7 +670,7 @@ def test_eventarc_client_get_mtls_endpoint_and_cert_source(client_class):
669670
config_filename = "mock_certificate_config.json"
670671
config_file_content = json.dumps(config_data)
671672
m = mock.mock_open(read_data=config_file_content)
672-
with mock.patch("builtins.open", m):
673+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
673674
with mock.patch.dict(
674675
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
675676
):
@@ -717,7 +718,7 @@ def test_eventarc_client_get_mtls_endpoint_and_cert_source(client_class):
717718
config_filename = "mock_certificate_config.json"
718719
config_file_content = json.dumps(config_data)
719720
m = mock.mock_open(read_data=config_file_content)
720-
with mock.patch("builtins.open", m):
721+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
721722
with mock.patch.dict(
722723
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
723724
):
@@ -733,13 +734,13 @@ def test_eventarc_client_get_mtls_endpoint_and_cert_source(client_class):
733734
assert cert_source is expected_cert_source
734735

735736
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
736-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
737+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
737738
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
738739
assert api_endpoint == client_class.DEFAULT_ENDPOINT
739740
assert cert_source is None
740741

741742
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
742-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
743+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
743744
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
744745
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
745746
assert cert_source is None

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_config_service_v2.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ def test_use_client_cert_effective():
236236
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
237237
# the GOOGLE_API_CONFIG environment variable is unset.
238238
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
239-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
239+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
240240
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
241-
assert ConfigServiceV2Client._use_client_cert_effective() is False
241+
with mock.patch("os.path.exists", return_value=False):
242+
assert ConfigServiceV2Client._use_client_cert_effective() is False
242243

243244
def test__get_client_cert_source():
244245
mock_provided_cert_source = mock.Mock()
@@ -629,7 +630,7 @@ def test_config_service_v2_client_get_mtls_endpoint_and_cert_source(client_class
629630
config_filename = "mock_certificate_config.json"
630631
config_file_content = json.dumps(config_data)
631632
m = mock.mock_open(read_data=config_file_content)
632-
with mock.patch("builtins.open", m):
633+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
633634
with mock.patch.dict(
634635
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
635636
):
@@ -677,7 +678,7 @@ def test_config_service_v2_client_get_mtls_endpoint_and_cert_source(client_class
677678
config_filename = "mock_certificate_config.json"
678679
config_file_content = json.dumps(config_data)
679680
m = mock.mock_open(read_data=config_file_content)
680-
with mock.patch("builtins.open", m):
681+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
681682
with mock.patch.dict(
682683
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
683684
):
@@ -693,13 +694,13 @@ def test_config_service_v2_client_get_mtls_endpoint_and_cert_source(client_class
693694
assert cert_source is expected_cert_source
694695

695696
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
696-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
697+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
697698
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
698699
assert api_endpoint == client_class.DEFAULT_ENDPOINT
699700
assert cert_source is None
700701

701702
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
702-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
703+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
703704
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
704705
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
705706
assert cert_source is None

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ def test_use_client_cert_effective():
231231
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
232232
# the GOOGLE_API_CONFIG environment variable is unset.
233233
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
234-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
234+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
235235
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
236-
assert LoggingServiceV2Client._use_client_cert_effective() is False
236+
with mock.patch("os.path.exists", return_value=False):
237+
assert LoggingServiceV2Client._use_client_cert_effective() is False
237238

238239
def test__get_client_cert_source():
239240
mock_provided_cert_source = mock.Mock()
@@ -624,7 +625,7 @@ def test_logging_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
624625
config_filename = "mock_certificate_config.json"
625626
config_file_content = json.dumps(config_data)
626627
m = mock.mock_open(read_data=config_file_content)
627-
with mock.patch("builtins.open", m):
628+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
628629
with mock.patch.dict(
629630
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
630631
):
@@ -672,7 +673,7 @@ def test_logging_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
672673
config_filename = "mock_certificate_config.json"
673674
config_file_content = json.dumps(config_data)
674675
m = mock.mock_open(read_data=config_file_content)
675-
with mock.patch("builtins.open", m):
676+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
676677
with mock.patch.dict(
677678
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
678679
):
@@ -688,13 +689,13 @@ def test_logging_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
688689
assert cert_source is expected_cert_source
689690

690691
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
691-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
692+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
692693
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
693694
assert api_endpoint == client_class.DEFAULT_ENDPOINT
694695
assert cert_source is None
695696

696697
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
697-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
698+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
698699
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
699700
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
700701
assert cert_source is None

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,10 @@ def test_use_client_cert_effective():
232232
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
233233
# the GOOGLE_API_CONFIG environment variable is unset.
234234
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
235-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
235+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
236236
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
237-
assert MetricsServiceV2Client._use_client_cert_effective() is False
237+
with mock.patch("os.path.exists", return_value=False):
238+
assert MetricsServiceV2Client._use_client_cert_effective() is False
238239

239240
def test__get_client_cert_source():
240241
mock_provided_cert_source = mock.Mock()
@@ -625,7 +626,7 @@ def test_metrics_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
625626
config_filename = "mock_certificate_config.json"
626627
config_file_content = json.dumps(config_data)
627628
m = mock.mock_open(read_data=config_file_content)
628-
with mock.patch("builtins.open", m):
629+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
629630
with mock.patch.dict(
630631
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
631632
):
@@ -673,7 +674,7 @@ def test_metrics_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
673674
config_filename = "mock_certificate_config.json"
674675
config_file_content = json.dumps(config_data)
675676
m = mock.mock_open(read_data=config_file_content)
676-
with mock.patch("builtins.open", m):
677+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
677678
with mock.patch.dict(
678679
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
679680
):
@@ -689,13 +690,13 @@ def test_metrics_service_v2_client_get_mtls_endpoint_and_cert_source(client_clas
689690
assert cert_source is expected_cert_source
690691

691692
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
692-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
693+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
693694
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
694695
assert api_endpoint == client_class.DEFAULT_ENDPOINT
695696
assert cert_source is None
696697

697698
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
698-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
699+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
699700
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
700701
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
701702
assert cert_source is None

0 commit comments

Comments
 (0)