mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
rename mailname to mail_domain everywhere
This commit is contained in:
@@ -9,7 +9,7 @@ def read_config(inipath):
|
||||
class Config:
|
||||
def __init__(self, inipath, params):
|
||||
self._inipath = inipath
|
||||
self.mailname = self.mail_domain = params["mailname"]
|
||||
self.mail_domain = params["mail_domain"]
|
||||
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
||||
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
||||
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
||||
@@ -23,12 +23,12 @@ class Config:
|
||||
return open(self._inipath, "rb")
|
||||
|
||||
|
||||
def write_initial_config(inipath, mailname):
|
||||
def write_initial_config(inipath, mail_domain):
|
||||
from importlib.resources import files
|
||||
|
||||
inidir = files(__package__).joinpath("ini")
|
||||
content = inidir.joinpath("chatmail.ini.f").read_text().format(mailname=mailname)
|
||||
if mailname.endswith(".testrun.org"):
|
||||
content = inidir.joinpath("chatmail.ini.f").read_text().format(mail_domain=mail_domain)
|
||||
if mail_domain.endswith(".testrun.org"):
|
||||
override_inipath = inidir.joinpath("override-testrun.ini")
|
||||
privacy = iniconfig.IniConfig(override_inipath)["privacy"]
|
||||
lines = []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[params]
|
||||
|
||||
# mail domain (MUST be set to fully qualified chat mail domain)
|
||||
mailname = {mailname}
|
||||
mail_domain = {mail_domain}
|
||||
|
||||
#
|
||||
# If you only do private test deploys, you don't need to modify any settings below
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import json
|
||||
import random
|
||||
|
||||
mailname_path = "/etc/mailname"
|
||||
mail_domain_path = "/etc/mailname"
|
||||
|
||||
|
||||
def create_newemail_dict(domain):
|
||||
@@ -16,7 +16,7 @@ def create_newemail_dict(domain):
|
||||
|
||||
|
||||
def print_new_account():
|
||||
domain = open(mailname_path).read().strip()
|
||||
domain = open(mail_domain_path).read().strip()
|
||||
creds = create_newemail_dict(domain=domain)
|
||||
|
||||
print("Content-Type: application/json")
|
||||
|
||||
@@ -13,8 +13,8 @@ from chatmaild.config import read_config, write_initial_config
|
||||
def make_config(tmp_path):
|
||||
inipath = tmp_path.joinpath("chatmail.ini")
|
||||
|
||||
def make_conf(mailname):
|
||||
write_initial_config(inipath, mailname=mailname)
|
||||
def make_conf(mail_domain):
|
||||
write_initial_config(inipath, mail_domain=mail_domain)
|
||||
return read_config(inipath)
|
||||
|
||||
return make_conf
|
||||
@@ -27,7 +27,7 @@ def example_config(make_config):
|
||||
|
||||
@pytest.fixture
|
||||
def maildomain(example_config):
|
||||
return example_config.mailname
|
||||
return example_config.mail_domain
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -3,7 +3,7 @@ from chatmaild.config import read_config
|
||||
|
||||
def test_read_config_basic(make_config):
|
||||
config = make_config("chat.example.org")
|
||||
assert config.mailname == "chat.example.org"
|
||||
assert config.mail_domain == "chat.example.org"
|
||||
assert not config.privacy_supervisor and not config.privacy_mail
|
||||
assert not config.privacy_pdo and not config.privacy_postal
|
||||
|
||||
@@ -11,12 +11,12 @@ def test_read_config_basic(make_config):
|
||||
inipath.write_text(inipath.read_text().replace("60", "37"))
|
||||
config = read_config(inipath)
|
||||
assert config.max_user_send_per_minute == 37
|
||||
assert config.mailname == "chat.example.org"
|
||||
assert config.mail_domain == "chat.example.org"
|
||||
|
||||
|
||||
def test_read_config_testrun(make_config):
|
||||
config = make_config("something.testrun.org")
|
||||
assert config.mailname == "something.testrun.org"
|
||||
assert config.mail_domain == "something.testrun.org"
|
||||
assert len(config.privacy_postal.split("\n")) > 1
|
||||
assert len(config.privacy_supervisor.split("\n")) > 1
|
||||
assert len(config.privacy_pdo.split("\n")) > 1
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_create_newemail_dict():
|
||||
def test_print_new_account(capsys, monkeypatch, maildomain, tmpdir):
|
||||
p = tmpdir.join("mailname")
|
||||
p.write(maildomain)
|
||||
monkeypatch.setattr(chatmaild.newemail, "mailname_path", str(p))
|
||||
monkeypatch.setattr(chatmaild.newemail, "mail_domain_path", str(p))
|
||||
print_new_account()
|
||||
out, err = capsys.readouterr()
|
||||
lines = out.split("\n")
|
||||
|
||||
Reference in New Issue
Block a user