Skip to content

Commit 3ff234a

Browse files
committed
Second round of review
1 parent a3eae49 commit 3ff234a

10 files changed

Lines changed: 104 additions & 74 deletions

File tree

tests/base64/base64-test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def test_stdin_input(self):
9898
[WOLFSSL_BIN, "base64"],
9999
input=stdin_data,
100100
capture_output=True,
101+
timeout=60,
101102
)
102103
self.assertEqual(result.returncode, 0,
103104
"Couldn't parse input from stdin")

tests/client/client-test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_s_client_x509(self):
4242
[WOLFSSL_BIN, "x509", "-outform", "pem", "-out", tmp_crt],
4343
input=s_client.stdout,
4444
capture_output=True,
45+
timeout=60,
4546
)
4647

4748
# Read back the cert

tests/encrypt/enc-test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run_enc(*args, password=""):
1616
"""Run wolfssl enc with a -k password argument appended."""
1717
cmd = [WOLFSSL_BIN] + list(args) + ["-k", password]
1818
return subprocess.run(cmd, capture_output=True, text=True,
19-
stdin=subprocess.DEVNULL)
19+
stdin=subprocess.DEVNULL, timeout=60)
2020

2121

2222
class EncDecryptTest(unittest.TestCase):
@@ -154,7 +154,7 @@ def test_openssl_enc_wolfssl_dec(self):
154154

155155
ossl = subprocess.run(["openssl", "enc", "-base64", "-aes-256-cbc",
156156
"-k", "test password", "-in", orig, "-out", enc],
157-
capture_output=True)
157+
capture_output=True, timeout=60)
158158
self.assertEqual(ossl.returncode, 0, ossl.stderr)
159159

160160
r = run_enc("enc", "-base64", "-d", "-aes-256-cbc",
@@ -174,7 +174,7 @@ def test_wolfssl_enc_openssl_dec(self):
174174

175175
ossl = subprocess.run(["openssl", "enc", "-base64", "-d", "-aes-256-cbc",
176176
"-k", "test password", "-in", enc, "-out", dec],
177-
capture_output=True)
177+
capture_output=True, timeout=60)
178178
self.assertEqual(ossl.returncode, 0, ossl.stderr)
179179
self.assertTrue(filecmp.cmp(orig, dec, shallow=False))
180180

@@ -186,7 +186,7 @@ def test_pbkdf2_openssl_enc_wolfssl_dec(self):
186186

187187
ossl = subprocess.run(["openssl", "enc", "-base64", "-pbkdf2", "-aes-256-cbc",
188188
"-k", "long test password", "-in", orig, "-out", enc],
189-
capture_output=True)
189+
capture_output=True, timeout=60)
190190
self.assertEqual(ossl.returncode, 0, ossl.stderr)
191191

192192
r = run_enc("enc", "-base64", "-d", "-pbkdf2", "-aes-256-cbc",
@@ -207,7 +207,7 @@ def test_pbkdf2_wolfssl_enc_openssl_dec(self):
207207
ossl = subprocess.run(["openssl", "enc", "-base64", "-d", "-pbkdf2",
208208
"-aes-256-cbc", "-k", "long test password",
209209
"-in", enc, "-out", dec],
210-
capture_output=True)
210+
capture_output=True, timeout=60)
211211
self.assertEqual(ossl.returncode, 0, ossl.stderr)
212212
self.assertTrue(filecmp.cmp(orig, dec, shallow=False))
213213

@@ -225,7 +225,8 @@ def test_pbkdf2_wolfssl_pass_flag(self):
225225
r = subprocess.run(
226226
[WOLFSSL_BIN, "enc", "-base64", "-d", "-pbkdf2", "-aes-256-cbc",
227227
"-pass", "pass:long test password", "-in", enc, "-out", dec],
228-
capture_output=True, text=True, stdin=subprocess.DEVNULL)
228+
capture_output=True, text=True, stdin=subprocess.DEVNULL,
229+
timeout=60)
229230
self.assertEqual(r.returncode, 0, r.stderr)
230231
self.assertTrue(filecmp.cmp(orig, dec, shallow=False))
231232

tests/pkcs/pkcs12-test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def test_nocerts(self):
4141
[WOLFSSL_BIN, "pkcs12", "-nodes", "-nocerts",
4242
"-passin", "stdin", "-passout", "pass:", "-in", P12_FILE],
4343
input=b"wolfSSL test", capture_output=True, text=False,
44+
timeout=60,
4445
)
4546
self.assertEqual(r.returncode, 0, r.stderr)
4647
self.assertNotIn(b"CERTIFICATE", r.stdout)
@@ -50,6 +51,7 @@ def test_nokeys(self):
5051
[WOLFSSL_BIN, "pkcs12", "-nokeys",
5152
"-passin", "stdin", "-passout", "pass:", "-in", P12_FILE],
5253
input=b"wolfSSL test", capture_output=True, text=False,
54+
timeout=60,
5355
)
5456
self.assertEqual(r.returncode, 0, r.stderr)
5557
self.assertNotIn(b"KEY", r.stdout)
@@ -64,6 +66,7 @@ def test_nocerts_with_passout(self):
6466
[WOLFSSL_BIN, "pkcs12", "-passin", "stdin", "-passout", "pass:",
6567
"-in", P12_FILE, "-nocerts"],
6668
input=b"wolfSSL test", capture_output=True, text=False,
69+
timeout=60,
6770
)
6871
self.assertEqual(r.returncode, 0, r.stderr)
6972

tests/pkcs/pkcs7-test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def test_pem_to_der(self):
4949
"-in", os.path.join(CERTS_DIR, "signed.p7s"),
5050
"-outform", "DER"],
5151
capture_output=True, stdin=subprocess.DEVNULL,
52+
timeout=60,
5253
)
5354
self.assertEqual(r.returncode, 0, r.stderr)
5455

@@ -62,6 +63,7 @@ def test_stdin_input(self):
6263
r = subprocess.run(
6364
[WOLFSSL_BIN, "pkcs7", "-inform", "DER"],
6465
input=data, capture_output=True, text=False,
66+
timeout=60,
6567
)
6668
self.assertIn(b"BEGIN PKCS7", r.stdout + r.stderr)
6769

tests/pkcs/pkcs8-test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def test_stdin_input(self):
8686
r = subprocess.run(
8787
[WOLFSSL_BIN, "pkcs8", "-passin", "pass:yassl123"],
8888
input=data, capture_output=True, text=False,
89+
timeout=60,
8990
)
9091
self.assertIn(b"BEGIN PRIVATE", r.stdout + r.stderr)
9192

tests/pkey/ecparam-test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ def test_fail_der_params_only(self):
8181
"""Reading DER with parameters only (no key) is not yet supported."""
8282
self._cleanup("ecc-key.der", "ecc-key.pem")
8383

84-
run_wolfssl("ecparam", "-in",
85-
os.path.join(CERTS_DIR, "ecc-key.pem"),
86-
"-out", "ecc-key.der", "-outform", "der")
84+
r = run_wolfssl("ecparam", "-in",
85+
os.path.join(CERTS_DIR, "ecc-key.pem"),
86+
"-out", "ecc-key.der", "-outform", "der")
87+
self.assertEqual(r.returncode, 0, r.stderr)
8788

8889
r = run_wolfssl("ecparam", "-in", "ecc-key.der", "-inform", "der",
8990
"-out", "ecc-key.pem", "-outform", "pem")

tests/x509/x509-ca-test.py

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,12 @@ def test_selfsign_verify_fails_wrong_ca(self):
275275
"""Self-signed cert should not verify with unrelated CAs."""
276276
out = "test_ca_selfsign_vf.pem"
277277
self._clean(out)
278-
run_wolfssl("ca", "-config", self.conf,
279-
"-in", self.csr, "-out", out,
280-
"-md", "sha256", "-selfsign",
281-
"-keyfile",
282-
os.path.join(CERTS_DIR, "server-key.pem"))
278+
r = run_wolfssl("ca", "-config", self.conf,
279+
"-in", self.csr, "-out", out,
280+
"-md", "sha256", "-selfsign",
281+
"-keyfile",
282+
os.path.join(CERTS_DIR, "server-key.pem"))
283+
self.assertEqual(r.returncode, 0, r.stderr)
283284

284285
r1 = run_wolfssl("verify", "-CAfile",
285286
os.path.join(CERTS_DIR, "server-cert.pem"), out)
@@ -486,8 +487,9 @@ def test_rand_file_written(self):
486487
"""Rand file should be 256 bytes after cert creation."""
487488
out = "test_ca_rand.pem"
488489
self._clean(out)
489-
run_wolfssl("ca", "-config", self.conf,
490-
"-in", self.csr, "-out", out)
490+
r = run_wolfssl("ca", "-config", self.conf,
491+
"-in", self.csr, "-out", out)
492+
self.assertEqual(r.returncode, 0, r.stderr)
491493
self.assertTrue(os.path.isfile("rand-file-test"))
492494
size = os.path.getsize("rand-file-test")
493495
self.assertEqual(size, 256,
@@ -499,16 +501,18 @@ def test_rand_file_changes(self):
499501
out2 = "test_ca_randc2.pem"
500502
self._clean(out1, out2)
501503

502-
run_wolfssl("ca", "-config", self.conf,
503-
"-in", self.csr, "-out", out1)
504+
r = run_wolfssl("ca", "-config", self.conf,
505+
"-in", self.csr, "-out", out1)
506+
self.assertEqual(r.returncode, 0, r.stderr)
504507
with open("rand-file-test", "rb") as f:
505508
rand1 = f.read()
506509

507510
_cleanup("index.txt")
508511
_touch("index.txt")
509512

510-
run_wolfssl("ca", "-config", self.conf,
511-
"-in", self.csr, "-out", out2)
513+
r = run_wolfssl("ca", "-config", self.conf,
514+
"-in", self.csr, "-out", out2)
515+
self.assertEqual(r.returncode, 0, r.stderr)
512516
with open("rand-file-test", "rb") as f:
513517
rand2 = f.read()
514518

@@ -548,10 +552,11 @@ def test_no_common_name_supplied_fails(self):
548552
csr = "ca_pol_nocn.csr"
549553
out = "ca_pol_nocn.pem"
550554
self._clean(csr, out)
551-
run_wolfssl("req", "-key",
552-
os.path.join(CERTS_DIR, "server-key.pem"),
553-
"-subj", "O=wolfSSL/C=US/ST=MT/L=Bozeman/OU=org-unit",
554-
"-out", csr)
555+
r = run_wolfssl("req", "-key",
556+
os.path.join(CERTS_DIR, "server-key.pem"),
557+
"-subj", "O=wolfSSL/C=US/ST=MT/L=Bozeman/OU=org-unit",
558+
"-out", csr)
559+
self.assertEqual(r.returncode, 0, r.stderr)
555560
r = run_wolfssl("ca", "-config", self.conf,
556561
"-in", csr, "-out", out,
557562
"-md", "sha256",
@@ -563,10 +568,11 @@ def test_no_common_name_match_fails(self):
563568
csr = "ca_pol_nocnm.csr"
564569
out = "ca_pol_nocnm.pem"
565570
self._clean(csr, out)
566-
run_wolfssl("req", "-key",
567-
os.path.join(CERTS_DIR, "server-key.pem"),
568-
"-subj", "O=wolfSSL/C=US/ST=MT/L=Bozeman/OU=org-unit",
569-
"-out", csr)
571+
r = run_wolfssl("req", "-key",
572+
os.path.join(CERTS_DIR, "server-key.pem"),
573+
"-subj", "O=wolfSSL/C=US/ST=MT/L=Bozeman/OU=org-unit",
574+
"-out", csr)
575+
self.assertEqual(r.returncode, 0, r.stderr)
570576
r = run_wolfssl("ca", "-config", self.match_conf,
571577
"-in", csr, "-out", out,
572578
"-md", "sha256",
@@ -578,11 +584,12 @@ def test_common_name_supplied_succeeds(self):
578584
csr = "ca_pol_cn.csr"
579585
out = "ca_pol_cn.pem"
580586
self._clean(csr, out)
581-
run_wolfssl("req", "-key",
582-
os.path.join(CERTS_DIR, "server-key.pem"),
583-
"-subj",
584-
"O=Sawtooth/CN=www.wolfclu.com/C=US/ST=MT/L=Bozeman/OU=org-unit",
585-
"-out", csr)
587+
r = run_wolfssl("req", "-key",
588+
os.path.join(CERTS_DIR, "server-key.pem"),
589+
"-subj",
590+
"O=Sawtooth/CN=www.wolfclu.com/C=US/ST=MT/L=Bozeman/OU=org-unit",
591+
"-out", csr)
592+
self.assertEqual(r.returncode, 0, r.stderr)
586593
r = run_wolfssl("ca", "-config", self.conf,
587594
"-in", csr, "-out", out,
588595
"-md", "sha256",
@@ -594,11 +601,12 @@ def test_common_name_mismatch_fails(self):
594601
csr = "ca_pol_cnmm.csr"
595602
out = "ca_pol_cnmm.pem"
596603
self._clean(csr, out)
597-
run_wolfssl("req", "-key",
598-
os.path.join(CERTS_DIR, "server-key.pem"),
599-
"-subj",
600-
"O=Sawtooth/CN=www.wolfclu.com/C=US/ST=MT/L=Bozeman/OU=org-unit",
601-
"-out", csr)
604+
r = run_wolfssl("req", "-key",
605+
os.path.join(CERTS_DIR, "server-key.pem"),
606+
"-subj",
607+
"O=Sawtooth/CN=www.wolfclu.com/C=US/ST=MT/L=Bozeman/OU=org-unit",
608+
"-out", csr)
609+
self.assertEqual(r.returncode, 0, r.stderr)
602610
r = run_wolfssl("ca", "-config", self.match_conf,
603611
"-in", csr, "-out", out,
604612
"-md", "sha256",

0 commit comments

Comments
 (0)