Use the public service hostname for existing mail nodes
This commit is contained in:
1 parent
d81e716ff5
commit
e2489aaa1c
8 files changed
+107
-13
No files matched your search
@@ -9,7 +9,11 @@ from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from deploy.panel_installer.cli import interactive_plan, save_interactive_plan
|
||||
from deploy.panel_installer.cli import (
|
||||
export_parameters,
|
||||
interactive_plan,
|
||||
save_interactive_plan,
|
||||
)
|
||||
from deploy.panel_installer.config import (
|
||||
InstallError,
|
||||
parse_plan,
|
||||
@@ -229,6 +233,72 @@ class InstallerParametersTests(unittest.TestCase):
|
||||
self.assertEqual(plan.mail.host, "192.0.2.41")
|
||||
self.assertEqual(plan.mail.host_key, str(path))
|
||||
self.assertEqual(plan.mail.port, 2222)
|
||||
self.assertEqual(plan.mail.mail_hostname, "")
|
||||
|
||||
def test_existing_mail_node_has_a_separate_public_hostname(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path = Path(folder) / "receiver.pub"
|
||||
path.write_text("ssh-ed25519 fixture-public-host-key\n")
|
||||
web = form_plan(
|
||||
PROXY
|
||||
| ADMIN
|
||||
| {
|
||||
"origin_port": "8080",
|
||||
"mail_mode": "remote",
|
||||
"mail_host": "192.0.2.41",
|
||||
"mail_host_key": str(path),
|
||||
"mail_local_host": "mail.example.net",
|
||||
"mail_sending_addresses": "93.184.215.14",
|
||||
}
|
||||
)
|
||||
inputs = (
|
||||
"custom",
|
||||
"panel.example.net",
|
||||
"acme",
|
||||
ADMIN["username"],
|
||||
ADMIN["email"],
|
||||
"off",
|
||||
"remote",
|
||||
"192.0.2.41",
|
||||
"",
|
||||
str(path),
|
||||
"mail.example.net",
|
||||
"",
|
||||
"93.184.215.14",
|
||||
)
|
||||
with (
|
||||
patch("builtins.input", side_effect=inputs),
|
||||
redirect_stdout(StringIO()),
|
||||
):
|
||||
cli = interactive_plan()
|
||||
for plan in (cli, web):
|
||||
self.assertEqual(plan.mail.host, "192.0.2.41")
|
||||
self.assertEqual(plan.mail.mail_hostname, "mail.example.net")
|
||||
self.assertEqual(
|
||||
parse_plan(export_parameters(plan, None)), plan
|
||||
)
|
||||
with patch(
|
||||
"deploy.panel_installer.engine.platform_settings",
|
||||
return_value=(None, True),
|
||||
):
|
||||
installer = Installer(plan, "test-only", Mock())
|
||||
installer.state = dict.fromkeys(
|
||||
("secret_key", "database_password", "broker_password"),
|
||||
"test-only",
|
||||
)
|
||||
env = dict(
|
||||
line.split("=", 1)
|
||||
for line in installer.environment().splitlines()
|
||||
)
|
||||
self.assertEqual(
|
||||
env["COULOBRE_MAIL_IMAP_HOST"], "mail.example.net"
|
||||
)
|
||||
self.assertEqual(
|
||||
env["COULOBRE_MAIL_SUBMISSION_HOST"], "mail.example.net"
|
||||
)
|
||||
self.assertEqual(
|
||||
env["COULOBRE_MAIL_MX_HOST"], "mail.example.net"
|
||||
)
|
||||
|
||||
def test_remote_bootstrap_shares_a_host_between_roles(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
|
||||
Reference in new issue
Block a user