From e1fe62f4fca9506980bb19bbc973bf21740625e0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 25 Jul 2024 16:51:07 +1000 Subject: [PATCH] tests/multi_net: Fix skipping of SSLContext tests when .der don't exist. The `sslcontext_server_client_ciphers.py` test was using stat to test for the .der files after it already tried to open them for reading. That is now fixed. And `sslcontext_server_client.py` is adjusted to use the same pattern for skipping the test. Signed-off-by: Damien George --- tests/multi_net/sslcontext_server_client.py | 12 ++++-------- tests/multi_net/sslcontext_server_client_ciphers.py | 10 ++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/multi_net/sslcontext_server_client.py b/tests/multi_net/sslcontext_server_client.py index 473c9c376e38..6516de53f7df 100644 --- a/tests/multi_net/sslcontext_server_client.py +++ b/tests/multi_net/sslcontext_server_client.py @@ -15,18 +15,14 @@ keyfile = "ec_key.der" try: - os.stat(certfile) - os.stat(keyfile) + with open(certfile, "rb") as cf: + cert = cadata = cf.read() + with open(keyfile, "rb") as kf: + key = kf.read() except OSError: print("SKIP") raise SystemExit -with open(certfile, "rb") as cf: - cert = cadata = cf.read() - -with open(keyfile, "rb") as kf: - key = kf.read() - # Server def instance0(): diff --git a/tests/multi_net/sslcontext_server_client_ciphers.py b/tests/multi_net/sslcontext_server_client_ciphers.py index c168b444a992..3334d9d9e4c1 100644 --- a/tests/multi_net/sslcontext_server_client_ciphers.py +++ b/tests/multi_net/sslcontext_server_client_ciphers.py @@ -13,14 +13,12 @@ # These are test certificates. See tests/README.md for details. cert = cafile = "ec_cert.der" key = "ec_key.der" -with open(cafile, "rb") as f: - cadata = f.read() -with open(key, "rb") as f: - keydata = f.read() try: - os.stat(cafile) - os.stat(key) + with open(cafile, "rb") as f: + cadata = f.read() + with open(key, "rb") as f: + keydata = f.read() except OSError: print("SKIP") raise SystemExit