Browse Source

Intermediate changes
commit_hash:20c3eb2f2d78b5f654ec928c071692413a1bd96d

robot-piglet 1 month ago
parent
commit
637f8bbf61

+ 10 - 4
contrib/python/pytest-localserver/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-localserver
-Version: 0.8.1
+Version: 0.9.0.post0
 Summary: pytest plugin to test server connections locally.
 Home-page: https://github.com/pytest-dev/pytest-localserver
 Author: Sebastian Rahlf
@@ -16,7 +16,6 @@ Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3 :: Only
-Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
 Classifier: Programming Language :: Python :: 3.8
@@ -24,8 +23,9 @@ Classifier: Programming Language :: Python :: 3.9
 Classifier: Programming Language :: Python :: 3.10
 Classifier: Programming Language :: Python :: 3.11
 Classifier: Programming Language :: Python :: 3.12
+Classifier: Programming Language :: Python :: 3.13
 Classifier: Topic :: Software Development :: Testing
-Requires-Python: >=3.5
+Requires-Python: >=3.6
 License-File: LICENSE
 License-File: AUTHORS
 Requires-Dist: werkzeug >=0.10
@@ -125,12 +125,13 @@ poking around in the code itself.
     * ``content`` - content of next response (str, bytes, or iterable of either)
     * ``headers`` - response headers (dict)
     * ``chunked`` - whether to chunk-encode the response (enumeration)
+    * ``store_request_data`` - whether to store request data for later use
 
     Once these attributes are set, all subsequent requests will be answered with
     these values until they are changed or the server is stopped. A more
     convenient way to change these is ::
 
-        httpserver.serve_content(content=None, code=200, headers=None, chunked=pytest_localserver.http.Chunked.NO)
+        httpserver.serve_content(content=None, code=200, headers=None, chunked=pytest_localserver.http.Chunked.NO, store_request_data=True)
 
     The ``chunked`` attribute or parameter can be set to
 
@@ -142,6 +143,11 @@ poking around in the code itself.
     If chunk encoding is applied, each str or bytes in ``content`` becomes one
     chunk in the response.
 
+    You can use ``store_request_data=False`` to disable loading the request data into
+    memory. This will make it impossible to check the request data using
+    ``httpserver.requests[index].data`` but may make sense when posting a larger amount of
+    data and you don't need to check this.
+
     The server address can be found in property
 
     * ``url``

+ 3 - 0
contrib/python/pytest-localserver/py3/AUTHORS

@@ -14,3 +14,6 @@ Hasan Ramezani <hasan.r67@gmail.com>
 Felix Yan <felixonmars@archlinux.org>
 Henri Hulski <henri.hulski@gazeta.pl>
 Theodore Ni
+Nicola Coretti <nico.coretti@gmail.com>
+Alissa Gerhard <alissa.gerhard@jonasundderwolf.de>
+Raphael Boidol <boidolr@users.noreply.github.com>

+ 7 - 1
contrib/python/pytest-localserver/py3/README.rst

@@ -91,12 +91,13 @@ poking around in the code itself.
     * ``content`` - content of next response (str, bytes, or iterable of either)
     * ``headers`` - response headers (dict)
     * ``chunked`` - whether to chunk-encode the response (enumeration)
+    * ``store_request_data`` - whether to store request data for later use
 
     Once these attributes are set, all subsequent requests will be answered with
     these values until they are changed or the server is stopped. A more
     convenient way to change these is ::
 
-        httpserver.serve_content(content=None, code=200, headers=None, chunked=pytest_localserver.http.Chunked.NO)
+        httpserver.serve_content(content=None, code=200, headers=None, chunked=pytest_localserver.http.Chunked.NO, store_request_data=True)
 
     The ``chunked`` attribute or parameter can be set to
 
@@ -108,6 +109,11 @@ poking around in the code itself.
     If chunk encoding is applied, each str or bytes in ``content`` becomes one
     chunk in the response.
 
+    You can use ``store_request_data=False`` to disable loading the request data into
+    memory. This will make it impossible to check the request data using
+    ``httpserver.requests[index].data`` but may make sense when posting a larger amount of
+    data and you don't need to check this.
+
     The server address can be found in property
 
     * ``url``

+ 6 - 4
contrib/python/pytest-localserver/py3/patches/01-arcadia.patch

@@ -1,8 +1,8 @@
 --- contrib/python/pytest-localserver/py3/pytest_localserver/https.py	(index)
 +++ contrib/python/pytest-localserver/py3/pytest_localserver/https.py	(working tree)
 @@ -10,1 +10,1 @@ import os.path
--DEFAULT_CERTIFICATE = os.path.join(os.path.abspath(os.path.dirname(__file__)), "server.pem")
-+DEFAULT_CERTIFICATE = os.path.join(os.getcwd(), "server.pem")
+-_ROOT = os.path.abspath(os.path.dirname(__file__))
++_ROOT = os.getcwd()
 --- contrib/python/pytest-localserver/py3/pytest_localserver/plugin.py	(index)
 +++ contrib/python/pytest-localserver/py3/pytest_localserver/plugin.py	(working tree)
 @@ -4,6 +4,9 @@
@@ -15,7 +15,7 @@
  import pytest
  
  
-@@ -62,11 +65,15 @@ def httpsserver(request):
+@@ -62,11 +65,17 @@ def httpsserver(request):
      SSL encryption.
      """
      from pytest_localserver import https
@@ -25,8 +25,10 @@
 -    request.addfinalizer(server.stop)
 -    return server
 +    try:
++        with open(https.DEFAULT_KEY, 'wb') as f:
++            f.write(pkgutil.get_data('pytest_localserver', 'server.key'))
 +        with open(https.DEFAULT_CERTIFICATE, 'wb') as f:
-+            f.write(pkgutil.get_data('pytest_localserver', 'server.pem'))
++            f.write(pkgutil.get_data('pytest_localserver', 'cert.crt'))
 +        server = https.SecureContentServer()
 +        server.start()
 +        request.addfinalizer(server.stop)

+ 2 - 2
contrib/python/pytest-localserver/py3/pytest_localserver/_version.py

@@ -12,5 +12,5 @@ __version__: str
 __version_tuple__: VERSION_TUPLE
 version_tuple: VERSION_TUPLE
 
-__version__ = version = '0.8.1'
-__version_tuple__ = version_tuple = (0, 8, 1)
+__version__ = version = '0.9.0.post0'
+__version_tuple__ = version_tuple = (0, 9, 0)

+ 32 - 0
contrib/python/pytest-localserver/py3/pytest_localserver/cert.crt

@@ -0,0 +1,32 @@
+-----BEGIN CERTIFICATE-----
+MIIFjzCCA3egAwIBAgIUPaO7CEh5PBQ5WVK10+B+NgkyBv0wDQYJKoZIhvcNAQEL
+BQAwSTESMBAGA1UEAwwJMTI3LjAuMC4xMRswGQYDVQQKDBJweXRlc3QtbG9jYWxz
+ZXJ2ZXIxFjAUBgNVBAsMDVRlc3RpbmcgRGVwdC4wHhcNMjQwMjIwMTQzNTIxWhcN
+MzQwMjE3MTQzNTIxWjB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WjPOkM7nfoSQd+QrbB
+uUxghFHHPbH7opHCPky0pK/+Wvwa+76lUaEnsC4gMOnO5U79BTT+EeFD1L9gQ6jZ
+LixdAaq2iq+4m7MJSkx1gyjwpH/xIaL0Vqh1A8qRlZNppMJ0ccIGK+UuZv3rNnRi
+BP0BRSpdH0WrposQWd+yOtac5bvLH4dnPUkk386e+H46HiGvmusDlUW0oD2TItn5
+fYofeaC1RDrbWRUOLgeKvda5vI1aH2p0asZu+MtUjkpENQKi2CieKCFh2wYTJdJT
+/aFuoeXzPLBgBiOc6SSg/RGAurFntxAYMQJLtwnUvFQ0Gp1XF7HgUh0PGkJNWDV2
+iah8jhvW2ujPf1dgpGIeVAcJ3Iu6KH5qOGWZnXNKm59U7zPwREtkxvqB07rAVXXi
+vKvjoqzu+LySVUtI8I8FWMbypHQGlNxippEVM85X4jfNWY+ufp5jOsgPAUVmyJWd
+VgepbU8kkr9scBasqjYdus0DXWUaDttbxoSpz8NODCS3StC2JJS+NEe1Vb/ZCNOQ
+cYuUuBfeuIF4jQjebJn+XvwLhu/KpemCU5WmcrlIk9NfPxCJ2K2es3nKBj5yWGXN
+XOf2/y5T4suViRRl5A+YO2wyWc8l4egVDKYzC2kSNlCQsIQ=
+-----END CERTIFICATE-----

+ 9 - 3
contrib/python/pytest-localserver/py3/pytest_localserver/http.py

@@ -15,7 +15,6 @@ from werkzeug.wrappers import Response
 
 
 class WSGIServer(threading.Thread):
-
     """
     HTTP server running a WSGI application in its own thread.
     """
@@ -61,7 +60,6 @@ def _encode_chunk(chunk, charset):
 
 
 class ContentServer(WSGIServer):
-
     """
     Small test server which can be taught which content (i.e. string) to serve
     with which response code. Try the following snippet for testing API calls::
@@ -89,12 +87,18 @@ class ContentServer(WSGIServer):
         self.compress = None
         self.requests = []
         self.chunked = Chunked.NO
+        self.store_request_data = False
 
     def __call__(self, environ, start_response):
         """
         This is the WSGI application.
         """
         request = Request(environ)
+
+        if self.store_request_data:
+            # need to invoke this method to cache the data
+            request.get_data(cache=True)
+
         self.requests.append(request)
         if (
             request.content_type == "application/x-www-form-urlencoded"
@@ -129,7 +133,7 @@ class ContentServer(WSGIServer):
 
         return response(environ, start_response)
 
-    def serve_content(self, content, code=200, headers=None, chunked=Chunked.NO):
+    def serve_content(self, content, code=200, headers=None, chunked=Chunked.NO, store_request_data=True):
         """
         Serves string content (with specified HTTP error code) as response to
         all subsequent request.
@@ -138,6 +142,7 @@ class ContentServer(WSGIServer):
         :param code: HTTP status code
         :param headers: HTTP headers to be returned
         :param chunked: whether to apply chunked transfer encoding to the content
+        :param store_request_data: whether to store data sent as request payload.
         """
         if not isinstance(content, (str, bytes, list, tuple)):
             # If content is an iterable which is not known to be a string,
@@ -153,6 +158,7 @@ class ContentServer(WSGIServer):
         self.content = content
         self.code = code
         self.chunked = chunked
+        self.store_request_data = store_request_data
         if headers:
             self.headers = Headers(headers)
 

+ 20 - 5
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

+ 3 - 1
contrib/python/pytest-localserver/py3/pytest_localserver/plugin.py

@@ -64,8 +64,10 @@ def httpsserver(request):
     """
     from pytest_localserver import https
     try:
+        with open(https.DEFAULT_KEY, 'wb') as f:
+            f.write(pkgutil.get_data('pytest_localserver', 'server.key'))
         with open(https.DEFAULT_CERTIFICATE, 'wb') as f:
-            f.write(pkgutil.get_data('pytest_localserver', 'server.pem'))
+            f.write(pkgutil.get_data('pytest_localserver', 'cert.crt'))
         server = https.SecureContentServer()
         server.start()
         request.addfinalizer(server.stop)

+ 0 - 32
contrib/python/pytest-localserver/py3/pytest_localserver/server.pem → contrib/python/pytest-localserver/py3/pytest_localserver/server.key

@@ -50,35 +50,3 @@ lIqpHR4fwrBr4SLStzvBo9UK1YYQ94FyKd7xou3uXLLTlY3G8rD6jjKJE2Gg8Ga/
 gGzbRCZWH6AOk1iO/CmOPH6AdFn5axXTx+uAML1Lr2VQ+azrYZCtIhKmW/kuQPQg
 apeiobcSY1vsX7eM8mQkM8TxrDLyNjtl
 -----END PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIIFiTCCA3GgAwIBAgIUUpWEFJm0PzrYTkhLe05yIBhBMuowDQYJKoZIhvcNAQEL
-BQAwSTESMBAGA1UEAwwJMTI3LjAuMC4xMRswGQYDVQQKDBJweXRlc3QtbG9jYWxz
-ZXJ2ZXIxFjAUBgNVBAsMDVRlc3RpbmcgRGVwdC4wHhcNMjEwOTE0MDU1NzAxWhcN
-MzEwOTEyMDU1NzAxWjBJMRIwEAYDVQQDDAkxMjcuMC4wLjExGzAZBgNVBAoMEnB5
-dGVzdC1sb2NhbHNlcnZlcjEWMBQGA1UECwwNVGVzdGluZyBEZXB0LjCCAiIwDQYJ
-K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