Skip to content

Commit

Permalink
python: fix env var for TLS
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Gaikwad <[email protected]>
  • Loading branch information
gaikwadabhishek committed Aug 6, 2024
1 parent 5580f06 commit 0698ac2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/aistore/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
---

Expand Down
2 changes: 1 addition & 1 deletion python/aistore/sdk/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
4 changes: 2 additions & 2 deletions python/aistore/sdk/request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python/tests/unit/sdk/test_request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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):
Expand Down

0 comments on commit 0698ac2

Please sign in to comment.