Skip to content

Commit

Permalink
TLS client test: also close client_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Sep 28, 2024
1 parent d9c010e commit c017074
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/scapy/layers/ldapopenldap.uts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Tests that need a local instance of OpenLDAP to run

+ Functional test against OpenLDAP
~ linux
~ linux ci_only

= (OpenLDAP) connect to server, bind

Expand Down
10 changes: 8 additions & 2 deletions test/scapy/layers/tls/tlsclientserver.uts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def run_tls_native_test_server(post_handshake_auth=False,

def ssl_server():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.settimeout(10)
server.settimeout(1)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("0.0.0.0", 59000))
server.listen(5)
Expand All @@ -486,6 +486,10 @@ def run_tls_native_test_server(post_handshake_auth=False,
assert resp == bytes(REQS[1])
ssl_client_socket.send(bytes(RESPS[1]))
# close socket
try:
ssl_client_socket.shutdown(socket.SHUT_RDWR)
finally:
ssl_client_socket.close()
try:
server.shutdown(socket.SHUT_RDWR)
finally:
Expand Down Expand Up @@ -522,7 +526,9 @@ def test_tls_client_native(post_handshake_auth=False,
a.send(REQS[1])
pkt = a.sr1(REQS[1], timeout=1, verbose=0)
assert pkt.load == b"Welcome"
# Wait
# Close
a.close()
# Wait for server to close
server.join(3)
assert not server.is_alive()

Expand Down

0 comments on commit c017074

Please sign in to comment.