Files
@ 814be5def61d
Branch filter:
Location: majic-ansible-roles/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py - annotation
814be5def61d
2.8 KiB
text/x-python
MAR-189: Added support for Debian 11 Bullseye to xmpp_server role:
- Roll-out LDAP client configuration since Bullseye does not come with
a stock one at /etc/ldap/ldap.conf that sets the trust anchor
correctly for validating LDAP server certificates.
- Drop the backports pinning in case of Bullseye (for now let's try to
keep the Buster and Bullseye at same versions for simplicity).
- Drop installation of Python apt bindings (no longer used).
- Tests for Buster and Bullseye need to be split-up a bit due to some
differences around backports etc.
- Roll-out LDAP client configuration since Bullseye does not come with
a stock one at /etc/ldap/ldap.conf that sets the trust anchor
correctly for validating LDAP server certificates.
- Drop the backports pinning in case of Bullseye (for now let's try to
keep the Buster and Bullseye at same versions for simplicity).
- Drop installation of Python apt bindings (no longer used).
- Tests for Buster and Bullseye need to be split-up a bit due to some
differences around backports etc.
6e57b636d3a7 6e57b636d3a7 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e d62b3adec462 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 88290d45ad87 0b4f215b3b4e 619c33cd4857 619c33cd4857 d752715bb533 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 88290d45ad87 0b4f215b3b4e d752715bb533 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e d752715bb533 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e d752715bb533 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e eeec809e0f90 eeec809e0f90 88290d45ad87 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e d752715bb533 d752715bb533 a718023f9e76 364c0adf308e d752715bb533 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 0b4f215b3b4e 88290d45ad87 364c0adf308e 0b4f215b3b4e 0b4f215b3b4e 364c0adf308e | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory')
def test_gnupg_private_keys_file_content(host):
"""
Tests if correct GnuPG private key used for encryption and signing has been
deployed.
"""
with host.sudo():
gnupg_private_keys = host.file('/etc/duply/main/private_keys.asc')
# The rstrip() is added because Ansible strips last newline
# when using the file lookup plugin.
assert gnupg_private_keys.content_string == open('tests/data/gnupg/parameters-mandatory.asc', 'r').read().rstrip()
def test_gnupg_public_keys_file_content(host):
"""
Tests if no additional public GnuPG keys have been deployed (should be
default without optional parameters).
"""
with host.sudo():
gnupg_public_keys = host.file('/etc/duply/main/public_keys.asc')
assert gnupg_public_keys.content_string == ""
def test_backup_ssh_key_file_content(host):
"""
Tests if correct key has been deployed for SSH client authentication.
"""
with host.sudo():
ssh_key = host.file('/etc/duply/main/ssh/identity')
assert ssh_key.content_string == open('tests/data/ssh/parameters-mandatory', 'r').read()
def test_known_hosts_content(host):
"""
Tests if known hosts file has been set-up with correct content.
"""
with host.sudo():
known_hosts = host.file('/etc/duply/main/ssh/known_hosts')
assert known_hosts.content_string == open('tests/data/ssh/parameters-mandatory-known_hosts', 'r').read()
def test_duply_configuration_content(host):
"""
Tests if duply configuration has been set-up correctly.
"""
hostname = host.run('hostname').stdout.strip()
with host.sudo():
duply_configuration = host.file('/etc/duply/main/conf')
assert "GPG_KEYS_ENC='59C26F031A129C54'" in duply_configuration.content_string
assert "GPG_KEY_SIGN='59C26F031A129C54'" in duply_configuration.content_string
assert "TARGET='pexpect+sftp://bak-%s@192.168.56.10:2222//duplicity'" % hostname in duply_configuration.content_string
assert "DUPL_PARAMS=\"$DUPL_PARAMS --ssh-options='-oLogLevel=ERROR -oUserKnownHostsFile=/dev/null " \
"-oGlobalKnownHostsFile=/etc/duply/main/ssh/known_hosts -oIdentityFile=/etc/duply/main/ssh/identity'\"" in duply_configuration.content_string
def test_duply_gnupg_keyring_private_keys(host):
"""
Tests if private key used for encryption/signing has been correctly
imporeted into Duply GnuPG keyring.
"""
with host.sudo():
private_key_listing = host.run('gpg --homedir /etc/duply/main/gnupg --list-public-keys')
assert private_key_listing.rc == 0
assert '59C26F031A129C54' in private_key_listing.stdout
|