aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/tests/test_dotfiles.py
blob: cd6e474a227463c0710981cfec5555bc7705e457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# SPDX-License-Identifier: GPL-3.0-or-later
"""Post-install checks: dotfiles stowed for the user.

Parity port of validate_dotfiles from validation.sh: .zshrc must be a symlink
into the ~/.dotfiles stow tree, not broken, and readable by the user (not just
root).
"""

import pytest


@pytest.mark.attribution("archsetup")
def test_zshrc_stowed_and_readable(host, target_user):
    zshrc = host.file("/home/%s/.zshrc" % target_user)
    assert zshrc.is_symlink, ".zshrc should be a stow symlink"
    assert ".dotfiles/" in zshrc.linked_to, "symlink should point into ~/.dotfiles"
    assert zshrc.exists, "symlink target must exist (not broken)"
    # Readable by the user, not only root.
    assert host.run("sudo -u %s test -r %s" % (target_user, zshrc.path)).rc == 0