Skip to content

Commit

Permalink
feat(#4055): Add subscriber defaults parameters and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fdalmaup committed Jun 21, 2023
1 parent e6815e7 commit 5986c53
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- sections:
- section: wodle
attributes:
- name: aws-s3
elements:
- disabled:
value: 'no'
- subscriber:
attributes:
- type: SUBSCRIBER_TYPE
elements:
- external_id:
value: wazuh-qa-integration-tests-external-id
- queue:
value: QUEUE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: security_lake_defaults
description: Security Lake default configurations
configuration_parameters:
SUBSCRIBER_TYPE: security_lake
QUEUE: sqs-security-lake-main-queue
EXTERNAL_ID: wazuh-qa-integration-tests-external-id
metadata:
queue: sqs-security-lake-main-queue
external_id: wazuh-qa-integration-tests-external-id
104 changes: 104 additions & 0 deletions tests/integration/test_aws/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,107 @@ def test_inspector_defaults(
timeout=global_parameters.default_timeout,
callback=event_monitor.callback_detect_all_aws_err,
).result()

# -------------------------------------------- TEST_SUBSCRIBER_DEFAULTS ---------------------------------------------------
# Configuration and cases data
t3_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'service_configuration_defaults.yaml')
t3_cases_path = os.path.join(TEST_CASES_PATH, 'cases_service_defaults.yaml')

# Enabled test configurations
t3_configuration_parameters, t3_configuration_metadata, t3_case_ids = get_test_cases_data(t3_cases_path)
configurations = load_configuration_template(
t3_configurations_path, t3_configuration_parameters, t3_configuration_metadata
)


@pytest.mark.tier(level=0)
@pytest.mark.parametrize('configuration, metadata', zip(configurations, t3_configuration_metadata), ids=t3_case_ids)
def test_service_defaults(
configuration, metadata, load_wazuh_basic_configuration, set_wazuh_configuration, clean_aws_services_db,
configure_local_internal_options_function, truncate_monitored_files, restart_wazuh_function, wazuh_log_monitor
):
"""
description: The module is invoked with the expected parameters and no error occurs.
test_phases:
- setup:
- Load Wazuh light configuration.
- Apply ossec.conf configuration changes according to the configuration template and use case.
- Apply custom settings in local_internal_options.conf.
- Truncate wazuh logs.
- Restart wazuh-manager service to apply configuration changes.
- test:
- Check in the ossec.log that a line has appeared calling the module with correct parameters.
- Check in the ossec.log that no errors occurs.
- teardown:
- Truncate wazuh logs.
- Restore initial configuration, both ossec.conf and local_internal_options.conf.
wazuh_min_version: 4.5.0
parameters:
- configuration:
type: dict
brief: Get configurations from the module.
- metadata:
type: dict
brief: Get metadata from the module.
- load_wazuh_basic_configuration:
type: fixture
brief: Load basic wazuh configuration.
- set_wazuh_configuration:
type: fixture
brief: Apply changes to the ossec.conf configuration.
- clean_aws_services_db:
type: fixture
brief: Delete the DB file before and after the test execution.
- configure_local_internal_options_function:
type: fixture
brief: Apply changes to the local_internal_options.conf configuration.
- truncate_monitored_files:
type: fixture
brief: Truncate wazuh logs.
- restart_wazuh_daemon_function:
type: fixture
brief: Restart the wazuh service.
- wazuh_log_monitor:
type: fixture
brief: Return a `ossec.log` monitor.
assertions:
- Check in the log that the module was called with correct parameters.
- Check in the log that no errors occurs.
input_description:
- The `configuration_defaults` file provides the module configuration for this test.
- The `cases_defaults` file provides the test cases.
"""
log_groups = metadata.get('log_group_name')

parameters = [
'wodles/aws/aws-s3',
'--service', metadata['service_type'],
'--aws_profile', 'qa',
'--regions', 'us-east-1',
'--debug', '2'
]

if log_groups is not None:
parameters.insert(7, log_groups)
parameters.insert(7, '--aws_log_groups')

# Check AWS module started
wazuh_log_monitor.start(
timeout=global_parameters.default_timeout,
callback=event_monitor.callback_detect_aws_module_start,
error_message='The AWS module did not start as expected',
).result()

# Check command was called correctly
wazuh_log_monitor.start(
timeout=global_parameters.default_timeout,
callback=event_monitor.callback_detect_aws_module_called(parameters),
error_message='The AWS module was not called with the correct parameters',
).result()

# Detect any ERROR message
with pytest.raises(TimeoutError):
wazuh_log_monitor.start(
timeout=global_parameters.default_timeout,
callback=event_monitor.callback_detect_all_aws_err,
).result()

0 comments on commit 5986c53

Please sign in to comment.