Skip to content

Commit faba649

Browse files
authored
tests(integ): fix nondeterministic ocsp test shutdown behavior (#5340)
1 parent daf68a1 commit faba649

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

tests/integrationv2/test_ocsp.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
@pytest.mark.uncollect_if(func=invalid_test_parameters)
1818
@pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
1919
@pytest.mark.parametrize("provider", [S2N, OpenSSL, GnuTLS], ids=get_parameter_name)
20-
@pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
2120
@pytest.mark.parametrize("curve", ALL_TEST_CURVES, ids=get_parameter_name)
2221
@pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
2322
@pytest.mark.parametrize("certificate", OCSP_CERTS, ids=get_parameter_name)
2423
def test_s2n_client_ocsp_response(
2524
managed_process, # noqa: F811
2625
cipher,
2726
provider,
28-
other_provider,
2927
curve,
3028
protocol,
3129
certificate,
@@ -62,9 +60,18 @@ def test_s2n_client_ocsp_response(
6260
)
6361

6462
kill_marker = None
65-
6663
if provider == GnuTLS:
67-
kill_marker = random_bytes
64+
# The gnutls-serv process will never exit on its own, so should be killed
65+
# to avoid a long timeout. However, we must NOT kill it until it sends
66+
# the close_notify that the s2n-tls client expects. The only good signal
67+
# for this is a debug message indicating that the alert was sent.
68+
#
69+
# The full debug message is something like:
70+
# "Sent Packet[4] Alert(21) in epoch 2 and length: 24"
71+
# but the packet number and epoch can vary. We are therefore forced to
72+
# only match on a very narrow substring, which could prove brittle.
73+
kill_marker = b"Alert(21) in epoch"
74+
server_options.extra_flags = ["-d", "5"]
6875

6976
server = managed_process(
7077
provider, server_options, timeout=30, kill_marker=kill_marker
@@ -87,15 +94,13 @@ def test_s2n_client_ocsp_response(
8794
@pytest.mark.uncollect_if(func=invalid_test_parameters)
8895
@pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
8996
@pytest.mark.parametrize("provider", [GnuTLS, OpenSSL], ids=get_parameter_name)
90-
@pytest.mark.parametrize("other_provider", [S2N])
9197
@pytest.mark.parametrize("curve", ALL_TEST_CURVES, ids=get_parameter_name)
9298
@pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
9399
@pytest.mark.parametrize("certificate", OCSP_CERTS, ids=get_parameter_name)
94100
def test_s2n_server_ocsp_response(
95101
managed_process, # noqa: F811
96102
cipher,
97103
provider,
98-
other_provider,
99104
curve,
100105
protocol,
101106
certificate,
@@ -129,20 +134,11 @@ def test_s2n_server_ocsp_response(
129134
}.get(certificate.algorithm),
130135
)
131136

132-
kill_marker = None
133-
if provider == GnuTLS:
134-
# The GnuTLS client hangs for a while after sending. Speed up the tests by killing
135-
# it immediately after sending the message.
136-
kill_marker = b"Sent: "
137-
138137
server = managed_process(S2N, server_options, timeout=90)
139-
client = managed_process(
140-
provider, client_options, timeout=90, kill_marker=kill_marker
141-
)
138+
client = managed_process(provider, client_options, timeout=90)
142139

143140
for client_results in client.get_results():
144141
client_results.assert_success()
145-
146142
assert any(
147143
[
148144
{

0 commit comments

Comments
 (0)