Skip to content

Commit

Permalink
Merge pull request #2181 from wazuh/1815-qadocs-migrate-test-office365
Browse files Browse the repository at this point in the history
Migrate test_office365 documentation to `qa-docs`
  • Loading branch information
snaow authored Nov 30, 2021
2 parents 2b808ad + aa931d9 commit 45e74cb
Showing 1 changed file with 94 additions and 16 deletions.
110 changes: 94 additions & 16 deletions tests/integration/test_office365/test_configuration/test_invalid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
# 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
'''
copyright: 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
type: integration
brief: The Wazuh 'office365' module allows you to collect all the logs from Office 365 using its API.
Specifically, these tests will check if that module detects invalid configurations and indicates
the location of the errors detected. The Office 365 Management Activity API aggregates actions
and events into tenant-specific content blobs, which are classified by the type and source
of the content they contain.
tier: 0
modules:
- office365
components:
- manager
daemons:
- wazuh-analysisd
- wazuh-monitord
- wazuh-modulesd
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
references:
- https://github.com/wazuh/wazuh-documentation/blob/develop/source/office365/index.rst
- https://github.com/wazuh/wazuh-documentation/blob/develop/source/office365/monitoring-office365-activity.rst
tags:
- office365_configuration
'''
import os
import sys

Expand Down Expand Up @@ -200,19 +253,44 @@ def get_local_internal_options():

def test_invalid(get_local_internal_options, configure_local_internal_options,
get_configuration, configure_environment, reset_ossec_log):
"""
Checks if an invalid configuration is detected
Using invalid configurations with different attributes,
expect an error message and office365 unable to start.
Args:
get_local_internal_options (fixture): Get internal configuration.
configure_local_internal_options (fixture): Set internal configuration for testing.
get_configuration (fixture): Get configurations from the module.
configure_environment (fixture): Configure a custom environment for testing.
reset_ossec_log (fixture): Reset ossec.log and start a new monitor
"""
'''
description: Check if the 'office365' module detects invalid configurations. For this purpose, the test
will configure that module using invalid configuration settings with different attributes.
Finally, it will verify that error events are generated indicating the source of the errors.
wazuh_min_version: 4.2.0
parameters:
- get_local_internal_options:
type: fixture
brief: Get internal configuration.
- configure_local_internal_options:
type: fixture
brief: Set internal configuration for testing.
- get_configuration:
type: fixture
brief: Get configurations from the module.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- reset_ossec_log:
type: fixture
brief: Reset the 'ossec.log' file and start a new monitor.
assertions:
- Verify that the 'office365' module generates error events when invalid configurations are used.
input_description: A configuration template (offic365_integration) is contained in an external YAML file
(wazuh_conf.yaml). That template is combined with different test cases defined in
the module. Those include configuration settings for the 'office365' module.
expected_output:
- r'wm_office365_read(): ERROR.* Invalid content for tag .*'
- r'wm_office365_read(): ERROR.* Empty content for tag .*'
tags:
- invalid_settings
'''
# Configuration error -> ValueError raised
try:
control_service('restart')
Expand Down

0 comments on commit 45e74cb

Please sign in to comment.