@@ -334,6 +334,48 @@ def test_success_with_certificate_config(
334334 assert key == pytest .private_key_bytes
335335 assert passphrase is None
336336
337+ @mock .patch (
338+ "google.auth.transport._mtls_helper._read_cert_and_key_files" , autospec = True
339+ )
340+ @mock .patch (
341+ "google.auth.transport._mtls_helper._get_cert_config_path" , autospec = True
342+ )
343+ @mock .patch ("google.auth.transport._mtls_helper._load_json_file" , autospec = True )
344+ @mock .patch ("google.auth.transport._mtls_helper._check_config_path" , autospec = True )
345+ def test_success_with_certificate_config_cloud_run_patch (
346+ self ,
347+ mock_check_config_path ,
348+ mock_load_json_file ,
349+ mock_get_cert_config_path ,
350+ mock_read_cert_and_key_files ,
351+ ):
352+ cert_config_path = "/path/to/config"
353+ mock_check_config_path .return_value = cert_config_path
354+ mock_load_json_file .return_value = {
355+ "cert_configs" : {
356+ "workload" : {
357+ "cert_path" : _mtls_helper ._INCORRECT_CLOUD_RUN_CERT_PATH ,
358+ "key_path" : _mtls_helper ._INCORRECT_CLOUD_RUN_KEY_PATH ,
359+ }
360+ }
361+ }
362+ mock_get_cert_config_path .return_value = cert_config_path
363+ mock_read_cert_and_key_files .return_value = (
364+ pytest .public_cert_bytes ,
365+ pytest .private_key_bytes ,
366+ )
367+
368+ has_cert , cert , key , passphrase = _mtls_helper .get_client_ssl_credentials ()
369+ assert has_cert
370+ assert cert == pytest .public_cert_bytes
371+ assert key == pytest .private_key_bytes
372+ assert passphrase is None
373+
374+ mock_read_cert_and_key_files .assert_called_once_with (
375+ _mtls_helper ._WELL_KNOWN_CLOUD_RUN_CERT_PATH ,
376+ _mtls_helper ._WELL_KNOWN_CLOUD_RUN_KEY_PATH ,
377+ )
378+
337379 @mock .patch (
338380 "google.auth.transport._mtls_helper._get_workload_cert_and_key" , autospec = True
339381 )
0 commit comments