ansible-role-certbot/molecule/default/tests/test_default.py

44 lines
1.2 KiB
Python

import testinfra.utils.ansible_runner
def test_packages(host):
package = host.package('certbot')
assert package.is_installed
def test_acme_directory(host):
path = host.file('/var/www/acme')
assert path.exists
assert path.is_directory
assert path.user == 'root'
assert path.group == 'root'
assert path.mode == 0o755
def test_old_cron_file(host):
path = host.file('/etc/cron.d/certbot')
assert not path.exists
def test_cron_file(host):
path = host.file('/var/spool/cron/crontabs/root')
assert path.exists
assert path.is_file
assert path.user == 'root'
assert path.group == 'crontab'
assert path.mode == 0o600
assert path.contains('perl -e \'sleep int(rand(3600))\' && certbot -q renew')
def test_config_file(host):
path = host.file('/etc/letsencrypt/hook-test.local')
assert path.exists
assert path.is_file
assert path.user == 'root'
assert path.group == 'root'
assert path.mode == 0o700
assert path.contains('echo OK > /tmp/test.txt')
def test_renew(host):
cmd = host.run('/etc/letsencrypt/hook-test.local')
assert cmd.succeeded
path = host.file('/tmp/test.txt')
assert path.exists
assert path.is_file
assert path.contains('OK')