-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1460 from wazuh/dev-office365-module
Add tests for invalid config of github and office365 modules
- Loading branch information
Showing
12 changed files
with
699 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (C) 2015-2021, Wazuh Inc. | ||
# Created by Wazuh, Inc. <info@wazuh.com>. | ||
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
|
||
def callback_detect_enabled_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'enabled\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_only_future_events_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'only_future_events\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_interval_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'interval\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_curl_max_size_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'curl_max_size\' at module \'github\'. '\ | ||
'The minimum value allowed is 1KB.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_time_delay_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'time_delay\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_org_name_err(line): | ||
if 'wm_github_read(): ERROR: Empty content for tag \'org_name\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_api_token_err(line): | ||
if 'wm_github_read(): ERROR: Empty content for tag \'api_token\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_event_type_err(line): | ||
if 'wm_github_read(): ERROR: Invalid content for tag \'event_type\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_read_err(line): | ||
if 'wm_github_read(): ERROR: Empty content for tag \'api_auth\' at module \'github\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_start_github(line): | ||
if 'wm_github_main(): INFO: Module GitHub started.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def detect_github_start(file_monitor): | ||
"""Detect module github starts after restarting Wazuh. | ||
Args: | ||
file_monitor (FileMonitor): File log monitor to detect events | ||
""" | ||
file_monitor.start(timeout=60, callback=callback_detect_start_github) |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright (C) 2015-2021, Wazuh Inc. | ||
# Created by Wazuh, Inc. <info@wazuh.com>. | ||
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
|
||
def callback_detect_enabled_err(line): | ||
if 'wm_office365_read(): ERROR: Invalid content for tag \'enabled\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_only_future_events_err(line): | ||
if 'wm_office365_read(): ERROR: Invalid content for tag \'only_future_events\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_interval_err(line): | ||
if 'wm_office365_read(): ERROR: Invalid content for tag \'interval\' at module \'office365\'. '\ | ||
'The maximum value allowed is 1 day.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_curl_max_size_err(line): | ||
if 'wm_office365_read(): ERROR: Invalid content for tag \'curl_max_size\' at module \'office365\'. '\ | ||
'The minimum value allowed is 1KB.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_tenant_id_err(line): | ||
if 'wm_office365_read(): ERROR: Empty content for tag \'tenant_id\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_client_id_err(line): | ||
if 'wm_office365_read(): ERROR: Empty content for tag \'client_id\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_client_secret_err(line): | ||
if 'wm_office365_read(): ERROR: Empty content for tag \'client_secret\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_subscription_err(line): | ||
if 'wm_office365_read(): ERROR: Empty content for tag \'subscription\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_read_err(line): | ||
if 'wm_office365_read(): ERROR: Empty content for tag \'api_auth\' at module \'office365\'.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def callback_detect_start_office365(line): | ||
if 'wm_office365_main(): INFO: Module Office365 started.' in line: | ||
return line | ||
return None | ||
|
||
|
||
def detect_office365_start(file_monitor): | ||
"""Detect module office365 starts after restarting Wazuh. | ||
Args: | ||
file_monitor (FileMonitor): File log monitor to detect events | ||
""" | ||
file_monitor.start(timeout=60, callback=callback_detect_start_office365) |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Overview | ||
|
3 changes: 3 additions & 0 deletions
3
docs/tests/integration/test_github/test_configuration/test_invalid.md
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Code documentation | ||
|
||
<!-- ::: tests.integration.test_github.test_configuration.test_invalid --> |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Overview | ||
|
3 changes: 3 additions & 0 deletions
3
docs/tests/integration/test_office365/test_configuration/test_invalid.md
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Code documentation | ||
|
||
<!-- ::: tests.integration.test_office365.test_configuration.test_invalid --> |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2015-2021, Wazuh Inc. | ||
# Created by Wazuh, Inc. <info@wazuh.com>. | ||
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import pytest | ||
|
||
from wazuh_testing.github import detect_github_start | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def wait_for_github_start(get_configuration, request): | ||
# Wait for module github starts | ||
file_monitor = getattr(request.module, 'wazuh_log_monitor') | ||
detect_github_start(file_monitor) |
28 changes: 28 additions & 0 deletions
28
tests/integration/test_github/test_configuration/data/wazuh_conf.yaml
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- tags: | ||
- github_integration | ||
apply_to_modules: | ||
- test_invalid | ||
sections: | ||
- section: github | ||
elements: | ||
- enabled: | ||
value: 'ENABLED' | ||
- only_future_events: | ||
value: 'ONLY_FUTURE_EVENTS' | ||
- interval: | ||
value: 'INTERVAL' | ||
- curl_max_size: | ||
value: 'CURL_MAX_SIZE' | ||
- time_delay: | ||
value: 'TIME_DELAY' | ||
- api_auth: | ||
elements: | ||
- org_name: | ||
value: 'ORG_NAME' | ||
- api_token: | ||
value: 'API_TOKEN' | ||
- api_parameters: | ||
elements: | ||
- event_type: | ||
value: 'EVENT_TYPE' |
Oops, something went wrong.