Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FIM test_synchronization according to new standard (1) #2358

Merged
merged 25 commits into from
Dec 21, 2021

Conversation

CamiRomero
Copy link
Contributor

@CamiRomero CamiRomero commented Dec 17, 2021

Related issue
#2320

Description

Changes applied in this PR:

  • We add a new folder called fim_module, the purpose of this is to contain all the things related to FIM module. Inside of this folder we have:

    • fim_synchronization: In this file, we put all the methods and functions that are related to the synchronization of DB
    • fim_variables: In this file, we put all the variables to use related to FIM, in order to not hardcoded code inside the test
  • We add a new conftest.py inside the folder test/integration/test_fim in order to move all the fixtures define in common inside the folders /test_fim, test_files, and test_synchronization
    in order to not duplicate code.

  • We add the auto-configuration of the test in order to not set manually the local internal options.

  • We add a new file called wazuh_variables when we put all the variables to use related to Wazuh in order to not hardcoded code inside the test, and with the purpose of if anything changes that will
    changes just these files and not all the tests that contain the variables

  • We changed the import in order to only import the functions that use in the test and not all the module

  • We changed YAML, now this file only contains one configuration, we note that when we put more than one, the test that does not apply with the configuration will be automatically skipped and this is wrong, if not applied the
    test just not run. When this changes the test only runs nine times and there isn't a skipped test.

  • We delete wazuh_disabled_sync_conf_win32.yaml and created wazuh_sync_conf_yaml with the general config and variables that can be set inside the test. With this change we evited have three different YAML, we only
    need one and set the variables.

  • By default the FIM test run in 3 different modes - scheduled, real-time, who-data, but we have a lot of tests that test only one mode, in this case, we need to specify inside the test the mode, if we do not define this, Pytest
    mark test with skip

  • We redefined test test_sync_disabled_win32.py, we divide it into 4 different cases. In order that can use one YAML and avoid the use of the condition if-else inside the code

Configuration options

Type Format Tag File name
Agent msi 4.3.0 wazuh-agent-4.3.0-0.40302.20211123.msi

Configuration options

syscheck.debug=2
agent.debug=2
monitord.rotate_log=0
windows.debug=2

Test

test_fim/

Test path Execution OS Type Version Date Status Executed by
test_fim/ Jenkins Windows Agent 4.3.0 17/12/2021 🟢 Camila
test_fim/ Jenkins Windows Agent 4.3.0 17/12/2021 🟢 Camila
test_fim/ Jenkins Windows Agent 4.3.0 17/12/2021 🟢 Camila
test_fim/ Local Windows Agent 4.3.0 17/12/2021 🟢 Camila
test_fim/ Local Windows Agent 4.3.0 17/12/2021 🟢 Camila
test_fim/ Local Windows Agent 4.3.0 17/12/2021 🟢 Camila

Tests

  • Proven that tests pass when they have to pass.
  • Proven that tests fail when they have to fail.
  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.
  • Python codebase is documented following the Google Style for Python docstrings.

type: fixture
brief: Remove the test key and restart the agent.
brief: Create the test key.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the configure_local_internal_options_module parameter.

'''
description: Check if the 'wazuh-syscheckd' daemon uses the value of the 'enabled' tag to start/stop
the file/registry synchronization. For this purpose, the test will monitor a directory/key.
Finally, it will verify that no FIM 'integrity' event is generated when the synchronization
is disabled, and verify that the FIM 'integrity' event generated corresponds with a
file or a registry when the synchronization is enabled, depending on the test case.
is disablede.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is disablede.
is disabled.

damarisg
damarisg previously approved these changes Dec 20, 2021
Copy link
Member

@damarisg damarisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ Cami!
I attach Tests Results:

Test path Execution OS Type Version Date Status Executed by
test_fim/test_synchronization/test_registry_responses_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_registry_responses_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_registry_responses_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/ Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/ Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/ Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_disabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_disabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_disabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_registry_enabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_registry_enabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla
test_fim/test_synchronization/test_sync_registry_enabled_win32.py Jenkins Windows Agent 4.3.0 20/12/2021 🟢 Seyla

@damarisg damarisg linked an issue Dec 20, 2021 that may be closed by this pull request
@snaow snaow changed the title 2320 Refactor some Tests synchronization with the new standard Refactor FIM: Tests synchronization according to new standard (1) Dec 20, 2021
@snaow snaow changed the title Refactor FIM: Tests synchronization according to new standard (1) Refactor FIM tests_synchronization according to new standard (1) Dec 20, 2021
@snaow snaow changed the title Refactor FIM tests_synchronization according to new standard (1) Refactor FIM test_synchronization according to new standard (1) Dec 20, 2021
@snaow snaow merged commit eb32b09 into master Dec 21, 2021
@snaow snaow deleted the 2320-refactor-test-synchronization branch December 21, 2021 08:03
@snaow snaow mentioned this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor FIM test_synchronization according to new standard (1)
3 participants