Files @ 770551dc8c6f
Branch filter:

Location: majic-ansible-roles/roles/ldap_client/molecule/default/tests/test_default.py

branko
MAR-148: Improve the SSH connectivity tests in backup_server role to be more reliable:

- Introduce a session-level fixture for setting permissions for client
SSH private keys (fixes errors related to SSH requesting tighter
permissions).
- Add assertions for the tests that verify the backup clients cannot
connect to the regular SSH server in case the SSH private keys do
not have correct permissions (just in case).
import os

import testinfra.utils.ansible_runner


testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-*')


def test_installed_packages(host):
    """
    Tests if correct packages are installed.
    """

    assert host.package('ldap-utils').is_installed


def test_ldap_configuration_file(host):
    """
    Tests if LDAP configuration files has been deployed with correct
    permissions.
    """

    config = host.file('/etc/ldap/ldap.conf')

    assert config.is_file
    assert config.user == 'root'
    assert config.group == 'root'
    assert config.mode == 0o644