aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/tests/test_keyring.py
blob: 99d322d255f39a33008fa31c8e0e754610c2c655 (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
35
# SPDX-License-Identifier: GPL-3.0-or-later
"""Post-install checks: gnome-keyring pre-configuration.

Parity port of validate_gnome_keyring_setup: the keyrings dir must exist, be
mode 700, owned by the user, with the default keyring set to "login".
"""

import pytest


@pytest.fixture(scope="session")
def keyring_dir(home):
    return "%s/.local/share/keyrings" % home


@pytest.mark.attribution("archsetup")
def test_keyring_dir_exists(host, keyring_dir):
    assert host.file(keyring_dir).is_directory


@pytest.mark.attribution("archsetup")
def test_keyring_dir_mode_700(host, keyring_dir):
    assert host.file(keyring_dir).mode == 0o700


@pytest.mark.attribution("archsetup")
def test_keyring_dir_owned_by_user(host, keyring_dir, target_user):
    assert host.file(keyring_dir).user == target_user


@pytest.mark.attribution("archsetup")
def test_default_keyring_is_login(host, keyring_dir):
    default = host.file("%s/default" % keyring_dir)
    assert default.exists, "default keyring file missing"
    assert default.content_string.strip() == "login"