From b8467e34275f371e8e6381b929498fac7864f4a7 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 10 Dec 2020 03:11:38 -0800 Subject: [PATCH 2/3] DROP ME: update test to reflect expected behavior The tests now show SOCKS v4 and v5 messages successfully received. --- test/lisp/net/socks-tests.el | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/test/lisp/net/socks-tests.el b/test/lisp/net/socks-tests.el index 601da494a26..af310b8e6e9 100644 --- a/test/lisp/net/socks-tests.el +++ b/test/lisp/net/socks-tests.el @@ -29,11 +29,11 @@ socks-filter-test-existing-behavior-v4 (socks-filter proc "\42") ; ?\" 34 (ert-info ("State transitions to complete (proto length check passes)") (should (eq (process-get proc 'socks-state) socks-state-connected))) - (ert-info ("Response field holds last scratch with new segment prepended") - (should (string= "\"\0Z\0\0]¸Ø" (process-get proc 'socks-response)))) + (ert-info ("Response field holds last scratch with new segment appended") + (should (string= "\0Z\0\0]¸Ø\"" (process-get proc 'socks-response)))) (ert-info ("Scratch remains populated, matches response field") - (should (string= "\"\0Z\0\0]¸Ø" (process-get proc 'socks-scratch))))) - (should (equal (string-to-vector "\"\0Z\0\0]¸Ø") [34 0 90 0 0 93 184 216])) + (should (string= "\0Z\0\0]¸Ø\"" (process-get proc 'socks-scratch))))) + (should (equal (string-to-vector "\0Z\0\0]¸Ø\"") [0 90 0 0 93 184 216 34])) (delete-process proc) (set-process-query-on-exit-flag proc nil) (kill-buffer buf))) @@ -64,19 +64,30 @@ socks-filter-test-existing-behavior-v5 (ert-info ("Scratch field holds partial payload of pending msg") (should (string= "\5\0\0\4\x26\x05\xbc\x80\x30\x10\x00\x60" (process-get proc 'socks-scratch))))) - (ert-info ("Last part arrives") - (ert-info ("Error raised because parsing logic expects appended bytes") - (let ((err (should-error (socks-filter proc "\xde\xad\xbe\xef\xca\xfe\xfe\xd9")))) - (should (equal err '(wrong-type-argument number-or-marker-p nil))))) - (ert-info ("State untouched (still waiting)") + (ert-info ("Second part arrives") + (socks-filter proc "\xde\xad\xbe\xef\xca\xfe\xfe\xd9") + (ert-info ("State untouched") (should (eq (process-get proc 'socks-state) socks-state-waiting))) (ert-info ("Response field untouched") (should-not (process-get proc 'socks-response))) - (ert-info ("Scratch contains new arrival prepended") - (should (string= (concat "\xde\xad\xbe\xef\xca\xfe\xfe\xd9" - "\5\0\0\4" - "\x26\x05\xbc\x80\x30\x10\x00\x60") + (ert-info ("Scratch contains new arrival appended") + (should (string= (concat "\5\0\0\4" + "\x26\x05\xbc\x80\x30\x10\x00\x60" + "\xde\xad\xbe\xef\xca\xfe\xfe\xd9") (process-get proc 'socks-scratch))))) + (ert-info ("Final part arrives (port number)") + (socks-filter proc "\0\0") + (ert-info ("State transitions to complete") + (should (eq (process-get proc 'socks-state) socks-state-connected))) + (ert-info ("Scratch contains final part appended") + (should (string= (concat "\5\0\0\4" + "\x26\x05\xbc\x80\x30\x10\x00\x60" + "\xde\xad\xbe\xef\xca\xfe\xfe\xd9" + "\0\0") + (process-get proc 'socks-scratch)))) + (ert-info ("Response field updated with final message") + (should (string= (process-get proc 'socks-response) + (process-get proc 'socks-scratch))))) (delete-process proc) (set-process-query-on-exit-flag proc nil) (kill-buffer buf))) -- 2.28.0