-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac: Remove the extended behavior. #2461
The extended behavior will be used for the full scan test refactor.
- Loading branch information
Luis Gonzalez
committed
Feb 3, 2022
1 parent
b300b14
commit 6a6cfc7
Showing
2 changed files
with
42 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,23 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
from subprocess import CalledProcessError | ||
|
||
import os | ||
import time | ||
import pytest | ||
|
||
from subprocess import CalledProcessError | ||
|
||
import wazuh_testing.db_interface.agent_db as adb | ||
from wazuh_testing.tools import LOG_FILE_PATH | ||
from wazuh_testing.tools.file import truncate_file | ||
from wazuh_testing.tools.monitoring import FileMonitor | ||
from wazuh_testing.tools.services import control_service | ||
from wazuh_testing.modules.vulnerability_detector.utils import clean_vd_tables | ||
from wazuh_testing.mocking import create_mocked_agent, delete_mocked_agent | ||
from wazuh_testing.db_interface import cve_db | ||
from wazuh_testing.mocking import set_system | ||
from wazuh_testing import db_interface as dbi | ||
from wazuh_testing.modules import vulnerability_detector as vd | ||
from wazuh_testing.db_interface import cve_db | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
|
@@ -123,3 +125,37 @@ def clean_cve_tables_func(): | |
cve_db.clean_all_tables() | ||
yield | ||
cve_db.clean_all_tables() | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def prepare_full_scan_environment(metadata): | ||
"""Setup the initial test state. | ||
It cleans the tables before running the test. Then, it mocks a RHEL8 system and inserts the OS information into | ||
the `sys_osinfo` table. Besides, It inserts the packages into the agent's `sys_programs` table. | ||
Finally, It cleans all in the teardown. | ||
Args: | ||
metadata (dict): Test case metadata. | ||
""" | ||
clean_vd_tables() | ||
|
||
# Mock RedHat system | ||
set_system('RHEL8') | ||
# Update sys_osinfo | ||
adb.insert_os_info() | ||
|
||
for package in metadata['package_names']: | ||
adb.insert_package(name=package, vendor=metadata['package_vendor'], | ||
version=metadata['package_version'], source='NULL') | ||
|
||
# Force in order to make the test more stable | ||
adb.update_last_full_scan(0) | ||
|
||
yield | ||
|
||
for package in metadata['package_names']: | ||
adb.delete_package(package) | ||
|
||
clean_vd_tables() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters