Explain setup choices and database service failures
This commit is contained in:
1 parent
3812e37d5b
commit
e658bf5b30
6 files changed
+247
-37
No files matched your search
@@ -3,11 +3,13 @@ import shlex
|
||||
import stat
|
||||
import tempfile
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from deploy.panel_installer.cli import save_interactive_plan
|
||||
from deploy.panel_installer.cli import interactive_plan, save_interactive_plan
|
||||
from deploy.panel_installer.config import (
|
||||
InstallError,
|
||||
parse_plan,
|
||||
@@ -15,7 +17,12 @@ from deploy.panel_installer.config import (
|
||||
read_plan,
|
||||
)
|
||||
from deploy.panel_installer.engine import Installer, install_worker
|
||||
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan
|
||||
from deploy.panel_installer.web import (
|
||||
Wizard,
|
||||
WizardHandler,
|
||||
form_plan,
|
||||
installation_form,
|
||||
)
|
||||
|
||||
PROXY = {
|
||||
"hostname": "Panel.Example.NET",
|
||||
@@ -139,6 +146,39 @@ class InstallerParametersTests(unittest.TestCase):
|
||||
self.assertEqual(stat.S_IMODE(path.stat().st_mode), 0o600)
|
||||
self.assertEqual(parse_plan(read_plan(path)), plan)
|
||||
|
||||
def test_interactive_hosting_hints_explain_dns_and_keep_defaults(self):
|
||||
replies = [
|
||||
"",
|
||||
"panel.example.net",
|
||||
"",
|
||||
"",
|
||||
"ops@example.net",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"192.0.2.21",
|
||||
"ns1.example.net",
|
||||
"",
|
||||
]
|
||||
output = StringIO()
|
||||
with (
|
||||
patch("builtins.input", side_effect=replies),
|
||||
redirect_stdout(output),
|
||||
):
|
||||
plan = interactive_plan()
|
||||
|
||||
self.assertEqual(plan.dns.mode, "local")
|
||||
self.assertEqual(plan.mail.mode, "local")
|
||||
self.assertEqual(plan.hosting.public_addresses, ("192.0.2.21",))
|
||||
self.assertEqual(plan.hosting.nameservers, ("ns1.example.net",))
|
||||
self.assertEqual(plan.hosting.mail_sending_addresses, ())
|
||||
self.assertIn("default A and AAAA records", output.getvalue())
|
||||
self.assertIn(
|
||||
"delegation separately at the registrar", output.getvalue()
|
||||
)
|
||||
self.assertIn("SPF and managed mail DNS", output.getvalue())
|
||||
|
||||
def test_browser_and_parameter_file_share_the_same_plan(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
params = Path(folder) / "panel.toml"
|
||||
@@ -260,6 +300,22 @@ class InstallerParametersTests(unittest.TestCase):
|
||||
|
||||
|
||||
class SetupWizardTests(unittest.TestCase):
|
||||
def test_form_hints_are_linked_and_saved_choices_are_restored(self):
|
||||
html = installation_form(
|
||||
{
|
||||
"access": "proxy",
|
||||
"dns_mode": "off",
|
||||
"mail_tls": "provided",
|
||||
"public_addresses": "192.0.2.21",
|
||||
}
|
||||
)
|
||||
for name in ("access", "dns_mode", "mail_tls", "public_addresses"):
|
||||
self.assertIn(f'aria-describedby="{name}-hint"', html)
|
||||
self.assertIn(f'id="{name}-hint"', html)
|
||||
for value in ("proxy", "off", "provided"):
|
||||
self.assertIn(f'<option value="{value}" selected>', html)
|
||||
self.assertIn('value="192.0.2.21"', html)
|
||||
|
||||
def handler(self):
|
||||
handler = WizardHandler.__new__(WizardHandler)
|
||||
handler.server = SimpleNamespace(
|
||||
|
||||
Reference in new issue
Block a user