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

45 lines
1.2 KiB
Python
Raw Normal View History

2021-08-24 16:15:33 +00:00
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
2023-07-26 09:40:24 +00:00
assert path.contains('perl -e \'sleep int(rand(3600))\' && certbot -q renew')
2021-08-24 16:15:33 +00:00
def test_config_file(host):
2023-07-26 09:40:24 +00:00
path = host.file('/etc/letsencrypt/hook-test.local')
2021-08-24 16:15:33 +00:00
assert path.exists
assert path.is_file
assert path.user == 'root'
assert path.group == 'root'
2023-07-26 09:40:24 +00:00
assert path.mode == 0o700
assert path.contains('echo OK > /tmp/test.txt')
2021-08-24 16:15:33 +00:00
def test_renew(host):
2023-07-26 09:40:24 +00:00
cmd = host.run('/etc/letsencrypt/hook-test.local')
2021-08-24 16:15:33 +00:00
assert cmd.succeeded
path = host.file('/tmp/test.txt')
assert path.exists
assert path.is_file
assert path.contains('OK')