Skip to content

Commit

Permalink
Update TLS test with pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
Tronic committed Nov 15, 2023
1 parent 340fea7 commit cc29f01
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions tests/test_tls.py
@@ -1,5 +1,4 @@
import logging
import os
import ssl
import subprocess
import sys
Expand Down Expand Up @@ -32,18 +31,18 @@
from sanic.worker.loader import CertLoader


current_dir = os.path.dirname(os.path.realpath(__file__))
localhost_dir = os.path.join(current_dir, "certs/localhost")
password_dir = os.path.join(current_dir, "certs/password")
sanic_dir = os.path.join(current_dir, "certs/sanic.example")
invalid_dir = os.path.join(current_dir, "certs/invalid.nonexist")
localhost_cert = os.path.join(localhost_dir, "fullchain.pem")
localhost_key = os.path.join(localhost_dir, "privkey.pem")
sanic_cert = os.path.join(sanic_dir, "fullchain.pem")
sanic_key = os.path.join(sanic_dir, "privkey.pem")
current_dir = Path(__file__).parent.resolve()
localhost_dir = current_dir / "certs/localhost"
password_dir = current_dir / "certs/password"
sanic_dir = current_dir / "certs/sanic.example"
invalid_dir = current_dir / "certs/invalid.nonexist"
localhost_cert = localhost_dir / "fullchain.pem"
localhost_key = localhost_dir / "privkey.pem"
sanic_cert = sanic_dir / "fullchain.pem"
sanic_key = sanic_dir / "privkey.pem"
password_dict = {
"cert": os.path.join(password_dir, "fullchain.pem"),
"key": os.path.join(password_dir, "privkey.pem"),
"cert": password_dir / "fullchain.pem",
"key": password_dir / "privkey.pem",
"password": "password",
"names": ["localhost"],
}
Expand Down Expand Up @@ -383,7 +382,7 @@ async def handler(request):
app.test_client.get("/test", server_kwargs={"ssl": ssl_list})

assert "folder expected" in str(excinfo.value)
assert sanic_cert in str(excinfo.value)
assert str(sanic_cert) in str(excinfo.value)


def test_missing_cert_path(app):
Expand Down

0 comments on commit cc29f01

Please sign in to comment.