ansible-role--sshd/molecule/testinfra/test_login_notifications.py

13 lines
569 B
Python
Raw Permalink Normal View History

2024-07-12 12:38:33 +00:00
import os
import testinfra.utils.commands as commands
def test_login_notification_is_sent():
# Vérifier que la notification a été envoyée
notification_file = os.path.join('/tmp', 'login_notification.json')
assert commands.check_output('test -f {}'.format(notification_file)) == 0
# Vérifier le contenu du fichier de notification
notification_data = json.loads(commands.check_output('cat {}'.format(notification_file)))
assert notification_data['title'] == 'Connexion SSH'
assert notification_data['message'].startswith('Utilisateur')