From 0698ac2b37bc7d1acc65d6b9b360667b86da66d7 Mon Sep 17 00:00:00 2001 From: Abhishek Gaikwad Date: Mon, 5 Aug 2024 17:54:00 -0700 Subject: [PATCH] python: fix env var for TLS Signed-off-by: Abhishek Gaikwad --- python/aistore/sdk/README.md | 2 +- python/aistore/sdk/const.py | 2 +- python/aistore/sdk/request_client.py | 4 ++-- python/tests/unit/sdk/test_request_client.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/aistore/sdk/README.md b/python/aistore/sdk/README.md index 1c198093d81..6db5d9ce51d 100644 --- a/python/aistore/sdk/README.md +++ b/python/aistore/sdk/README.md @@ -99,7 +99,7 @@ The SDK supports HTTPS connectivity if the AIS cluster is configured to use HTTP - Pass an argument to the path of the certificate when creating the client: - `client = Client(ca_cert=/path/to/cert)` - Use the environment variable - - Set `AIS_SERVER_CRT` to the path of your certificate before initializing the client + - Set `AIS_CLIENT_CA` to the path of your certificate before initializing the client - If your AIS cluster is using a certificate signed by a trusted CA, the client will default to using verification without needing to provide a CA cert. --- diff --git a/python/aistore/sdk/const.py b/python/aistore/sdk/const.py index a2590c0b8f4..2faf60efc54 100644 --- a/python/aistore/sdk/const.py +++ b/python/aistore/sdk/const.py @@ -138,7 +138,7 @@ STATUS_PARTIAL_CONTENT = 206 # Environment Variables -AIS_SERVER_CRT = "AIS_SERVER_CRT" +AIS_CLIENT_CA = "AIS_CLIENT_CA" # Content Constants LOREM = ( diff --git a/python/aistore/sdk/request_client.py b/python/aistore/sdk/request_client.py index 17991507654..7a03523893d 100644 --- a/python/aistore/sdk/request_client.py +++ b/python/aistore/sdk/request_client.py @@ -11,7 +11,7 @@ HEADER_USER_AGENT, USER_AGENT_BASE, HEADER_CONTENT_TYPE, - AIS_SERVER_CRT, + AIS_CLIENT_CA, HEADER_AUTHORIZATION, ) from aistore.sdk.utils import handle_errors, decode_response @@ -78,7 +78,7 @@ def _set_session_verification(self, request_session: Session): if self._ca_cert: request_session.verify = self._ca_cert return - env_crt = os.getenv(AIS_SERVER_CRT) + env_crt = os.getenv(AIS_CLIENT_CA) request_session.verify = env_crt if env_crt else True @property diff --git a/python/tests/unit/sdk/test_request_client.py b/python/tests/unit/sdk/test_request_client.py index 0e30c0a5651..4b9ea69799f 100644 --- a/python/tests/unit/sdk/test_request_client.py +++ b/python/tests/unit/sdk/test_request_client.py @@ -8,7 +8,7 @@ HEADER_USER_AGENT, USER_AGENT_BASE, HEADER_CONTENT_TYPE, - AIS_SERVER_CRT, + AIS_CLIENT_CA, ) from aistore.sdk.request_client import RequestClient from aistore.version import __version__ as sdk_version @@ -35,7 +35,7 @@ def test_default_session(self): "aistore.sdk.request_client.os.getenv", return_value=None ) as mock_getenv: self.request_client = RequestClient(self.endpoint) - mock_getenv.assert_called_with(AIS_SERVER_CRT) + mock_getenv.assert_called_with(AIS_CLIENT_CA) self.assertEqual(True, self.request_client.session.verify) @test_cases( @@ -54,7 +54,7 @@ def test_session(self, test_case): self.endpoint, skip_verify=skip_verify, ca_cert=arg_cert ) if not skip_verify and not arg_cert: - mock_getenv.assert_called_with(AIS_SERVER_CRT) + mock_getenv.assert_called_with(AIS_CLIENT_CA) self.assertEqual(test_case[1], self.request_client.session.verify) def test_properties(self):