From 7379dde0f7b51c6b24f7ffd7c81f7285c7cc3d43 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Thu, 11 Jul 2024 14:46:43 -0700 Subject: [PATCH 01/10] feat(auth): Update get_client_ssl_credentials to support X.509 workload certs --- google/auth/transport/_mtls_helper.py | 36 +++++++++---- tests/transport/test__mtls_helper.py | 77 ++++++++++++++++++++------- 2 files changed, 84 insertions(+), 29 deletions(-) diff --git a/google/auth/transport/_mtls_helper.py b/google/auth/transport/_mtls_helper.py index 6299e2bde..4ecb0128d 100644 --- a/google/auth/transport/_mtls_helper.py +++ b/google/auth/transport/_mtls_helper.py @@ -48,21 +48,21 @@ ) -def _check_dca_metadata_path(metadata_path): - """Checks for context aware metadata. If it exists, returns the absolute path; +def _check_config_path(config_path): + """Checks for config file path. If it exists, returns the absolute path with user expansion; otherwise returns None. Args: - metadata_path (str): context aware metadata path. + config_path (str): The config file path for either context_aware_metadata.json or certificate_config.json for example Returns: str: absolute path if exists and None otherwise. """ - metadata_path = path.expanduser(metadata_path) - if not path.exists(metadata_path): - _LOGGER.debug("%s is not found, skip client SSL authentication.", metadata_path) + config_path = path.expanduser(config_path) + if not path.exists(config_path): + _LOGGER.debug("%s is not found.", config_path) return None - return metadata_path + return config_path def _load_json_file(path): @@ -279,14 +279,22 @@ def _run_cert_provider_command(command, expect_encrypted_key=False): def get_client_ssl_credentials( generate_encrypted_key=False, context_aware_metadata_path=CONTEXT_AWARE_METADATA_PATH, + certificate_config_path=_CERTIFICATE_CONFIGURATION_DEFAULT_PATH, ): """Returns the client side certificate, private key and passphrase. + We look for certificates and keys with the following order of priority: + 1. Certificate and key specified by certificate_config.json. + Currently, only X.509 workload certificates are supported. + 2. Certificate and key specified by context aware metadata (i.e. SecureConnect). + Args: generate_encrypted_key (bool): If set to True, encrypted private key and passphrase will be generated; otherwise, unencrypted private key - will be generated and passphrase will be None. + will be generated and passphrase will be None. This option only + affects keys obtained via context_aware_metadata.json. context_aware_metadata_path (str): The context_aware_metadata.json file path. + certificate_config_path (str): The certificate_config.json file path. Returns: Tuple[bool, bytes, bytes, bytes]: @@ -297,7 +305,17 @@ def get_client_ssl_credentials( google.auth.exceptions.ClientCertError: if problems occurs when getting the cert, key and passphrase. """ - metadata_path = _check_dca_metadata_path(context_aware_metadata_path) + + # 1. Check for certificate config json. + cert_config_path = _check_config_path(certificate_config_path) + if cert_config_path: + # Attempt to retrieve X.509 Workload cert and key. + cert, key = _get_workload_cert_and_key(cert_config_path) + if cert and key: + return True, cert, key, None + + # 2. Check for context aware metadata json + metadata_path = _check_config_path(context_aware_metadata_path) if metadata_path: metadata_json = _load_json_file(metadata_path) diff --git a/tests/transport/test__mtls_helper.py b/tests/transport/test__mtls_helper.py index b195616dd..4da2b4c42 100644 --- a/tests/transport/test__mtls_helper.py +++ b/tests/transport/test__mtls_helper.py @@ -111,15 +111,15 @@ def test_key(self): ) -class TestCheckaMetadataPath(object): +class TestCheckConfigPath(object): def test_success(self): metadata_path = os.path.join(pytest.data_dir, "context_aware_metadata.json") - returned_path = _mtls_helper._check_dca_metadata_path(metadata_path) + returned_path = _mtls_helper._check_config_path(metadata_path) assert returned_path is not None def test_failure(self): metadata_path = os.path.join(pytest.data_dir, "not_exists.json") - returned_path = _mtls_helper._check_dca_metadata_path(metadata_path) + returned_path = _mtls_helper._check_config_path(metadata_path) assert returned_path is None @@ -279,15 +279,15 @@ class TestGetClientSslCredentials(object): ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) - def test_success( + def test_success_with_context_aware_metadata( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_run_cert_provider_command, ): - mock_check_dca_metadata_path.return_value = True + mock_check_config_path.return_value = True mock_load_json_file.return_value = {"cert_provider_command": ["command"]} mock_run_cert_provider_command.return_value = (b"cert", b"key", None) has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials() @@ -297,10 +297,47 @@ def test_success( assert passphrase is None @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True + ) + @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) + @mock.patch( + "google.auth.transport._mtls_helper._get_cert_config_path", autospec=True + ) + @mock.patch( + "google.auth.transport._mtls_helper._read_cert_and_key_files", autospec=True + ) + def test_success_with_certificate_config( + self, + mock_check_config_path, + mock_load_json_file, + mock_get_cert_config_path, + mock_read_cert_and_key_files, + ): + cert_config_path = "/path/to/cert" + mock_check_config_path.return_value = True + mock_load_json_file.return_value = { + "cert_configs": { + "workload": {"cert_path": "cert/path", "key_path": "key/path"} + } + } + mock_get_cert_config_path.return_value = cert_config_path + mock_read_cert_and_key_files.return_value = ( + pytest.public_cert_bytes, + pytest.private_key_bytes, + ) + + has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials( + certificate_config_path=cert_config_path) + assert has_cert + assert cert == pytest.public_cert_bytes + assert key == pytest.private_key_bytes + assert passphrase is None + + @mock.patch( + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) - def test_success_without_metadata(self, mock_check_dca_metadata_path): - mock_check_dca_metadata_path.return_value = False + def test_success_without_metadata(self, mock_check_config_path): + mock_check_config_path.return_value = False has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials() assert not has_cert assert cert is None @@ -312,15 +349,15 @@ def test_success_without_metadata(self, mock_check_dca_metadata_path): ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_success_with_encrypted_key( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_run_cert_provider_command, ): - mock_check_dca_metadata_path.return_value = True + mock_check_config_path.return_value = True mock_load_json_file.return_value = {"cert_provider_command": ["command"]} mock_run_cert_provider_command.return_value = (b"cert", b"key", b"passphrase") has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials( @@ -336,12 +373,12 @@ def test_success_with_encrypted_key( @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_missing_cert_command( - self, mock_check_dca_metadata_path, mock_load_json_file + self, mock_check_config_path, mock_load_json_file ): - mock_check_dca_metadata_path.return_value = True + mock_check_config_path.return_value = True mock_load_json_file.return_value = {} with pytest.raises(exceptions.ClientCertError): _mtls_helper.get_client_ssl_credentials() @@ -351,16 +388,16 @@ def test_missing_cert_command( ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_customize_context_aware_metadata_path( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_run_cert_provider_command, ): context_aware_metadata_path = "/path/to/metata/data" - mock_check_dca_metadata_path.return_value = context_aware_metadata_path + mock_check_config_path.return_value = context_aware_metadata_path mock_load_json_file.return_value = {"cert_provider_command": ["command"]} mock_run_cert_provider_command.return_value = (b"cert", b"key", None) @@ -372,7 +409,7 @@ def test_customize_context_aware_metadata_path( assert cert == b"cert" assert key == b"key" assert passphrase is None - mock_check_dca_metadata_path.assert_called_with(context_aware_metadata_path) + mock_check_config_path.assert_called_with(context_aware_metadata_path) mock_load_json_file.assert_called_with(context_aware_metadata_path) From 62bd8f23c958ced4fefab7f3e720c3e241a42c45 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Thu, 11 Jul 2024 21:57:23 -0700 Subject: [PATCH 02/10] feat(auth): Update has_default_client_cert_source --- google/auth/transport/_mtls_helper.py | 6 +++--- google/auth/transport/mtls.py | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/google/auth/transport/_mtls_helper.py b/google/auth/transport/_mtls_helper.py index 4ecb0128d..68568dd60 100644 --- a/google/auth/transport/_mtls_helper.py +++ b/google/auth/transport/_mtls_helper.py @@ -23,7 +23,7 @@ from google.auth import exceptions CONTEXT_AWARE_METADATA_PATH = "~/.secureConnect/context_aware_metadata.json" -_CERTIFICATE_CONFIGURATION_DEFAULT_PATH = "~/.config/gcloud/certificate_config.json" +CERTIFICATE_CONFIGURATION_DEFAULT_PATH = "~/.config/gcloud/certificate_config.json" _CERTIFICATE_CONFIGURATION_ENV = "GOOGLE_API_CERTIFICATE_CONFIG" _CERT_PROVIDER_COMMAND = "cert_provider_command" _CERT_REGEX = re.compile( @@ -136,7 +136,7 @@ def _get_cert_config_path(certificate_config_path=None): if env_path is not None and env_path != "": certificate_config_path = env_path else: - certificate_config_path = _CERTIFICATE_CONFIGURATION_DEFAULT_PATH + certificate_config_path = CERTIFICATE_CONFIGURATION_DEFAULT_PATH certificate_config_path = path.expanduser(certificate_config_path) if not path.exists(certificate_config_path): @@ -279,7 +279,7 @@ def _run_cert_provider_command(command, expect_encrypted_key=False): def get_client_ssl_credentials( generate_encrypted_key=False, context_aware_metadata_path=CONTEXT_AWARE_METADATA_PATH, - certificate_config_path=_CERTIFICATE_CONFIGURATION_DEFAULT_PATH, + certificate_config_path=CERTIFICATE_CONFIGURATION_DEFAULT_PATH, ): """Returns the client side certificate, private key and passphrase. diff --git a/google/auth/transport/mtls.py b/google/auth/transport/mtls.py index c5707617f..67661cd82 100644 --- a/google/auth/transport/mtls.py +++ b/google/auth/transport/mtls.py @@ -24,10 +24,8 @@ def has_default_client_cert_source(): Returns: bool: indicating if the default client cert source exists. """ - metadata_path = _mtls_helper._check_dca_metadata_path( - _mtls_helper.CONTEXT_AWARE_METADATA_PATH - ) - return metadata_path is not None + return (_mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None) or + (_mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None) def default_client_cert_source(): From 2079d6887806ff026d52462fa140c816e8a09a82 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Thu, 11 Jul 2024 22:15:19 -0700 Subject: [PATCH 03/10] feat(auth): Fix formatting --- google/auth/transport/mtls.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/google/auth/transport/mtls.py b/google/auth/transport/mtls.py index 67661cd82..34bb96638 100644 --- a/google/auth/transport/mtls.py +++ b/google/auth/transport/mtls.py @@ -24,8 +24,15 @@ def has_default_client_cert_source(): Returns: bool: indicating if the default client cert source exists. """ - return (_mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None) or - (_mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None) + return ( + _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) + is not None + ) or ( + _mtls_helper._check_config_path( + _mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH + ) + is not None + ) def default_client_cert_source(): From 232000d5200a98c8f1417457f883f342a89fe79e Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Fri, 12 Jul 2024 15:30:12 -0700 Subject: [PATCH 04/10] feat(auth): Fix test__mtls_helper.py --- tests/transport/test__mtls_helper.py | 40 +++++++++++++++++++--------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tests/transport/test__mtls_helper.py b/tests/transport/test__mtls_helper.py index 4da2b4c42..39365369a 100644 --- a/tests/transport/test__mtls_helper.py +++ b/tests/transport/test__mtls_helper.py @@ -274,6 +274,9 @@ def test_popen_raise_exception(self, mock_popen): class TestGetClientSslCredentials(object): + @mock.patch( + "google.auth.transport._mtls_helper._get_workload_cert_and_key", autospec=True + ) @mock.patch( "google.auth.transport._mtls_helper._run_cert_provider_command", autospec=True ) @@ -286,10 +289,12 @@ def test_success_with_context_aware_metadata( mock_check_config_path, mock_load_json_file, mock_run_cert_provider_command, + mock_get_workload_cert_and_key, ): - mock_check_config_path.return_value = True + mock_check_config_path.return_value = "/path/to/config" mock_load_json_file.return_value = {"cert_provider_command": ["command"]} mock_run_cert_provider_command.return_value = (b"cert", b"key", None) + mock_get_workload_cert_and_key.return_value = (None, None) has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials() assert has_cert assert cert == b"cert" @@ -297,14 +302,14 @@ def test_success_with_context_aware_metadata( assert passphrase is None @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True + "google.auth.transport._mtls_helper._read_cert_and_key_files", autospec=True ) - @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( "google.auth.transport._mtls_helper._get_cert_config_path", autospec=True ) + @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._read_cert_and_key_files", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_success_with_certificate_config( self, @@ -313,8 +318,8 @@ def test_success_with_certificate_config( mock_get_cert_config_path, mock_read_cert_and_key_files, ): - cert_config_path = "/path/to/cert" - mock_check_config_path.return_value = True + cert_config_path = "/path/to/config" + mock_check_config_path.return_value = cert_config_path mock_load_json_file.return_value = { "cert_configs": { "workload": {"cert_path": "cert/path", "key_path": "key/path"} @@ -326,8 +331,7 @@ def test_success_with_certificate_config( pytest.private_key_bytes, ) - has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials( - certificate_config_path=cert_config_path) + has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials() assert has_cert assert cert == pytest.public_cert_bytes assert key == pytest.private_key_bytes @@ -344,6 +348,9 @@ def test_success_without_metadata(self, mock_check_config_path): assert key is None assert passphrase is None + @mock.patch( + "google.auth.transport._mtls_helper._get_workload_cert_and_key", autospec=True + ) @mock.patch( "google.auth.transport._mtls_helper._run_cert_provider_command", autospec=True ) @@ -356,10 +363,12 @@ def test_success_with_encrypted_key( mock_check_config_path, mock_load_json_file, mock_run_cert_provider_command, + mock_get_workload_cert_and_key, ): - mock_check_config_path.return_value = True + mock_check_config_path.return_value = "/path/to/config" mock_load_json_file.return_value = {"cert_provider_command": ["command"]} mock_run_cert_provider_command.return_value = (b"cert", b"key", b"passphrase") + mock_get_workload_cert_and_key.return_value = (None, None) has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials( generate_encrypted_key=True ) @@ -371,15 +380,22 @@ def test_success_with_encrypted_key( ["command", "--with_passphrase"], expect_encrypted_key=True ) + @mock.patch( + "google.auth.transport._mtls_helper._get_workload_cert_and_key", autospec=True + ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_missing_cert_command( - self, mock_check_config_path, mock_load_json_file + self, + mock_check_config_path, + mock_load_json_file, + mock_get_workload_cert_and_key, ): - mock_check_config_path.return_value = True + mock_check_config_path.return_value = "/path/to/config" mock_load_json_file.return_value = {} + mock_get_workload_cert_and_key.return_value = (None, None) with pytest.raises(exceptions.ClientCertError): _mtls_helper.get_client_ssl_credentials() @@ -557,7 +573,7 @@ def test_default(self, mock_path_exists): mock_path_exists.return_value = True returned_path = _mtls_helper._get_cert_config_path() expected_path = os.path.expanduser( - _mtls_helper._CERTIFICATE_CONFIGURATION_DEFAULT_PATH + _mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH ) assert returned_path == expected_path From 3e951e6aae331b5c02ce0b63b5492a69a05df238 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Fri, 12 Jul 2024 22:18:11 -0700 Subject: [PATCH 05/10] feat(auth): Fix function name in tests --- google/auth/transport/grpc.py | 2 +- tests/transport/test_grpc.py | 28 ++++++++++++++-------------- tests/transport/test_mtls.py | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/google/auth/transport/grpc.py b/google/auth/transport/grpc.py index 9a817976d..1ebe13795 100644 --- a/google/auth/transport/grpc.py +++ b/google/auth/transport/grpc.py @@ -302,7 +302,7 @@ def __init__(self): self._is_mtls = False else: # Load client SSL credentials. - metadata_path = _mtls_helper._check_dca_metadata_path( + metadata_path = _mtls_helper._check_config_path( _mtls_helper.CONTEXT_AWARE_METADATA_PATH ) self._is_mtls = metadata_path is not None diff --git a/tests/transport/test_grpc.py b/tests/transport/test_grpc.py index 433cc6855..dcdf91f06 100644 --- a/tests/transport/test_grpc.py +++ b/tests/transport/test_grpc.py @@ -143,11 +143,11 @@ def test__get_authorization_headers_with_service_account_and_default_host(self): class TestSecureAuthorizedChannel(object): @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_secure_authorized_channel_adc( self, - check_dca_metadata_path, + check_config_path, load_json_file, secure_channel, ssl_channel_credentials, @@ -161,7 +161,7 @@ def test_secure_authorized_channel_adc( # Mock the context aware metadata and client cert/key so mTLS SSL channel # will be used. - check_dca_metadata_path.return_value = METADATA_PATH + check_config_path.return_value = METADATA_PATH load_json_file.return_value = {"cert_provider_command": ["some command"]} get_client_ssl_credentials.return_value = ( True, @@ -332,11 +332,11 @@ def test_secure_authorized_channel_with_client_cert_callback_success( @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) def test_secure_authorized_channel_with_client_cert_callback_failure( self, - check_dca_metadata_path, + check_config_path, load_json_file, secure_channel, ssl_channel_credentials, @@ -401,18 +401,18 @@ def test_secure_authorized_channel_cert_callback_without_client_cert_env( ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) class TestSslCredentials(object): def test_no_context_aware_metadata( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_get_client_ssl_credentials, mock_ssl_channel_credentials, ): # Mock that the metadata file doesn't exist. - mock_check_dca_metadata_path.return_value = None + mock_check_config_path.return_value = None with mock.patch.dict( os.environ, {environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE: "true"} @@ -429,12 +429,12 @@ def test_no_context_aware_metadata( def test_get_client_ssl_credentials_failure( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_get_client_ssl_credentials, mock_ssl_channel_credentials, ): - mock_check_dca_metadata_path.return_value = METADATA_PATH + mock_check_config_path.return_value = METADATA_PATH mock_load_json_file.return_value = {"cert_provider_command": ["some command"]} # Mock that client cert and key are not loaded and exception is raised. @@ -448,12 +448,12 @@ def test_get_client_ssl_credentials_failure( def test_get_client_ssl_credentials_success( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_get_client_ssl_credentials, mock_ssl_channel_credentials, ): - mock_check_dca_metadata_path.return_value = METADATA_PATH + mock_check_config_path.return_value = METADATA_PATH mock_load_json_file.return_value = {"cert_provider_command": ["some command"]} mock_get_client_ssl_credentials.return_value = ( True, @@ -476,7 +476,7 @@ def test_get_client_ssl_credentials_success( def test_get_client_ssl_credentials_without_client_cert_env( self, - mock_check_dca_metadata_path, + mock_check_config_path, mock_load_json_file, mock_get_client_ssl_credentials, mock_ssl_channel_credentials, @@ -486,7 +486,7 @@ def test_get_client_ssl_credentials_without_client_cert_env( assert ssl_credentials.ssl_credentials is not None assert not ssl_credentials.is_mtls - mock_check_dca_metadata_path.assert_not_called() + mock_check_config_path.assert_not_called() mock_load_json_file.assert_not_called() mock_get_client_ssl_credentials.assert_not_called() mock_ssl_channel_credentials.assert_called_once() diff --git a/tests/transport/test_mtls.py b/tests/transport/test_mtls.py index b62063e47..e82520b41 100644 --- a/tests/transport/test_mtls.py +++ b/tests/transport/test_mtls.py @@ -20,13 +20,13 @@ @mock.patch( - "google.auth.transport._mtls_helper._check_dca_metadata_path", autospec=True + "google.auth.transport._mtls_helper._check_config_path", autospec=True ) -def test_has_default_client_cert_source(check_dca_metadata_path): - check_dca_metadata_path.return_value = mock.Mock() +def test_has_default_client_cert_source(check_config_path): + check_config_path.return_value = mock.Mock() assert mtls.has_default_client_cert_source() - check_dca_metadata_path.return_value = None + check_config_path.return_value = None assert not mtls.has_default_client_cert_source() From 1ff9d550c6dd5c9f1b7b677d7ddecc03e31a592a Mon Sep 17 00:00:00 2001 From: Carl Lundin Date: Tue, 30 Jul 2024 14:15:47 -0700 Subject: [PATCH 06/10] chore: Refresh system test creds. --- system_tests/secrets.tar.enc | Bin 10324 -> 10324 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/system_tests/secrets.tar.enc b/system_tests/secrets.tar.enc index ccb040256c0cf0e7e68c58b58536bc49bf81293d..ba7444e1df8e8d3fc1f51912ad4ef49d4ec5b07d 100644 GIT binary patch literal 10324 zcmV-aD67{BB>?tKRTEdEYGJTZ<>FTl(mkbszCMI9ylE@VNasIML}e%qA3zeSPylv+ ziVkJc%0}s*Ebc^*w;Ob}Qogu}1fYImvwUW1HY0ssfFm1(eWNvy?;s56pS2Q?o-*!T z8-soi@Q|V8D!Ub@sAw0}Wa1IB3Vhm0Z4X6CUp1G>RRH*IB!I$UWq{%^8C$3930c>0qK*EwF26j-0)9!ux9F`kH zoTJ3Gd)uo*&m)fF8{t{yF;2Vn!`H}((lp(Lbj^et-$13#gn8jpLZpPcHNwj)q=7Sw zG9OVWv~Q?i9VD|m$-D9qwyi5#U0n-e7@!B?8|#ZYrtyA!@RjQ&@N5Pi0aVKLa$QgX zkV`3zN(w-7!(fcdZQzjOdcqK{>f#m~!iS$xs63d4{{%QStO&re6yISbWm#6z-CJsw zbRw~geAoZFga^}oXX%;PD_3}jXmeXNcwhDY606Zr6DU}1n)7`)tH=qd_3!W-oRS7RAU8?r~)5Ek1N$@4wt-ha8#jnuLAx6 zSes9yuY@$Hn4fBBX8bQg>94LsPqoQMj+jjfud@(?aBhQALDHKpO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dfct??%b2mv z8^<>oEDIT568PYb94eqc0dnrOjcU!`kN1W$oeSs}&Tcpi&*nlZHj-vs0OuIgL6QedD2JTFpV+NbH>C=i8R!(uT%g$ z!5}{|jsc4|Z>fX(P50fw4@UX3`I5vZPyt=N2Z+c3Nsu2H8UJG@>>Ml?PT};8SBlq2 z(~~VSbr5_HiR=qY z9ZT++p&n^%fuVK=L4(bRQsaaoQ-Z~F)@JTU( zY$0gJM}R;#50DUq>K*)736npvya|fT6-4+Bzv`5xP{e|!;ifPsS}CGASXh4aV?MF`yW#P zF^#mpcMc`11QZrni$|{8fnePN=N0Ia0|1!Kqls16e+bWBWJ=Z5f`HQrtxMOYHBpa$}rH-S^#^^@WYu7ax? zx)02x@+j0uM;CN+X<_N-Q}k^)uRCmgbs9$4{(qoUd?iyoT`Ze&Ph9H4s0xi%mhO#6 zTm{ggll%!d8YWQrTX22mHZ2!fP6?)~ltN%J#^aLO%9K4)t;PNg_%5a}avKWdfDHu_ mKGal`NiOJ(dJyVdvx1Z1NIqTODvoU87-x;59NuORu>vk~-Uqh; From 7a628e6631418572cc8c757909f2bf7d2e2a38bb Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Tue, 30 Jul 2024 14:55:56 -0700 Subject: [PATCH 07/10] feat(auth): Fix style --- google/auth/transport/mtls.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/google/auth/transport/mtls.py b/google/auth/transport/mtls.py index 34bb96638..1ae9b52e0 100644 --- a/google/auth/transport/mtls.py +++ b/google/auth/transport/mtls.py @@ -24,15 +24,11 @@ def has_default_client_cert_source(): Returns: bool: indicating if the default client cert source exists. """ - return ( - _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) - is not None - ) or ( - _mtls_helper._check_config_path( - _mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH - ) - is not None - ) + if _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None: + return true + if _mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None: + return true + return false def default_client_cert_source(): From 94422121167379972e8df0e38ed88f4d431fc4ee Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Tue, 30 Jul 2024 15:21:14 -0700 Subject: [PATCH 08/10] feat(auth): Fix casing --- google/auth/transport/mtls.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google/auth/transport/mtls.py b/google/auth/transport/mtls.py index 1ae9b52e0..58061510a 100644 --- a/google/auth/transport/mtls.py +++ b/google/auth/transport/mtls.py @@ -25,10 +25,10 @@ def has_default_client_cert_source(): bool: indicating if the default client cert source exists. """ if _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None: - return true + return True if _mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None: - return true - return false + return True + return False def default_client_cert_source(): From 22592b49af5d1dd9e4319305cb7143b5b1eadfe2 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Wed, 7 Aug 2024 11:43:26 -0700 Subject: [PATCH 09/10] feat(auth): Fix linter issue --- google/auth/transport/mtls.py | 12 ++++++++++-- tests/transport/test__mtls_helper.py | 24 ++++++------------------ tests/transport/test_grpc.py | 12 +++--------- tests/transport/test_mtls.py | 4 +--- 4 files changed, 20 insertions(+), 32 deletions(-) diff --git a/google/auth/transport/mtls.py b/google/auth/transport/mtls.py index 58061510a..e7a7304f6 100644 --- a/google/auth/transport/mtls.py +++ b/google/auth/transport/mtls.py @@ -24,9 +24,17 @@ def has_default_client_cert_source(): Returns: bool: indicating if the default client cert source exists. """ - if _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None: + if ( + _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) + is not None + ): return True - if _mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None: + if ( + _mtls_helper._check_config_path( + _mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH + ) + is not None + ): return True return False diff --git a/tests/transport/test__mtls_helper.py b/tests/transport/test__mtls_helper.py index 39365369a..f6e20b726 100644 --- a/tests/transport/test__mtls_helper.py +++ b/tests/transport/test__mtls_helper.py @@ -281,9 +281,7 @@ class TestGetClientSslCredentials(object): "google.auth.transport._mtls_helper._run_cert_provider_command", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_success_with_context_aware_metadata( self, mock_check_config_path, @@ -308,9 +306,7 @@ def test_success_with_context_aware_metadata( "google.auth.transport._mtls_helper._get_cert_config_path", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_success_with_certificate_config( self, mock_check_config_path, @@ -337,9 +333,7 @@ def test_success_with_certificate_config( assert key == pytest.private_key_bytes assert passphrase is None - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_success_without_metadata(self, mock_check_config_path): mock_check_config_path.return_value = False has_cert, cert, key, passphrase = _mtls_helper.get_client_ssl_credentials() @@ -355,9 +349,7 @@ def test_success_without_metadata(self, mock_check_config_path): "google.auth.transport._mtls_helper._run_cert_provider_command", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_success_with_encrypted_key( self, mock_check_config_path, @@ -384,9 +376,7 @@ def test_success_with_encrypted_key( "google.auth.transport._mtls_helper._get_workload_cert_and_key", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_missing_cert_command( self, mock_check_config_path, @@ -403,9 +393,7 @@ def test_missing_cert_command( "google.auth.transport._mtls_helper._run_cert_provider_command", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_customize_context_aware_metadata_path( self, mock_check_config_path, diff --git a/tests/transport/test_grpc.py b/tests/transport/test_grpc.py index dcdf91f06..ed3f3ee83 100644 --- a/tests/transport/test_grpc.py +++ b/tests/transport/test_grpc.py @@ -142,9 +142,7 @@ def test__get_authorization_headers_with_service_account_and_default_host(self): @mock.patch("grpc.secure_channel", autospec=True) class TestSecureAuthorizedChannel(object): @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_secure_authorized_channel_adc( self, check_config_path, @@ -331,9 +329,7 @@ def test_secure_authorized_channel_with_client_cert_callback_success( ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) - @mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True - ) + @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_secure_authorized_channel_with_client_cert_callback_failure( self, check_config_path, @@ -400,9 +396,7 @@ def test_secure_authorized_channel_cert_callback_without_client_cert_env( "google.auth.transport._mtls_helper.get_client_ssl_credentials", autospec=True ) @mock.patch("google.auth.transport._mtls_helper._load_json_file", autospec=True) -@mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True -) +@mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) class TestSslCredentials(object): def test_no_context_aware_metadata( self, diff --git a/tests/transport/test_mtls.py b/tests/transport/test_mtls.py index e82520b41..e65f10737 100644 --- a/tests/transport/test_mtls.py +++ b/tests/transport/test_mtls.py @@ -19,9 +19,7 @@ from google.auth.transport import mtls -@mock.patch( - "google.auth.transport._mtls_helper._check_config_path", autospec=True -) +@mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_has_default_client_cert_source(check_config_path): check_config_path.return_value = mock.Mock() assert mtls.has_default_client_cert_source() From 7726727874d27122e12efd4556c8190891cc8738 Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Wed, 7 Aug 2024 14:52:43 -0700 Subject: [PATCH 10/10] feat(auth): Fix coverage issue --- tests/transport/test_mtls.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/transport/test_mtls.py b/tests/transport/test_mtls.py index e65f10737..ea549ae14 100644 --- a/tests/transport/test_mtls.py +++ b/tests/transport/test_mtls.py @@ -16,14 +16,29 @@ import pytest # type: ignore from google.auth import exceptions +from google.auth.transport import _mtls_helper from google.auth.transport import mtls @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) def test_has_default_client_cert_source(check_config_path): - check_config_path.return_value = mock.Mock() + def return_path_for_metadata(path): + return mock.Mock() if path == _mtls_helper.CONTEXT_AWARE_METADATA_PATH else None + + check_config_path.side_effect = return_path_for_metadata + assert mtls.has_default_client_cert_source() + + def return_path_for_cert_config(path): + return ( + mock.Mock() + if path == _mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH + else None + ) + + check_config_path.side_effect = return_path_for_cert_config assert mtls.has_default_client_cert_source() + check_config_path.side_effect = None check_config_path.return_value = None assert not mtls.has_default_client_cert_source()