From 5fb7fdea534419eadedc639a7b7c2f3b650d1330 Mon Sep 17 00:00:00 2001 From: Mauro Malara Date: Mon, 15 Aug 2022 19:33:26 -0300 Subject: [PATCH] fix: test_fim fixed. #2830 --- .../end_to_end/test_fim/data/playbooks/generate_events.yaml | 4 ++-- tests/end_to_end/test_fim/test_fim.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/end_to_end/test_fim/data/playbooks/generate_events.yaml b/tests/end_to_end/test_fim/data/playbooks/generate_events.yaml index 4ddc7c0196..200187088f 100644 --- a/tests/end_to_end/test_fim/data/playbooks/generate_events.yaml +++ b/tests/end_to_end/test_fim/data/playbooks/generate_events.yaml @@ -18,13 +18,13 @@ path: "{{ path }}" state: "{{ state }}" mode: "{{ mode }}" - when: os == "Linux" + when: ansible_system == os - name: "{{ event_description }}" win_file: path: "{{ path }}" state: "{{ state }}" - when: os == ansible_facts['os_family'] + when: ansible_facts['os_family'] == os - name: Get alerts hosts: wazuh-manager diff --git a/tests/end_to_end/test_fim/test_fim.py b/tests/end_to_end/test_fim/test_fim.py index d46bb6dd33..6adaee3e48 100644 --- a/tests/end_to_end/test_fim/test_fim.py +++ b/tests/end_to_end/test_fim/test_fim.py @@ -28,13 +28,14 @@ def test_fim(configure_environment, metadata, get_dashboard_credentials, generat rule_level = metadata['rule.level'] rule_description = metadata['rule.description'] syscheck_path = metadata['extra']['syscheck.path'] + timestamp = r'\d+\-\d+\-\w+\:\d+\:\d+\.\d+[+|-]\d+' - expected_alert_json = fr'\{{"timestamp":"(\d+\-\d+\-\w+\:\d+\:\d+\.\d+\+\d+)","rule":{{"level":{rule_level},' \ + expected_alert_json = fr'.*\{{"timestamp":"({timestamp})","rule":{{"level":{rule_level},' \ fr'"description":"{rule_description}","id":"{rule_id}".*"syscheck":{{"path":' \ fr'"{syscheck_path}".*\}}' expected_indexed_alert = fr'.*"path": "{syscheck_path}".*"rule":.*"level": {rule_level},.*"description": ' \ - fr'"{rule_description}".*"timestamp": "(\d+\-\d+\-\w+\:\d+\:\d+\.\d+\+\d+)".*' + fr'"{rule_description}".*"timestamp": "({timestamp})".*' # Check that alert has been raised and save timestamp raised_alert = evm.check_event(callback=expected_alert_json, file_to_monitor=alerts_json,