summaryrefslogtreecommitdiffstats
path: root/test/functional/util/dummy_fprot.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:30:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:30:40 +0000
commit133a45c109da5310add55824db21af5239951f93 (patch)
treeba6ac4c0a950a0dda56451944315d66409923918 /test/functional/util/dummy_fprot.py
parentInitial commit. (diff)
downloadrspamd-133a45c109da5310add55824db21af5239951f93.tar.xz
rspamd-133a45c109da5310add55824db21af5239951f93.zip
Adding upstream version 3.8.1.upstream/3.8.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/functional/util/dummy_fprot.py')
-rwxr-xr-xtest/functional/util/dummy_fprot.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/functional/util/dummy_fprot.py b/test/functional/util/dummy_fprot.py
new file mode 100755
index 0000000..31ae2c4
--- /dev/null
+++ b/test/functional/util/dummy_fprot.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+import os
+import signal
+import socket
+import socketserver
+import sys
+
+import dummy_killer
+
+PID = "/tmp/dummy_fprot.pid"
+
+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->bar\n")
+ else:
+ self.request.sendall(b"0 <clean> FOO\n")
+ self.request.close()
+
+if __name__ == "__main__":
+
+ HOST = "localhost"
+
+ alen = len(sys.argv)
+ if alen > 1:
+ port = int(sys.argv[1])
+ if alen >= 4:
+ PID = sys.argv[3]
+ foundvirus = bool(sys.argv[2])
+ elif 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()
+
+ dummy_killer.setup_killer(server)
+ dummy_killer.write_pid(PID)
+
+ try:
+ server.handle_request()
+ except socket.error:
+ print("Socket closed")
+ server.server_close()