-
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.
Adding new test descriptions and revising already documented tests
- Loading branch information
1 parent
8fc9587
commit 2cfac29
Showing
13 changed files
with
514 additions
and
257 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 |
---|---|---|
@@ -1,3 +1,52 @@ | ||
''' | ||
copyright: Copyright (C) 2015-2021, Wazuh Inc. | ||
Created by Wazuh, Inc. <[email protected]>. | ||
This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
type: integration | ||
brief: These tests will check if the 'wazuh-authd' daemon correctly responds to the enrollment requests | ||
messages respecting the valid option values used in the force configuration block. | ||
tier: 0 | ||
modules: | ||
- authd | ||
components: | ||
- manager | ||
daemons: | ||
- wazuh-authd | ||
- wazuh-db | ||
os_platform: | ||
- linux | ||
os_version: | ||
- Arch Linux | ||
- Amazon Linux 2 | ||
- Amazon Linux 1 | ||
- CentOS 8 | ||
- CentOS 7 | ||
- CentOS 6 | ||
- Ubuntu Focal | ||
- Ubuntu Bionic | ||
- Ubuntu Xenial | ||
- Ubuntu Trusty | ||
- Debian Buster | ||
- Debian Stretch | ||
- Debian Jessie | ||
- Debian Wheezy | ||
- Red Hat 8 | ||
- Red Hat 7 | ||
- Red Hat 6 | ||
tags: | ||
- enrollment | ||
''' | ||
import os | ||
import time | ||
import pytest | ||
|
@@ -54,9 +103,56 @@ def get_current_test_case(request): | |
def test_authd_force_options(get_current_test_case, configure_local_internal_options_module, override_authd_force_conf, | ||
insert_pre_existent_agents, file_monitoring, restart_authd_function, | ||
wait_for_authd_startup_function, connect_to_sockets_function, tear_down): | ||
''' | ||
description: | ||
Check that every input message in authd port generates the adequate output. | ||
wazuh_min_version: | ||
4.3.0 | ||
parameters: | ||
- get_current_test_case: | ||
type: fixture | ||
brief: gets the current test case from the tests' list | ||
- configure_local_internal_options_module: | ||
type: fixture | ||
brief: Configure the local internal options file. | ||
- override_authd_force_conf: | ||
type: fixture | ||
brief: Modified the authd configuration options. | ||
- insert_pre_existent_agents: | ||
type: fixture | ||
brief: adds the required agents to the client.keys and global.db | ||
- file_monitoring: | ||
type: fixture | ||
brief: Handle the monitoring of a specified file. | ||
- restart_authd_function: | ||
type: fixture | ||
brief: stops the wazuh-authd daemon. | ||
- wait_for_authd_startup_function: | ||
type: fixture | ||
brief: Waits until Authd is accepting connections. | ||
- connect_to_sockets_function: | ||
type: fixture | ||
brief: Bind to the configured sockets at function scope. | ||
- tear_down: | ||
type: fixture | ||
brief: Roll back the daemon and client.keys state after the test ends. | ||
assertions: | ||
- The received output must match with expected. | ||
- Verifies the registration responses. | ||
input_description: | ||
Different test cases are contained in external YAML files (valid_config folder) which includes | ||
different possible values for the current authd settings. | ||
expected_output: | ||
- Registration request responses on Authd socket. | ||
''' | ||
|
||
authd_sock = receiver_sockets[0] | ||
validate_authd_logs(get_current_test_case.get('log', []), log_monitor) | ||
validate_authd_logs(get_current_test_case.get('log', [])) | ||
|
||
for stage in get_current_test_case['test_case']: | ||
# Reopen socket (socket is closed by manager after sending message with client key) | ||
|
@@ -70,4 +166,4 @@ def test_authd_force_options(get_current_test_case, configure_local_internal_opt | |
raise ConnectionResetError('Manager did not respond to sent message!') | ||
result, err_msg = validate_authd_response(response, stage['output']) | ||
assert result == 'success', f"Failed stage '{stage['description']}': {err_msg} Complete response: '{response}'" | ||
validate_authd_logs(stage.get('log', []), log_monitor) | ||
validate_authd_logs(stage.get('log', [])) |
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 |
---|---|---|
@@ -1,3 +1,51 @@ | ||
''' | ||
copyright: Copyright (C) 2015-2021, Wazuh Inc. | ||
Created by Wazuh, Inc. <[email protected]>. | ||
This program is free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
type: integration | ||
brief: These tests will check if a set of wrong configuration option values in the block force | ||
are warned in the logs file. | ||
tier: 0 | ||
modules: | ||
- authd | ||
components: | ||
- manager | ||
daemons: | ||
- wazuh-authd | ||
os_platform: | ||
- linux | ||
os_version: | ||
- Arch Linux | ||
- Amazon Linux 2 | ||
- Amazon Linux 1 | ||
- CentOS 8 | ||
- CentOS 7 | ||
- CentOS 6 | ||
- Ubuntu Focal | ||
- Ubuntu Bionic | ||
- Ubuntu Xenial | ||
- Ubuntu Trusty | ||
- Debian Buster | ||
- Debian Stretch | ||
- Debian Jessie | ||
- Debian Wheezy | ||
- Red Hat 8 | ||
- Red Hat 7 | ||
- Red Hat 6 | ||
tags: | ||
- enrollment | ||
''' | ||
import os | ||
import pytest | ||
from wazuh_testing.tools import LOG_FILE_PATH | ||
|
@@ -48,6 +96,42 @@ def get_current_test_case(request): | |
|
||
def test_authd_force_options_invalid_config(get_current_test_case, configure_local_internal_options_module, | ||
override_authd_force_conf, file_monitoring, tear_down): | ||
''' | ||
description: | ||
Check that every input with a wrong configuration option value | ||
matches the adequate output log. None force registration | ||
or response message is made. | ||
wazuh_min_version: | ||
4.3.0 | ||
parameters: | ||
- get_current_test_case: | ||
type: fixture | ||
brief: gets the current test case from the tests' list | ||
- configure_local_internal_options_module: | ||
type: fixture | ||
brief: Configure the local internal options file. | ||
- override_authd_force_conf: | ||
type: fixture | ||
brief: Modified the authd configuration options. | ||
- file_monitoring: | ||
type: fixture | ||
brief: Handle the monitoring of a specified file. | ||
- tear_down: | ||
type: fixture | ||
brief: Roll back the daemon and client.keys state after the test ends. | ||
assertions: | ||
- The received output must match with expected due to wrong configuration options. | ||
input_description: | ||
Different test cases are contained in an external YAML file (invalid_config folder) which includes | ||
different possible wrong settings. | ||
expected_output: | ||
- Invalid configuration values error. | ||
''' | ||
|
||
truncate_file(LOG_FILE_PATH) | ||
try: | ||
|
@@ -56,4 +140,4 @@ def test_authd_force_options_invalid_config(get_current_test_case, configure_loc | |
pass | ||
else: | ||
raise Exception("Authd started when it was expected to fail") | ||
validate_authd_logs(get_current_test_case.get('log', []), log_monitor) | ||
validate_authd_logs(get_current_test_case.get('log', [])) |
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
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
Oops, something went wrong.