MattermostAskUser
Ask a user a question on Mattermost and expect a response. The response can also close a task (might be conditional) in a playbook.
python · Mattermost
Details
| ID | MattermostAskUser |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Tags | mattermost |
README
Ask a user a question on Mattermost and expect a response. The response can also close a task (might be conditional) in a playbook.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | mattermost |
| Cortex XSOAR Version | 5.0.0 |
Dependencies
This script uses the following commands and scripts.
- send-notification
Inputs
| Argument Name | Description |
|---|---|
| user | The Mattermost user to ask. Can be either an email or Mattermost username. |
| message | The message to ask the user. |
| option1 | First option for a user reply. “yes” is the default. |
| option2 | Second option for the user reply. “no” is the default. |
| task | Which task should we close with the reply. If none, then no playbook tasks will be closed. |
| replyEntriesTag | Tag to add on email reply entries. |
| persistent | Indicates whether to use one-time entitlement or a persistent one. |
| reply | The reply to send to the user. Use the templates {user} and {response} to incorporate these in the reply. (i.e., “Thank you **{user}**. You have answered **{response}**.”). |
| lifetime | Time until the question expires. For example - 1 day. When it expires, a default response is sent. Default value is 1 day. |
| defaultResponse | Default response in case the question expires. |
Outputs
There are no outputs for this script.
import demistomock as demisto import pytest from CommonServerPython import * def test_MattermostAskUser_with_error(mocker): """ Given: - Execute the MattermostAskUser command. When: - The execute command ('addEntitlement') result has an error entry. Then: - Validating the results and the calling to sys.exit after. """ from MattermostAskUser import main execute_command_res = [{"Contents": [], "Type": EntryType.ERROR}] mocker.patch.object(demisto, "executeCommand", return_value=execute_command_res) results_mock = mocker.patch.object(demisto, "results") with pytest.raises(SystemExit) as pytest_wrapped_e: main() results = results_mock.call_args[0][0] assert results == execute_command_res assert pytest_wrapped_e.type is SystemExit assert pytest_wrapped_e.value.code == 0 def test_MattermostAskUser(mocker): """ Given: - The script args. When: - Running the MattermostAskUser command. Then: - Validating the results after manipulating the data and execute the 'send-notification' command. """ from MattermostAskUser import main mocker.patch.object( demisto, "args", return_value={ "message": "message", "persistent": "persistent", "replyEntriesTag": "replyEntriesTag", "task": "1", "user": {"email"}, "lifetime": "test", }, ) execute_command_add_entitlement_res = [{"Type": EntryType.NOTE, "Contents": "some-guid"}] execute_command_send_notification_res = [ {"Type": EntryType.NOTE, "HumanReadable": "Message sent to Mattermost successfully. \nThread ID is: 1660645689.649679"} ] execute_mock = mocker.patch.object( demisto, "executeCommand", side_effect=[execute_command_add_entitlement_res, execute_command_send_notification_res] ) results_mock = mocker.patch.object(demisto, "results") main() assert execute_mock.call_count == 2 results_mock.assert_called_once() results = results_mock.call_args[0][0] assert results == execute_command_send_notification_res