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

Add integration tests for max_upload_size API option #1494

Merged
merged 8 commits into from
Sep 28, 2021

Conversation

Selutario
Copy link
Contributor

@Selutario Selutario commented Jun 24, 2021

Related issue
#1802 (wazuh/wazuh#9054)

Description

This PR adds a test to verify that a 413 status code (Request Entity Too Large) is returned if the body in an API request is bigger than max_upload_size, which is specified in the api.yaml file.

Configuration options

None

Logs example

============================================================================================ test session starts ============================================================================================
platform linux -- Python 3.9.2, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /wazuh-qa/tests/integration, configfile: pytest.ini
plugins: testinfra-6.4.0, html-3.1.1, testinfra-6.0.0, metadata-1.11.0
collected 4 items                                                                                                                                                                                           

tests/integration/test_api/test_config/test_max_upload_size/test_max_upload_size.py .ss.                                                                                                              [100%]

================================================================================= 2 passed, 2 skipped, 2 warnings in 34.59s =================================================================================

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.
  • The test is documented in wazuh-qa/docs.
  • provision_documentation.sh generate the docs without errors.

Regards,
Selu.

@Selutario Selutario self-assigned this Jun 24, 2021
@Selutario Selutario requested review from vicferpoy and mcarmona99 and removed request for vicferpoy June 28, 2021 08:09
mcarmona99
mcarmona99 previously approved these changes Jun 30, 2021
Copy link
Contributor

@mcarmona99 mcarmona99 left a comment

Choose a reason for hiding this comment

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

LGTM

@Selutario Selutario linked an issue Aug 30, 2021 that may be closed by this pull request
Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

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

GJ, but some changes are required.

Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

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

GJ, only it is necessary to use common repository fixtures.

@Selutario Selutario force-pushed the feature/9054-api-config-max-size branch from ba01375 to 39bc159 Compare September 14, 2021 12:11
@Selutario
Copy link
Contributor Author

Test result after applying daemons_handler changes:

============================================================================================ test session starts ============================================================================================
platform linux -- Python 3.9.6, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /var/ossec/framework/python/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.9.6', 'Platform': 'Linux-5.4.0-84-generic-x86_64-with-glibc2.31', 'Packages': {'pytest': '6.2.5', 'py': '1.10.0', 'pluggy': '1.0.0'}, 'Plugins': {'testinfra': '6.0.0', 'html': '3.1.1', 'metadata': '1.11.0'}}
rootdir: /wazuh-qa/tests/integration, configfile: pytest.ini
plugins: testinfra-6.4.0, html-3.1.1, testinfra-6.0.0, metadata-1.11.0
collected 4 items                                                                                                                                                                                           

wazuh-qa/tests/integration/test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_0-content_size_100-tags_to_apply0] PASSED                          [ 25%]
wazuh-qa/tests/integration/test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_5-content_size_20-tags_to_apply0] PASSED                           [ 50%]
wazuh-qa/tests/integration/test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_40-content_size_10-tags_to_apply0] PASSED                          [ 75%]
wazuh-qa/tests/integration/test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_40-content_size_500-tags_to_apply0] PASSED                         [100%]

============================================================================================= warnings summary ==============================================================================================
test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_0-content_size_100-tags_to_apply0]
test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_5-content_size_20-tags_to_apply0]
test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_40-content_size_10-tags_to_apply0]
test_api/test_config/test_max_upload_size/test_max_upload_size.py::test_max_upload_size[max_upload_size_40-content_size_500-tags_to_apply0]
  /var/ossec/framework/python/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================================================== 4 passed, 4 warnings in 39.84s =======================================================================================

Rebits
Rebits previously approved these changes Sep 15, 2021
Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

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

LGTM

@Rebits
Copy link
Member

Rebits commented Sep 16, 2021

This test seems to work correctly, running without fail.

Local Status Report
R1 🟢 R1
R2 🟢 R2
R3 🟢 R3

@snaow
Copy link
Contributor

snaow commented Sep 28, 2021

LGTM

@snaow snaow merged commit 2ef2134 into master Sep 28, 2021
@snaow snaow deleted the feature/9054-api-config-max-size branch September 28, 2021 07:47
@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.

Update API config integration tests
5 participants