From 92fd1fa9aa034c4676c7d4d19ea8d1f40090a6db Mon Sep 17 00:00:00 2001 From: Javier Paniagua Date: Wed, 18 Aug 2021 17:43:02 +0200 Subject: [PATCH 1/4] added *TestCase classes --- sslserver/testcases.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sslserver/testcases.py diff --git a/sslserver/testcases.py b/sslserver/testcases.py new file mode 100644 index 0000000..0bdd168 --- /dev/null +++ b/sslserver/testcases.py @@ -0,0 +1,33 @@ +import os + +from django.contrib.staticfiles.testing import StaticLiveServerTestCase +from django.test.testcases import LiveServerTestCase, LiveServerThread, QuietWSGIRequestHandler + +from sslserver.management.commands.runsslserver import ( + SecureHTTPServer, WSGIRequestHandler, default_ssl_files_dir, +) + + +class SecureQuietWSGIRequestHandler(WSGIRequestHandler, QuietWSGIRequestHandler): + pass + + +class SecureLiveServerThread(LiveServerThread): + def _create_server(self): + cert_file = os.path.join(default_ssl_files_dir(), "development.crt") + key_file = os.path.join(default_ssl_files_dir(), "development.key") + + return SecureHTTPServer( + (self.host, self.port), + SecureQuietWSGIRequestHandler, + cert_file, + key_file, + ) + + +class SecureLiveServerTestCase(LiveServerTestCase): + server_thread_class = SecureLiveServerThread + + +class SecureStaticLiveServerTestCase(StaticLiveServerTestCase): + server_thread_class = SecureLiveServerThread From 304f02da0953702b853911fcf08ba53a56b9f3ad Mon Sep 17 00:00:00 2001 From: Javier Paniagua Date: Wed, 18 Aug 2021 17:46:23 +0200 Subject: [PATCH 2/4] bumped version 0.20 -> 0.21 --- sslserver/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sslserver/__init__.py b/sslserver/__init__.py index 2390dc1..54d5d3b 100644 --- a/sslserver/__init__.py +++ b/sslserver/__init__.py @@ -1 +1 @@ -__version__ = "0.20" +__version__ = "0.21" From 49af725a64d698d1cc2996be4bb0a6683f5d1ad5 Mon Sep 17 00:00:00 2001 From: Javier Paniagua Date: Wed, 18 Aug 2021 18:07:38 +0200 Subject: [PATCH 3/4] updated documentation --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.rst b/README.rst index c83022d..2040f18 100644 --- a/README.rst +++ b/README.rst @@ -74,6 +74,16 @@ If you're using a wrapper around your WSGI application such as dj_static or Whit static files. Otherwise, you may see 404s when requesting static files. You can disable the default behavior by using the ``--nostatic`` option. +Testing Tools +============= + +Django SSL Server adds SSL-enabled versions of +`LiveServerTestCase `_ and +`StaticLiveServerTestCase `_, called . +``SecureLiveServerTestCase`` and ``SecureStaticLiveServerTestCase`` respectively. + +You can use these classes to write tests that involve running the code under test and consuming it with testing tools through HTTPS (e.g. Selenium, PhantomJS, etc.), for cases in which a secure connection is needed (e.g., `WebAuthn `). + Getting Involved ================ From 8a2a01425dc99aefb2b9a324ebcb95df9961a2f5 Mon Sep 17 00:00:00 2001 From: Javier Paniagua Date: Wed, 18 Aug 2021 18:21:40 +0200 Subject: [PATCH 4/4] actually, version should be > 0.22 --- sslserver/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sslserver/__init__.py b/sslserver/__init__.py index 54d5d3b..3fe695d 100644 --- a/sslserver/__init__.py +++ b/sslserver/__init__.py @@ -1 +1 @@ -__version__ = "0.21" +__version__ = "0.23"