-
Notifications
You must be signed in to change notification settings - Fork 18
Use locally hosted services for tests #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
840f87d
8254da5
deaf361
4bf82b6
64a4450
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,13 +30,13 @@ | |
|
|
||
| @requires_ssl_assert_fingerprint_in_chain | ||
| @pytest.mark.parametrize("node_cls", [Urllib3HttpNode, RequestsHttpNode]) | ||
| def test_ssl_assert_fingerprint_invalid_length(node_cls): | ||
| def test_ssl_assert_fingerprint_invalid_length(node_cls, httpbin_secure): | ||
| with pytest.raises(ValueError) as e: | ||
| node_cls( | ||
| NodeConfig( | ||
| "https", | ||
| "httpbin.org", | ||
| 443, | ||
| httpbin_secure.host, | ||
| httpbin_secure.port, | ||
| ssl_assert_fingerprint="0000", | ||
| ) | ||
| ) | ||
|
|
@@ -49,22 +49,14 @@ def test_ssl_assert_fingerprint_invalid_length(node_cls): | |
|
|
||
| @requires_ssl_assert_fingerprint_in_chain | ||
| @pytest.mark.parametrize("node_cls", [Urllib3HttpNode, RequestsHttpNode]) | ||
| @pytest.mark.parametrize( | ||
| "ssl_assert_fingerprint", | ||
| [ | ||
| "8ecde6884f3d87b1125ba31ac3fcb13d7016de7f57cc904fe1cb97c6ae98196e", | ||
| "8e:cd:e6:88:4f:3d:87:b1:12:5b:a3:1a:c3:fc:b1:3d:70:16:de:7f:57:cc:90:4f:e1:cb:97:c6:ae:98:19:6e", | ||
| "8ECDE6884F3D87B1125BA31AC3FCB13D7016DE7F57CC904FE1CB97C6AE98196E", | ||
| ], | ||
| ) | ||
| def test_assert_fingerprint_in_cert_chain(node_cls, ssl_assert_fingerprint): | ||
| def test_assert_fingerprint_in_cert_chain(node_cls, cert_fingerprint, httpbin_secure): | ||
| with warnings.catch_warnings(record=True) as w: | ||
| node = node_cls( | ||
| NodeConfig( | ||
| "https", | ||
| "httpbin.org", | ||
| 443, | ||
| ssl_assert_fingerprint=ssl_assert_fingerprint, | ||
| httpbin_secure.host, | ||
| httpbin_secure.port, | ||
| ssl_assert_fingerprint=cert_fingerprint, | ||
| ) | ||
| ) | ||
| meta, _ = node.perform_request("GET", "/") | ||
|
|
@@ -75,11 +67,13 @@ def test_assert_fingerprint_in_cert_chain(node_cls, ssl_assert_fingerprint): | |
|
|
||
| @requires_ssl_assert_fingerprint_in_chain | ||
| @pytest.mark.parametrize("node_cls", [Urllib3HttpNode, RequestsHttpNode]) | ||
| def test_assert_fingerprint_in_cert_chain_failure(node_cls): | ||
| def test_assert_fingerprint_in_cert_chain_failure( | ||
| node_cls, httpbin_secure, cert_fingerprint | ||
| ): | ||
| node = node_cls( | ||
| NodeConfig( | ||
| "https", | ||
| "httpbin.org", | ||
| "www.elastic.co", | ||
| 443, | ||
| ssl_assert_fingerprint="0" * 64, | ||
| ) | ||
|
|
@@ -96,4 +90,4 @@ def test_assert_fingerprint_in_cert_chain_failure(node_cls): | |
| in err | ||
| ) | ||
| # This is the root CA for httpbin.org with a leading comma to denote more than one cert was listed. | ||
| assert ', "8ecde6884f3d87b1125ba31ac3fcb13d7016de7f57cc904fe1cb97c6ae98196e"' in err | ||
| assert ', "cbb522d7b7f127ad6a0113865bdf1cd4102e7d0759af635a7cf4720dc963c53b"' in err | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The certificate is currently generated by trustme: kevin1024/pytest-httpbin#90. Since it generates its own CA, this is going to be less stable than before. Additionally, the comment is out of date.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the root CA for www.elastic.co, this is the one test that does not use the local httpbin.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, sorry. This should be pretty stable. Can we update the comment above then? |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as a follow-up, we could add an url property to NodeConfig, which would avoid accepting both
httpbinandhttpbin_node_config. (It took me a while to understand.)