-
Notifications
You must be signed in to change notification settings - Fork 32
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
Added test descriptions for documentation. #2176
Merged
DProvinciani
merged 2 commits into
dev-9550-authd-replacement-configurations-improvement
from
dev-2154-tests_documentation
Nov 4, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,12 +394,14 @@ def duplicate_name_agent_delete_test(server): | |
def test_ossec_authd_agents_ctx_main(get_configuration, set_up_groups, configure_environment, | ||
configure_sockets_environment, connect_to_sockets_module): | ||
''' | ||
description: Check if when the 'wazuh-authd' daemon receives an enrollment request from an agent | ||
that has an IP address or name that is already registered, 'authd' creates a record | ||
for the new agent and deletes the old one. In this case, the enrollment requests | ||
are sent to an IP v4 network socket. | ||
description: | ||
Check if when the 'wazuh-authd' daemon receives an enrollment request from an agent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. I found the same typo in other files too. |
||
that has an IP address or name that is already registered, 'authd' creates a record | ||
for the new agent and deletes the old one. In this case, the enrollment requests | ||
are sent to an IP v4 network socket. | ||
|
||
wazuh_min_version: 4.2.0 | ||
wazuh_min_version: | ||
4.2.0 | ||
|
||
parameters: | ||
- get_configuration: | ||
|
@@ -422,8 +424,9 @@ def test_ossec_authd_agents_ctx_main(get_configuration, set_up_groups, configure | |
- Verify that agents using an already registered IP address can successfully enroll. | ||
- Verify that agents using an already registered name can successfully enroll. | ||
|
||
input_description: Different test cases are contained in an external YAML file (wazuh_conf.yaml) | ||
which includes configuration settings for the 'wazuh-authd' daemon. | ||
input_description: | ||
Different test cases are contained in an external YAML file (wazuh_conf.yaml) | ||
which includes configuration settings for the 'wazuh-authd' daemon. | ||
|
||
expected_output: | ||
- r'Accepting connections on port 1515' (When the 'wazuh-authd' daemon is ready to accept enrollments) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this was written in this way before you created this PR, but taking advantage of the PR to improve the documentation, I would say
different types
instead ofdifferent kinds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation, I overlooked. Changed!