[英]How can we use Django LiveServerTestCase with Selenium to test https urls
Our end-to-end tests use Django's LiveServerTestCase with Selenium.我们的端到端测试使用 Django 的 LiveServerTestCase 和 Selenium。 So far we have only been able to run these on insecure urls.到目前为止,我们只能在不安全的 url 上运行这些。 However, some of the libraries that we use (Square) require a page to be on https even in sandbox mode.但是,我们使用的一些库(Square)需要一个页面在 https 上,即使在沙盒模式下也是如此。
When attempting to connect to a secure url, Selenium/Chrome Webdriver simply shows the standard SSL not supported error:尝试连接到安全 url 时,Selenium/Chrome Webdriver 仅显示标准 SSL 不支持错误:
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?有谁知道是否可以在 LiveServerTestCase 上启用 https?
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.我试图避免在我们的构建框上运行单独的 https 代理,但这似乎是唯一的方法。
After quick research I found out that this is impossible in Django suggested by this old code ticket https://code.djangoproject.com/ticket/25328经过快速研究,我发现这在旧代码票https://code.djangoproject.com/ticket/25328建议的 Django 中是不可能的
I also found out that you could setup a tunnel to bypass this issue.我还发现你可以设置一个隧道来绕过这个问题。 However this applies to django development server.但是,这适用于 django 开发服务器。 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 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'? 如何像使用“runserver”进行非 https 连接一样轻松地测试与 Django 的 https 连接?
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.它为您提供了一个开箱即用的支持 https 的 django 开发服务器。 The project is active and maintained该项目处于活动状态并得到维护
https://github.com/teddziuba/django-sslserver https://github.com/teddziuba/django-sslserver
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.