eugeniy / pytest-tornado

A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.
Apache License 2.0
121 stars 34 forks source link

Support for HTTPS testing #50

Closed okin closed 5 years ago

okin commented 5 years ago

This adds support for testing with HTTPS. Based on the work of @judeaugustinej in PR #22 to fix #21.

It adds fixtures https_port, https_server, https_client and secure_base_url.

Even though it works I'd like things to be easier to use in regard of base_url, because this introduces another fixture secure_base_url. I'd like to have only the base_url fixture available but am currently not sure if or how this could be implemented. Feedback in this regard is more than welcome!

Options for SSL have to be given through an fixture ssl_options in a way like currently app is used.

vidartf commented 5 years ago

I'd like to have only the base_url fixture available but am currently not sure if or how this could be implemented.

I think you can use request.fixturenames in base_url and see if http[s]_server is in there.

okin commented 5 years ago

@vidartf thanks for the tip with request.fixturenames. I was able to get it together with this.

Let me know what you think!

vidartf commented 5 years ago

Note: I added a commit for making create_cert.py work on Windows. See commit message for details.

okin commented 5 years ago

Note: I added a commit for making create_cert.py work on Windows. See commit message for details.

I'm fine with this.

The only possible improvement I can see would be to give a warning if a user requests a mismatched secure/non-secure server/client/port tuple. Could be an easy typo that would be hard to catch, but I'm not sure if it is worth the effort though, so I will leave that as a possible follow-up PR (ping if you want it).

I would skip this for now and wait how users are picking up the new feature. If this becomes a common mistake I think such a warning should be implemented. Will add an issue so this won't be forgotten.