Skip to content

Commit fcf62d9

Browse files
committed
update goldens
1 parent 0547563 commit fcf62d9

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ def test_use_client_cert_effective():
280280
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
281281
# the GOOGLE_API_CONFIG environment variable is unset.
282282
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
283-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
283+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": ""}):
284284
with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
285-
assert {{ service.client_name }}._use_client_cert_effective() is False
285+
with mock.patch("os.path.exists", return_value=False):
286+
assert {{ service.client_name }}._use_client_cert_effective() is False
286287

287288
def test__get_client_cert_source():
288289
mock_provided_cert_source = mock.Mock()
@@ -775,7 +776,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
775776
config_filename = "mock_certificate_config.json"
776777
config_file_content = json.dumps(config_data)
777778
m = mock.mock_open(read_data=config_file_content)
778-
with mock.patch("builtins.open", m):
779+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
779780
with mock.patch.dict(
780781
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
781782
):
@@ -823,7 +824,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
823824
config_filename = "mock_certificate_config.json"
824825
config_file_content = json.dumps(config_data)
825826
m = mock.mock_open(read_data=config_file_content)
826-
with mock.patch("builtins.open", m):
827+
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
827828
with mock.patch.dict(
828829
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
829830
):
@@ -839,13 +840,13 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
839840
assert cert_source is expected_cert_source
840841

841842
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
842-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
843+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
843844
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
844845
assert api_endpoint == client_class.DEFAULT_ENDPOINT
845846
assert cert_source is None
846847

847848
# Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
848-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
849+
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
849850
api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
850851
assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
851852
assert cert_source is None

0 commit comments

Comments
 (0)