From 3bb77ce91ee9f0b4a26aad3976478a305ce22137 Mon Sep 17 00:00:00 2001 From: DinaMeylakh <72339665+DinaMeylakh@users.noreply.github.com> Date: Thu, 16 May 2024 16:24:12 +0300 Subject: [PATCH] EWSv2 fix html body default behaviour (#34226) EWSv2 fix html body default behaviour #34226 --- .../Integrations/EWSv2/EWSv2.py | 2 +- .../Integrations/EWSv2/EWSv2.yml | 4 ++-- .../Integrations/EWSv2/EWSv2_test.py | 12 ++++++++++++ .../Integrations/EWSv2/README.md | 5 +++-- .../MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md | 6 ++++++ Packs/MicrosoftExchangeOnPremise/pack_metadata.json | 2 +- 6 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md diff --git a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.py b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.py index 7543ee22bdb9..127a2527f274 100644 --- a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.py +++ b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.py @@ -779,7 +779,7 @@ def get_message_for_body_type(body, body_type, html_body): return HTMLBody(html_body) if html_body else Body(body) if body_type.lower() == 'html' and html_body: # When called from 'send-mail' command. return HTMLBody(html_body) - return Body(body) + return Body(body) if (body or not html_body) else HTMLBody(html_body) def send_email_reply_to_mailbox(account, in_reply_to, to, body, subject=None, bcc=None, cc=None, html_body=None, diff --git a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.yml b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.yml index 6a4679435264..b7f829373373 100644 --- a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.yml +++ b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.yml @@ -1042,9 +1042,9 @@ script: - name: replyTo description: The email address specified in the 'reply to' field. - name: body - description: The contents (body) of the email to send. + description: The contents (body) of the email to send. This argument overrides the "htmlBody" argument if the "bodyType" argument is Text. - name: htmlBody - description: HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument. + description: HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument if the "bodyType" argument is HTML. - name: bodyType description: Whether message response body type is Text, or HTML. auto: PREDEFINED diff --git a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2_test.py b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2_test.py index c453b2c60530..ce92f0e69b77 100644 --- a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2_test.py +++ b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2_test.py @@ -816,6 +816,18 @@ def test_get_message_for_body_type_text_body_type_with_no_html_body(): assert result == Body(body) +def test_get_message_for_body_type_text_body_type_with_html_body_no_body(): + """ + Given: html_body, no body, the default 'text' as body_type. + When: Constructing the message body. + Then: Assert that the result is an html body. + """ + html_body = "
This is an HTML body
" + result = get_message_for_body_type('', 'text', html_body) + assert isinstance(result, HTMLBody) + assert result == HTMLBody(html_body) + + def test_parse_physical_address(): assert parse_physical_address(PhysicalAddress(city='New York', country='USA', diff --git a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/README.md b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/README.md index 26e02902096f..ea4d7803ee16 100644 --- a/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/README.md +++ b/Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/README.md @@ -1719,13 +1719,14 @@ Sends an email using EWS. | bcc | A CSV list of email addresses for the 'bcc' field. | Optional | | subject | Subject for the email to be sent. | Required | | replyTo | The email address specified in the 'reply to' field. | Optional | -| body | The contents (body) of the email to send. | Optional | -| htmlBody | HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument. | Optional | +| body | The contents (body) of the email to send. This argument overrides the "htmlBody" argument if the "bodyType" argument is Text. | Optional | +| htmlBody | HTML formatted content (body) of the email to be sent. This argument overrides the "body" argument if the "bodyType" argument is HTML. | Optional | | attachIDs | A CSV list of War Room entry IDs that contain files, and are used to attach files to the outgoing email. For example: attachIDs=15@8,19@8. | Optional | | attachNames | A CSV list of names of attachments to send. Should be the same number of elements as attachIDs. | Optional | | attachCIDs | A CSV list of CIDs to embed attachments within the email itself. | Optional | | raw_message | Raw email message from MimeContent type. | Optional | | from | The email address from which to reply. | Optional | +| bodyType | Whether message response body type is Text or HTML. Default is Text. | Required | #### Context Output diff --git a/Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md b/Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md new file mode 100644 index 000000000000..8f60ea8faa23 --- /dev/null +++ b/Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_6.md @@ -0,0 +1,6 @@ + +#### Integrations + +##### EWS v2 + +Fixed an issue where providing `htmlBody` and not providing `body` arguments to the ***send-mail*** command resulted in an empty email body for the default `bodyType`. \ No newline at end of file diff --git a/Packs/MicrosoftExchangeOnPremise/pack_metadata.json b/Packs/MicrosoftExchangeOnPremise/pack_metadata.json index d51845d08a34..bb3013d95200 100644 --- a/Packs/MicrosoftExchangeOnPremise/pack_metadata.json +++ b/Packs/MicrosoftExchangeOnPremise/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Microsoft Exchange On-Premise", "description": "Exchange Web Services", "support": "xsoar", - "currentVersion": "2.1.5", + "currentVersion": "2.1.6", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",