fixes
This commit is contained in:
parent
1819a276cb
commit
e466a03055
@ -2,7 +2,7 @@
|
||||
Description=Chatmail dict proxy for IMAP METADATA
|
||||
|
||||
[Service]
|
||||
ExecStart={execpath} /run/dovecot/metadata.socket vmail {config_path}
|
||||
ExecStart={execpath} /run/dovecot/metadata.socket vmail {config_path} /home/vmail/metadata
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pwd
|
||||
|
||||
import pathlib
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
from socketserver import (
|
||||
@ -145,12 +146,15 @@ class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
||||
|
||||
|
||||
def main():
|
||||
socket, username, config = sys.argv[1:]
|
||||
socket, username, config, metadata_dir = sys.argv[1:]
|
||||
passwd_entry = pwd.getpwnam(username)
|
||||
|
||||
# XXX config is not currently used
|
||||
config = read_config(config)
|
||||
notifier = Notifier()
|
||||
metadata_dir = pathlib.Path(metadata_dir)
|
||||
if not metadata_dir.exists():
|
||||
metadata_dir.mkdir()
|
||||
notifier = Notifier(metadata_dir)
|
||||
|
||||
class Handler(StreamRequestHandler):
|
||||
def handle(self):
|
||||
|
@ -16,6 +16,22 @@ def notifier(tmp_path):
|
||||
return Notifier(metadata_dir)
|
||||
|
||||
|
||||
def test_notifier_persistence(tmp_path):
|
||||
metadata_dir = tmp_path.joinpath("metadata")
|
||||
metadata_dir.mkdir()
|
||||
notifier1 = Notifier(metadata_dir)
|
||||
notifier2 = Notifier(metadata_dir)
|
||||
assert notifier1.get_token(guid="guid00") is None
|
||||
assert notifier2.get_token(guid="guid00") is None
|
||||
|
||||
notifier1.set_token("guid00", "01234")
|
||||
notifier1.set_token("guid03", "456")
|
||||
assert notifier2.get_token("guid00") == "01234"
|
||||
assert notifier2.get_token("guid03") == "456"
|
||||
notifier2.del_token("guid00")
|
||||
assert notifier1.get_token("guid00") is None
|
||||
|
||||
|
||||
def test_handle_dovecot_request_lookup_fails(notifier):
|
||||
res = handle_dovecot_request("Lpriv/123/chatmail", {}, notifier)
|
||||
assert res == "N\n"
|
||||
|
Loading…
Reference in New Issue
Block a user