BuildEWSQuery

Returns an EWS query according to the automation's arguments.

python · Microsoft Exchange On-Premise

Details

IDBuildEWSQuery
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsews

README

Returns an EWS query according to the automation’s arguments.

Script Data


Name Description
Script Type python
Tags ews

Inputs


Argument Name Description
from The value of the email’s From attribute.
subject The value of the email’s Subject attribute.
attachmentName The value of the email’s attachmentName attribute.
body The value of the email’s Body attribute.
searchThisWeek Whether to limit the search to the current week. Must be “true” or “false”.
stripSubject Removes the prefix from the subject of reply and forward messages (e.g., FW:).
escapeSemicolons Whether to escape the semicolons. Must be “true” or “false”.

Outputs


Path Description Type
EWS.Query The result query. string
import pytest

DEMISTO_ARGS: dict = {
    "stripSubject": "True",
    "escapeColons": "False",
    "searchThisWeek": "true",
    "from": "my_test_mail@test.com",
    "subject": "test",
    "body": "this is a test",
}
EXPECTED_RESULTS = 'From:"my_test_mail@test.com" AND Subject:"test" AND Body:"this is a test" AND Received:"this week"'


@pytest.mark.parametrize(
    "args, expected_results",
    [
        (DEMISTO_ARGS, EXPECTED_RESULTS),
    ],
)
def test_build_ews_query(args, expected_results):
    """
    Given:
        - args dictionary.

    When:
        - running BuildEWSQuery script.

    Then:
        - Ensure that the query was built correctly.

    """
    from BuildEWSQuery import build_ews_query

    results = build_ews_query(args)
    assert expected_results == results.readable_output