Reuse the installer worker group when creating its service user
This commit is contained in:
1 parent
10e8a9d90d
commit
469c1817ff
2 files changed
+49
-3
No files matched your search
@@ -14,7 +14,7 @@ from deploy.panel_installer.config import (
|
||||
read_password,
|
||||
read_plan,
|
||||
)
|
||||
from deploy.panel_installer.engine import Installer
|
||||
from deploy.panel_installer.engine import Installer, install_worker
|
||||
from deploy.panel_installer.web import Wizard, WizardHandler, form_plan
|
||||
|
||||
PROXY = {
|
||||
@@ -27,6 +27,49 @@ ADMIN = {"username": "operator", "email": "ops@example.net"}
|
||||
|
||||
|
||||
class InstallerParametersTests(unittest.TestCase):
|
||||
def test_worker_can_join_its_existing_private_group(self):
|
||||
name = "coulobre-operator"
|
||||
service = f"{name}-worker.service"
|
||||
account = SimpleNamespace(
|
||||
pw_gid=983,
|
||||
pw_uid=984,
|
||||
pw_dir="/nonexistent",
|
||||
pw_shell="/usr/sbin/nologin",
|
||||
)
|
||||
with (
|
||||
patch(
|
||||
"deploy.panel_installer.engine.pwd.getpwnam",
|
||||
side_effect=[KeyError, account],
|
||||
),
|
||||
patch(
|
||||
"deploy.panel_installer.engine.grp.getgrnam",
|
||||
return_value=SimpleNamespace(gr_gid=983),
|
||||
),
|
||||
patch(
|
||||
"deploy.panel_installer.engine.os.getgrouplist",
|
||||
return_value=[983],
|
||||
),
|
||||
patch("deploy.panel_installer.engine.run") as run,
|
||||
patch("deploy.panel_installer.engine.install_unit"),
|
||||
):
|
||||
self.assertEqual(
|
||||
install_worker(name, name, f"{name}-apply", service),
|
||||
service,
|
||||
)
|
||||
run.assert_called_once_with(
|
||||
"useradd",
|
||||
"--system",
|
||||
"--gid",
|
||||
"983",
|
||||
"--no-create-home",
|
||||
"--home-dir",
|
||||
"/nonexistent",
|
||||
"--shell",
|
||||
"/usr/sbin/nologin",
|
||||
name,
|
||||
label=f"Create service user {name}",
|
||||
)
|
||||
|
||||
def test_default_health_targets_follow_locally_installed_roles(self):
|
||||
cases = (
|
||||
({}, None, []),
|
||||
|
||||
Reference in new issue
Block a user