aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/tests/test_users.py
blob: c0097eda1b30e5c4ade6df76b1186cfd0301a59f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-License-Identifier: GPL-3.0-or-later
"""Post-install checks: the user account archsetup creates.

Parity port of validate_user_created / validate_user_shell / validate_user_groups.
"""

import pytest


# Groups archsetup adds: wheel (useradd -G), the usermod -aG set, and docker
# (added later in the developer-workstation step).
EXPECTED_GROUPS = [
    "wheel", "sys", "adm", "network", "scanner", "power", "uucp",
    "audio", "lp", "rfkill", "video", "storage", "optical", "users", "docker",
]


@pytest.mark.smoke
@pytest.mark.attribution("archsetup")
def test_user_exists(host, target_user):
    assert host.user(target_user).exists


@pytest.mark.attribution("archsetup")
def test_user_shell_is_zsh(host, target_user):
    # archsetup may set either path depending on how zsh resolves.
    assert host.user(target_user).shell in ("/bin/zsh", "/usr/bin/zsh")


@pytest.mark.attribution("archsetup")
@pytest.mark.parametrize("group", EXPECTED_GROUPS)
def test_user_in_group(host, target_user, group):
    # Parametrized so a failure names the exact missing group.
    assert group in host.user(target_user).groups