Skip to content

Commit

Permalink
tests/multi_net: Fix skipping of SSLContext tests when .der don't exist.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dpgeorge committed Jul 25, 2024
1 parent 17f254d commit e1fe62f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
12 changes: 4 additions & 8 deletions tests/multi_net/sslcontext_server_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
10 changes: 4 additions & 6 deletions tests/multi_net/sslcontext_server_client_ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1fe62f

Please sign in to comment.