From f133174add5a794d79dc896cf3044c63ac8efeb0 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Fri, 22 Jul 2016 10:15:31 +0100 Subject: [PATCH] [Test] Add test for legacy RSPAMC protocol --- test/functional/cases/general.robot | 5 +++++ test/functional/lib/rspamd.py | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/test/functional/cases/general.robot b/test/functional/cases/general.robot index 5fb80520d..8876ef980 100644 --- a/test/functional/cases/general.robot +++ b/test/functional/cases/general.robot @@ -35,3 +35,8 @@ GTUBE - SPAMC ${result} = Spamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} Follow Rspamd Log Should Contain ${result} GTUBE + +GTUBE - RSPAMC + ${result} = Rspamc ${LOCAL_ADDR} ${PORT_NORMAL} ${GTUBE} + Follow Rspamd Log + Should Contain ${result} GTUBE diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index 56356e599..ef7c6e29c 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -41,6 +41,19 @@ def read_log_from_position(filename, offset): size = len(goo) return [goo, size+offset] +def rspamc(addr, port, filename): + mboxgoo = b"From MAILER-DAEMON Fri May 13 19:17:40 2016\r\n" + goo = open(filename, 'rb').read() + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((addr, port)) + s.send(b"CHECK RSPAMC/1.0\r\nContent-length: ") + s.send(str(len(goo+mboxgoo)).encode('utf-8')) + s.send(b"\r\n\r\n") + s.send(mboxgoo) + s.send(goo) + r = s.recv(2048) + return r.decode('utf-8') + def scan_file(addr, port, filename): return str(urlopen("http://%s:%s/symbols?file=%s" % (addr, port, filename)).read()) -- 2.39.5