Ansible_workstation/roles/user/molecule/default/tests/test_default.py

49 lines
1.3 KiB
Python
Raw Normal View History

"""Role testing files using testinfra."""
def test_create_users(host):
""" Validate user creation """
user = host.user("user")
assert user.exists
assert user.uid >= 1000
assert user.shell == "/bin/zsh"
assert user.home == f"/home/{user.name}"
admin = host.user("admin")
assert admin.exists
assert admin.uid < 1000
assert admin.shell == "/bin/bash"
assert admin.home == f"/home/{admin.name}"
2022-01-11 21:20:52 +00:00
def test_ssh_key(host):
user = host.user("user")
sshdir = host.file(user.home + "/.ssh")
assert not sshdir.exists
admin = host.user("admin")
sshdir = host.file(admin.home + "/.ssh")
assert sshdir.exists
autho = host.file(admin.home + "/.ssh/authorized_keys")
assert autho.contains("user1@fool")
def test_clone_dotfiles(host):
user = host.user("user")
dotfiles = host.file(user.home + "/.dotfiles")
assert dotfiles.exists
assert dotfiles.user == user.name
admin = host.user("admin")
dotfiles = host.file(admin.home + "/.dotfiles")
assert dotfiles.exists
assert dotfiles.user == admin.name
2022-01-12 05:06:12 +00:00
def test_stow_config(host):
user = host.user("user")
nvim_config = host.files(user.home + "/.config/nvim/")
assert nvim_config.exists
admin = host.user("admin")
nvim_config = host.files(admin.home + "/.config/nvim/")
assert not nvim_config.exists