Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove added parent directory from certs path #281

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions betfairlightweight/baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ def cert(self) -> list:
return self.cert_files

certs = self.certs or "/certs/"
Copy link
Member

@liampauling liampauling Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that maybe we should update the class initialisation as well and remove this line and replace with in the init:

certs: str = os.path.join(“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))

Expand All @@ -167,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(certs, file)
elif ext == ".key":
key = os.path.join(ssl_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)"
% ssl_path
% certs
)
return [cert, key]

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_client_certs_mocked(self, mock_listdir):
[".DS_Store", "client-2048.crt", "client-2048.key"]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add another test that confirms that certs=“/tmp” is correct

assert self.client.cert == normpaths(
["../fail/client-2048.crt", "../fail/client-2048.key"]
["fail/client-2048.crt", "fail/client-2048.key"]
)


Expand Down