From 6e2ccd325ecee97d5b9b128c747e1d21b3809fe5 Mon Sep 17 00:00:00 2001 From: Gleb <39743818+fzovpec@users.noreply.github.com> Date: Thu, 16 May 2024 14:59:51 +0200 Subject: [PATCH] Fix odd pexpect bug (#84) * Fix odd pexpect bug * Typo --- server_check/check.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/server_check/check.py b/server_check/check.py index be12a49..0c912ea 100644 --- a/server_check/check.py +++ b/server_check/check.py @@ -126,7 +126,13 @@ def reject_usernames_commas(): client_name_pt2 = generate_name() expected_output = "BAD-RQST-BODY" - _, output = execute_and_wait(f'echo "HELLO-FROM {client_name_pt1},{client_name_pt2}" | nc 127.0.0.1 5378 -W 1') + + echo_cmd = f'echo "HELLO-FROM {client_name_pt1},{client_name_pt2}"' + _, echo_output = execute_and_wait(echo_cmd) + + nc_cmd = f'echo "{echo_output}" | nc 127.0.0.1 5378 -W 1' + + _, output = execute_and_wait(nc_cmd) if not expected_output in output: raise TestException(f"your server did not return BAD-RQST-BODY when logging in with a username that contains commas. Reply was '{output}'") @@ -138,7 +144,13 @@ def reject_usernames_spaces(): client_name_pt2 = generate_name() expected_output = "BAD-RQST-BODY" - _, output = execute_and_wait(f'echo "HELLO-FROM {client_name_pt1} {client_name_pt2}" | nc 127.0.0.1 5378 -W 1') + + echo_cmd = f'echo "HELLO-FROM {client_name_pt1} {client_name_pt2}"' + _, echo_output = execute_and_wait(echo_cmd) + + nc_cmd = f'echo "{echo_output}" | nc 127.0.0.1 5378 -W 1' + + _, output = execute_and_wait(nc_cmd) if not expected_output in output: raise TestException(f"your server did not return BAD-RQST-BODY when logging in with a username that contains spaces. Reply was '{output}'") @@ -313,7 +325,12 @@ def send_message_before_login(): message = generate_message() expected_output = "BAD-RQST-HDR" - _, output = execute_and_wait(f'echo "SEND {client_name_1} {message}" | nc 127.0.0.1 5378 -W 1') + + echo_cmd = f'echo "SEND {client_name_1} {message}"' + _, echo_output = execute_and_wait(echo_cmd) + + nc_cmd = f'echo "{echo_output}" | nc 127.0.0.1 5378 -W 1' + _, output = execute_and_wait(nc_cmd) if not expected_output in output: raise TestException(f"your server did not return BAD-RQST-HDR when trying to send messages before logging in. Answer was '{output}'")