aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest-localserver/py3/pytest_localserver/https.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-02-02 10:11:17 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-02-02 10:21:23 +0300
commit637f8bbf610e99859dfbdbde49d99e9c60a7acf7 (patch)
tree3e685433e89f53a34ca2a4635c29865598d12b4f /contrib/python/pytest-localserver/py3/pytest_localserver/https.py
parentbbd3eacdd0520f608b6290efdd0050d7e55ad40d (diff)
downloadydb-637f8bbf610e99859dfbdbde49d99e9c60a7acf7.tar.gz
Intermediate changes
commit_hash:20c3eb2f2d78b5f654ec928c071692413a1bd96d
Diffstat (limited to 'contrib/python/pytest-localserver/py3/pytest_localserver/https.py')
-rw-r--r--contrib/python/pytest-localserver/py3/pytest_localserver/https.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/contrib/python/pytest-localserver/py3/pytest_localserver/https.py b/contrib/python/pytest-localserver/py3/pytest_localserver/https.py
index 856e222ac5..7339211497 100644
--- a/contrib/python/pytest-localserver/py3/pytest_localserver/https.py
+++ b/contrib/python/pytest-localserver/py3/pytest_localserver/https.py
@@ -6,12 +6,13 @@ import os.path
from pytest_localserver.http import ContentServer
-#: default server certificate
-DEFAULT_CERTIFICATE = os.path.join(os.getcwd(), "server.pem")
+# default key and certificate
+_ROOT = os.getcwd()
+DEFAULT_KEY = os.path.join(_ROOT, "server.key")
+DEFAULT_CERTIFICATE = os.path.join(_ROOT, "cert.crt")
class SecureContentServer(ContentServer):
-
"""
Small test server which works just like :class:`http.Server` over HTTP::
@@ -111,13 +112,27 @@ class SecureContentServer(ContentServer):
.. _pyOpenSSH: https://launchpad.net/pyopenssl
"""
- def __init__(self, host="localhost", port=0, key=DEFAULT_CERTIFICATE, cert=DEFAULT_CERTIFICATE):
+ def __init__(self, host="localhost", port=0, key=DEFAULT_KEY, cert=DEFAULT_CERTIFICATE):
"""
:param key: location of file containing the server private key.
:param cert: location of file containing server certificate.
"""
- super().__init__(host, port, ssl_context=(key, cert))
+ super().__init__(host, port, ssl_context=(cert, key))
+ self._cert = cert
+
+ @property
+ def certificate(self):
+ """
+ Returns the path to the server's SSL/TLS certificate file.
+ Clients can use this path to access and verify the server's identity by
+ incorporating the certificate.
+
+ .. note::
+ Do not rely on having a stable filesystem path for the returned
+ certificate path across different versions or test runs.
+ """
+ return self._cert
if __name__ == "__main__": # pragma: no cover