address review comments: renamed test and using socketserver ThreadingUnixStreamServer

This commit is contained in:
holger krekel
2024-07-22 13:39:34 +02:00
parent 35a0f07887
commit bf0f6e2303
2 changed files with 3 additions and 11 deletions

View File

@@ -1,10 +1,6 @@
import logging import logging
import os import os
from socketserver import ( from socketserver import StreamRequestHandler, ThreadingUnixStreamServer
StreamRequestHandler,
ThreadingMixIn,
UnixStreamServer,
)
class DictProxy: class DictProxy:
@@ -86,12 +82,8 @@ class DictProxy:
except FileNotFoundError: except FileNotFoundError:
pass pass
with ThreadedUnixStreamServer(socket, Handler) as server: with ThreadingUnixStreamServer(socket, Handler) as server:
try: try:
server.serve_forever() server.serve_forever()
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
request_queue_size = 100

View File

@@ -129,7 +129,7 @@ def test_handle_dovecot_protocol_hello_is_skipped(db, example_config, caplog):
assert not caplog.messages assert not caplog.messages
def test_handle_dovecot_protocol(db, example_config): def test_handle_dovecot_protocol_user_not_exists(db, example_config):
dictproxy = AuthDictProxy(db=db, config=example_config) dictproxy = AuthDictProxy(db=db, config=example_config)
rfile = io.BytesIO( rfile = io.BytesIO(
b"H3\t2\t0\t\tauth\nLshared/userdb/foobar@chat.example.org\tfoobar@chat.example.org\n" b"H3\t2\t0\t\tauth\nLshared/userdb/foobar@chat.example.org\tfoobar@chat.example.org\n"