From da94125827be55142794a77f57c67dcd302fede3 Mon Sep 17 00:00:00 2001 From: Yorick van Zweeden Date: Thu, 5 Mar 2020 12:01:36 +0100 Subject: [PATCH 1/4] Remove added parent directory from certs path --- betfairlightweight/baseclient.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/betfairlightweight/baseclient.py b/betfairlightweight/baseclient.py index 50d0f8c3..35680949 100644 --- a/betfairlightweight/baseclient.py +++ b/betfairlightweight/baseclient.py @@ -156,9 +156,8 @@ def cert(self) -> list: return self.cert_files certs = self.certs or "/certs/" - ssl_path = os.path.join(os.pardir, certs) try: - cert_path = os.listdir(ssl_path) + cert_path = os.listdir(certs) except FileNotFoundError as e: raise CertsError(str(e)) From ea9e7c20fd82f19e78e2958530610ad57e2d10d2 Mon Sep 17 00:00:00 2001 From: Yorick van Zweeden Date: Thu, 5 Mar 2020 12:05:46 +0100 Subject: [PATCH 2/4] Rename ssl_path to cert_path --- betfairlightweight/baseclient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/betfairlightweight/baseclient.py b/betfairlightweight/baseclient.py index 35680949..b38d5c30 100644 --- a/betfairlightweight/baseclient.py +++ b/betfairlightweight/baseclient.py @@ -166,13 +166,13 @@ def cert(self) -> list: for file in cert_path: ext = os.path.splitext(file)[-1] if ext in [".crt", ".cert"]: - cert = os.path.join(ssl_path, file) + cert = os.path.join(cert_path, file) elif ext == ".key": - key = os.path.join(ssl_path, file) + key = os.path.join(cert_path, file) if cert is None or key is None: raise CertsError( "Certificates not found in directory: '%s' (make sure .crt and .key file is present)" - % ssl_path + % cert_path ) return [cert, key] From 8ed4a5f5ab9ce72e0d8f742c9969c506095fca1b Mon Sep 17 00:00:00 2001 From: Yorick van Zweeden Date: Thu, 5 Mar 2020 12:14:31 +0100 Subject: [PATCH 3/4] Rename ssl_path to cert_path --- betfairlightweight/baseclient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/betfairlightweight/baseclient.py b/betfairlightweight/baseclient.py index b38d5c30..b0dc3d5d 100644 --- a/betfairlightweight/baseclient.py +++ b/betfairlightweight/baseclient.py @@ -166,13 +166,13 @@ def cert(self) -> list: for file in cert_path: ext = os.path.splitext(file)[-1] if ext in [".crt", ".cert"]: - cert = os.path.join(cert_path, file) + cert = os.path.join(certs, file) elif ext == ".key": - key = os.path.join(cert_path, file) + key = os.path.join(certs, file) if cert is None or key is None: raise CertsError( "Certificates not found in directory: '%s' (make sure .crt and .key file is present)" - % cert_path + % certs ) return [cert, key] From 94a90171cbeac245e8aff823673c37dec77423c2 Mon Sep 17 00:00:00 2001 From: Yorick van Zweeden Date: Thu, 5 Mar 2020 12:20:36 +0100 Subject: [PATCH 4/4] Fix test with relative path --- tests/unit/test_baseclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_baseclient.py b/tests/unit/test_baseclient.py index 15de81b2..92558f56 100644 --- a/tests/unit/test_baseclient.py +++ b/tests/unit/test_baseclient.py @@ -199,7 +199,7 @@ def test_client_certs_mocked(self, mock_listdir): [".DS_Store", "client-2048.crt", "client-2048.key"] ) assert self.client.cert == normpaths( - ["../fail/client-2048.crt", "../fail/client-2048.key"] + ["fail/client-2048.crt", "fail/client-2048.key"] )