|
10 | 10 |
|
11 | 11 | Test the simplest proxy use scenario for smoke. |
12 | 12 | """ |
13 | | -import sys |
14 | 13 | import time |
15 | 14 | import pytest |
16 | 15 | import tempfile |
| 16 | +import subprocess |
17 | 17 |
|
18 | 18 | from pathlib import Path |
19 | 19 | from typing import Any, Generator |
|
22 | 22 | from proxy.common.constants import IS_WINDOWS |
23 | 23 |
|
24 | 24 |
|
25 | | -TLS_INTERCEPTION_FLAGS = ' '.join(( |
26 | | - '--ca-cert-file', 'ca-cert.pem', |
27 | | - '--ca-key-file', 'ca-key.pem', |
28 | | - '--ca-signing-key', 'ca-signing-key.pem', |
29 | | -)) |
| 25 | +def _tls_interception_flags(ca_cert_suffix: str = '') -> str: |
| 26 | + return ' '.join(( |
| 27 | + '--ca-cert-file', 'ca-cert%s.pem' % ca_cert_suffix, |
| 28 | + '--ca-key-file', 'ca-key%s.pem' % ca_cert_suffix, |
| 29 | + '--ca-signing-key', 'ca-signing-key%s.pem' % ca_cert_suffix, |
| 30 | + )) |
| 31 | + |
30 | 32 |
|
31 | 33 | PROXY_PY_FLAGS_INTEGRATION = ( |
32 | 34 | ('--threadless'), |
|
35 | 37 | ) |
36 | 38 |
|
37 | 39 | PROXY_PY_FLAGS_TLS_INTERCEPTION = ( |
38 | | - ('--threadless ' + TLS_INTERCEPTION_FLAGS), |
39 | | - ('--threadless --local-executor 0 ' + TLS_INTERCEPTION_FLAGS), |
40 | | - ('--threaded ' + TLS_INTERCEPTION_FLAGS), |
| 40 | + ('--threadless ' + _tls_interception_flags()), |
| 41 | + ('--threadless --local-executor 0 ' + _tls_interception_flags()), |
| 42 | + ('--threaded ' + _tls_interception_flags()), |
41 | 43 | ) |
42 | 44 |
|
43 | 45 | PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN = ( |
44 | 46 | ( |
45 | 47 | '--threadless --plugin proxy.plugin.ModifyChunkResponsePlugin ' + |
46 | | - TLS_INTERCEPTION_FLAGS |
| 48 | + _tls_interception_flags('-chunk') |
47 | 49 | ), |
48 | 50 | ( |
49 | 51 | '--threadless --local-executor 0 --plugin proxy.plugin.ModifyChunkResponsePlugin ' + |
50 | | - TLS_INTERCEPTION_FLAGS |
| 52 | + _tls_interception_flags('-chunk') |
51 | 53 | ), |
52 | 54 | ( |
53 | 55 | '--threaded --plugin proxy.plugin.ModifyChunkResponsePlugin ' + |
54 | | - TLS_INTERCEPTION_FLAGS |
| 56 | + _tls_interception_flags('-chunk') |
55 | 57 | ), |
56 | 58 | ) |
57 | 59 |
|
58 | 60 | PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN = ( |
59 | 61 | ( |
60 | 62 | '--threadless --plugin proxy.plugin.ModifyPostDataPlugin ' + |
61 | | - TLS_INTERCEPTION_FLAGS |
| 63 | + _tls_interception_flags('-post') |
62 | 64 | ), |
63 | 65 | ( |
64 | 66 | '--threadless --local-executor 0 --plugin proxy.plugin.ModifyPostDataPlugin ' + |
65 | | - TLS_INTERCEPTION_FLAGS |
| 67 | + _tls_interception_flags('-post') |
66 | 68 | ), |
67 | 69 | ( |
68 | 70 | '--threaded --plugin proxy.plugin.ModifyPostDataPlugin ' + |
69 | | - TLS_INTERCEPTION_FLAGS |
| 71 | + _tls_interception_flags('-post') |
70 | 72 | ), |
71 | 73 | ) |
72 | 74 |
|
73 | 75 |
|
74 | 76 | @pytest.fixture(scope='session', autouse=True) # type: ignore[misc] |
75 | | -def _gen_ca_certificates() -> None: |
76 | | - check_output(['make', 'ca-certificates']) |
| 77 | +def _gen_ca_certificates(request: Any) -> None: |
| 78 | + check_output([ |
| 79 | + 'make', 'ca-certificates', |
| 80 | + ]) |
| 81 | + check_output([ |
| 82 | + 'make', 'ca-certificates', |
| 83 | + '-e', 'CA_CERT_SUFFIX=-chunk', |
| 84 | + ]) |
| 85 | + check_output([ |
| 86 | + 'make', 'ca-certificates', |
| 87 | + '-e', 'CA_CERT_SUFFIX=-post', |
| 88 | + ]) |
77 | 89 |
|
78 | 90 |
|
79 | 91 | # FIXME: Ignore is necessary for as long as pytest hasn't figured out |
@@ -104,7 +116,7 @@ def proxy_py_subprocess(request: Any) -> Generator[int, None, None]: |
104 | 116 | '--ca-cert-dir', str(ca_cert_dir), |
105 | 117 | '--log-level', 'd', |
106 | 118 | ) + tuple(request.param.split()) |
107 | | - proxy_proc = Popen(proxy_cmd) |
| 119 | + proxy_proc = Popen(proxy_cmd, stderr=subprocess.STDOUT) |
108 | 120 | # Needed because port file might not be available immediately |
109 | 121 | while not port_file.exists(): |
110 | 122 | time.sleep(1) |
@@ -163,10 +175,6 @@ def test_integration_with_interception_flags(proxy_py_subprocess: int) -> None: |
163 | 175 | IS_WINDOWS, |
164 | 176 | reason='OSError: [WinError 193] %1 is not a valid Win32 application', |
165 | 177 | ) # type: ignore[misc] |
166 | | -@pytest.mark.skipif( |
167 | | - sys.version_info < (3, 10), |
168 | | - reason='For version < 3.10, GHA integration run into OSError when flushing to clients', |
169 | | -) # type: ignore[misc] |
170 | 178 | def test_modify_chunk_response_integration(proxy_py_subprocess: int) -> None: |
171 | 179 | """An acceptance test for :py:class:`~proxy.plugin.ModifyChunkResponsePlugin` |
172 | 180 | interception using ``curl`` through proxy.py.""" |
|
0 commit comments