diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-03-06 16:45:21 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-03-06 16:45:21 +0200 |
commit | b88b679dd797b92ad7cfaa365c130ebd8b2b0dd2 (patch) | |
tree | fecb5291686f00d66b5d3192e2f651d331dd21d2 /test/functional/util | |
parent | efbf2c75c52473088c310dbd5281bfbd0d53d173 (diff) | |
download | rspamd-b88b679dd797b92ad7cfaa365c130ebd8b2b0dd2.tar.gz rspamd-b88b679dd797b92ad7cfaa365c130ebd8b2b0dd2.zip |
[Test] Some tests for antivirus module
Diffstat (limited to 'test/functional/util')
-rwxr-xr-x | test/functional/util/dummy_clam.py | 45 | ||||
-rwxr-xr-x | test/functional/util/dummy_fprot.py | 45 |
2 files changed, 90 insertions, 0 deletions
diff --git a/test/functional/util/dummy_clam.py b/test/functional/util/dummy_clam.py new file mode 100755 index 000000000..8c68889a9 --- /dev/null +++ b/test/functional/util/dummy_clam.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import os +import sys +try: + import SocketServer as socketserver +except: + import socketserver + +class MyTCPHandler(socketserver.BaseRequestHandler): + + def handle(self): + self.data = self.request.recv(1024).strip() + if self.server.foundvirus: + self.request.sendall(b"stream: Eicar-Test-Signature FOUND\0") + else: + self.request.sendall(b"stream: OK\0") + self.request.close() + +if __name__ == "__main__": + pid = os.fork() + if pid > 0: + sys.exit(0) + + HOST = "localhost" + + alen = len(sys.argv) + if alen > 1: + port = int(sys.argv[1]) + if alen >= 3: + foundvirus = bool(sys.argv[2]) + else: + foundvirus = False + else: + port = 3310 + foundvirus = False + + server = socketserver.TCPServer((HOST, port), MyTCPHandler, bind_and_activate=False) + server.allow_reuse_address = True + server.foundvirus = foundvirus + server.server_bind() + server.server_activate() + server.handle_request() + server.server_close() + os.exit(0) diff --git a/test/functional/util/dummy_fprot.py b/test/functional/util/dummy_fprot.py new file mode 100755 index 000000000..01e7e578b --- /dev/null +++ b/test/functional/util/dummy_fprot.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import os +import sys +try: + import SocketServer as socketserver +except: + import socketserver + +class MyTCPHandler(socketserver.BaseRequestHandler): + + def handle(self): + self.data = self.request.recv(1024).strip() + if self.server.foundvirus: + self.request.sendall(b"1 <infected: EICAR_Test_File> FOO\n") + else: + self.request.sendall(b"0 <clean> FOO\n") + self.request.close() + +if __name__ == "__main__": + pid = os.fork() + if pid > 0: + sys.exit(0) + + HOST = "localhost" + + alen = len(sys.argv) + if alen > 1: + port = int(sys.argv[1]) + if alen >= 3: + foundvirus = bool(sys.argv[2]) + else: + foundvirus = False + else: + port = 10200 + foundvirus = False + + server = socketserver.TCPServer((HOST, port), MyTCPHandler, bind_and_activate=False) + server.allow_reuse_address = True + server.foundvirus = foundvirus + server.server_bind() + server.server_activate() + server.handle_request() + server.server_close() + os.exit(0) |