"""Role testing files using testinfra.""" import pytest def test_create_users(host): """ Validate user creation """ user = host.user("gooduser") 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}" def test_ssh_key(host): user = host.user("gooduser") 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("gooduser") 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 def test_stow_config(host): user = host.user("gooduser") nvim_config = host.file(user.home + "/.config/nvim/") assert nvim_config.exists admin = host.user("admin") nvim_config = host.file(admin.home + "/.config/nvim/") assert not nvim_config.exists