2

Our end-to-end tests use Django's LiveServerTestCase with Selenium. So far we have only been able to run these on insecure urls. However, some of the libraries that we use (Square) require a page to be on https even in sandbox mode.

When attempting to connect to a secure url, Selenium/Chrome Webdriver simply shows the standard SSL not supported error:

This site can’t provide a secure connection chezpierre.localtest.me sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Does anyone know if it is possible to enable https on a LiveServerTestCase?

If not, does anyone have a working workaround for this? I'm trying to avoid running a separate https proxy on our build box, but it seems like it might be the only way.

Pierre Drescher
  • 776
  • 5
  • 10

1 Answers1

1

After quick research I found out that this is impossible in Django suggested by this old code ticket https://code.djangoproject.com/ticket/25328

I also found out that you could setup a tunnel to bypass this issue. However this applies to django development server. This is kind of tricky so I am leaving links to posts as the method is rather long:

https://www.ianlewis.org/en/testing-https-djangos-development-server

or

How can I test https connections with Django as easily as I can non-https connections using 'runserver'?

ALTERNATIVE - In my opinion better

There is also a simpler way using an external package. It gives you out of the box a https capable django development server. The project is active and maintained

https://github.com/teddziuba/django-sslserver

CodeSamurai777
  • 3,285
  • 2
  • 24
  • 42
  • Thanks for the research. Good find on the old code ticket. Looks like it won't be supported any time soon. We've used sslserver for local ssl development but it doesn't ship with a LiveServerTestCase so it won't work for integration tests. I think our approach at the moment is to look into running a local https proxy when running our LiveServerTestCase tests. I'll update the question here if we get it to work and it seems reasonable. – Pierre Drescher Jul 29 '19 at 13:30