Skip to content

Commit

Permalink
Bug fix/xsup 42076/bmc helix itsm fix query (demisto#36583)
Browse files Browse the repository at this point in the history
* BMC Helix ITSM added brackets to the query

* RN

* Fix ut
  • Loading branch information
MosheEichler authored Oct 7, 2024
1 parent 976d434 commit 97b1e45
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Packs/BmcITSM/Integrations/BmcITSM/BmcITSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3476,7 +3476,7 @@ def gen_single_filters_statement(filter_key: str, values: list, oper_in_filter:

stmt = oper_between_filters.join(f"'{filter_key}' {oper_in_filter} \"{resource_id}\""
for resource_id in (values))
return stmt
return f'({stmt})' if stmt else ''


def wrap_filter_value(filter_value: str, operation: str) -> str:
Expand Down Expand Up @@ -3530,7 +3530,7 @@ def gen_fetch_incidents_query(
str: query to fetch a certain ticket type.
"""
create_time_prop = "Create Date" if ticket_type == "task" else "Submit Date"
time_filter = f"'{create_time_prop}' <= \"{t_epoch_to}\" AND '{create_time_prop}' >\"{t_epoch_from}\""
time_filter = f"('{create_time_prop}' <= \"{t_epoch_to}\" AND '{create_time_prop}' >\"{t_epoch_from}\")"

status_statement = gen_single_filters_statement(TICKET_TYPE_TO_STATUS_KEY[ticket_type],
status_filter, "=", " OR ")
Expand Down
8 changes: 4 additions & 4 deletions Packs/BmcITSM/Integrations/BmcITSM/BmcITSM_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def test_task_create_command(
mock_response = load_mock_response(response_file_name)
url = f"{BASE_URL}/api/arsys/v1/entry/TMS:Task?fields=values(Task ID,Create Date)"
requests_mock.post(url=url, json=mock_response)
query = "'Request ID' = \"PKE000000000227\""
query = "('Request ID' = \"PKE000000000227\")"
url = f"{BASE_URL}/api/arsys/v1/entry/PBM:KnownErrorInterface?q={query}"
requests_mock.get(url=url, json=load_mock_response("get_known_error.json"))

Expand Down Expand Up @@ -1182,7 +1182,7 @@ def test_gen_fetch_incidents_query():
urgency_filter,
custom_query,
)
assert query == "'Submit Date' <= \"1657032797\" AND 'Submit Date' >\"1657032797\" AND 'Urgency' = \"4-Low\""
assert query == "('Submit Date' <= \"1657032797\" AND 'Submit Date' >\"1657032797\") AND ('Urgency' = \"4-Low\")"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -1509,8 +1509,8 @@ def test_fetch_command(
status_filter=[],
impact_filter=[],
urgency_filter=[],
custom_query=("'Submit Date' <= \"1657032797\" AND 'Submit Date'"
">\"1657032797\" AND 'Urgency' = \"4-Low\""),
custom_query=("('Submit Date' <= \"1657032797\" AND 'Submit Date'"
">\"1657032797\") AND ('Urgency' = \"4-Low\")"),
mirror_direction="both",
)
assert last_run_result["SRM:Request"]["last_create_time"] == expected_result
6 changes: 6 additions & 0 deletions Packs/BmcITSM/ReleaseNotes/1_0_27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### BMC Helix ITSM

Fixed an issue were the ***fetch-incidents*** command returned unrelated incidents due to an incorrect query.
2 changes: 1 addition & 1 deletion Packs/BmcITSM/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "BMC Helix ITSM",
"description": "BMC Helix ITSM allows customers to manage service request, incident, change request, task, problem investigation, known error and work order tickets.",
"support": "xsoar",
"currentVersion": "1.0.26",
"currentVersion": "1.0.27",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 97b1e45

Please sign in to comment.