VectraRUXSyncEntityAssignment
Sync Entity Assignment details from the Vectra platform.
python · Vectra RUX
Details
| ID | VectraRUXSyncEntityAssignment |
|---|---|
| Language | python |
| From Version | 6.10.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Tags | incident-action-button |
README
Sync Entity Assignment details from the Vectra platform.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | incident-action-button |
| Cortex XSOAR Version | 6.10.0 |
Inputs
There are no inputs for this script.
Outputs
There are no outputs for this script.
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 from VectraRUXSyncEntityAssignment import main # Import the main function from the script file from VectraRUXSyncEntityAssignment import handle_error, map_and_update_entity_assignments def test_handle_error_no_error(): """ Given: - Command results containing no errors. When: - Calling the 'handle_error' function with the provided command results. Then: - Assert that the function returns None, indicating no error. """ # Test when no error in the command results command_results = [{"Type": 1, "Contents": "Success"}] handle_error(command_results) def test_map_and_update_entity_assignments(): """ Given: - Test data containing various fields, including 'Vectra RUX Entity Assignment Details'. - A mapper and a mapper type. When: - Calling the 'map_and_update_entity_assignments' function with the provided data, mapper, and mapper type. Then: - Assert that the function returns a CommandResults object. - Assert that the readable output of the CommandResults indicates successful synchronization of assignments. """ # Define your test data data = {"field1": "value1", "field2": "value2", "Assignment Details": "assignment_data"} mapper = "your_mapper" mapper_type = "incident_type" # Mock demisto.mapObject def mock_map_object(data, mapper, mapper_type): return data # Mock demisto.executeCommand def mock_execute_command(command, data): assert command == "setIncident" assert data == data # Replace the actual functions with the mock functions original_map_object = demisto.mapObject demisto.mapObject = mock_map_object original_execute_command = demisto.executeCommand demisto.executeCommand = mock_execute_command # Test the map_and_update_entity_assignments function result = map_and_update_entity_assignments(data, mapper, mapper_type) # Restore the original functions demisto.mapObject = original_map_object demisto.executeCommand = original_execute_command # Check if the result is a CommandResults object with the correct readable_output assert isinstance(result, CommandResults) assert result.readable_output == "Assignments have been synchronized successfully." def test_main(mocker): """ Given: - A mocked incident object. When: - Calling the 'main' function of the VectraRUXSyncEntityAssignment script. """ mocker.patch.object( demisto, "incident", return_value={"CustomFields": {"vectraruxentityid": "1", "vectraruxentitytype": "host"}} ) # Mock the demisto.executeCommand() function to return the command result. mocker.patch.object( demisto, "executeCommand", return_value=[ { "Type": "command", "Contents": [ { "id": 212, "assigned_by": {"id": 65, "username": "test.user4@example.com"}, "date_assigned": "2023-08-18T06:29:56Z", "events": [], "account_id": 108, "assigned_to": {"id": 60, "username": "test.user1@example.com"}, "assignment_id": 212, } ], "HumanReadable": "", } ], ) # Call the main function main()