Skip to content

Commit

Permalink
Sanitizing domain names in regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianBracq committed Sep 5, 2023
1 parent 3a05086 commit 77f278c
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tests/data/drivers/test_cybereason_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def _cr_pre_checks(driver: CybereasonDriver):
@respx.mock
def test_connect(driver):
"""Test connect."""
connect = respx.post(re.compile(r"^https://.*\.cybereason.net/login.html")).respond(
200
)
connect = respx.post(
re.compile(r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/login\.html")
).respond(200)
with custom_mp_config(MP_PATH):
driver.connect()
check.is_true(connect.called)
Expand All @@ -225,11 +225,13 @@ def test_connect(driver):
@respx.mock
def test_query(driver):
"""Test query calling returns data in expected format."""
connect = respx.post(re.compile(r"^https://.*\.cybereason.net/login.html")).respond(
200
)
connect = respx.post(
re.compile(r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/login\.html")
).respond(200)
query = respx.post(
re.compile(r"^https://.*\.cybereason.net/rest/visualsearch/query/simple")
re.compile(
r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/rest/visualsearch/query/simple"
)
).respond(200, json=_CR_RESULT)
with custom_mp_config(MP_PATH):
driver.connect()
Expand All @@ -242,15 +244,19 @@ def test_query(driver):
@respx.mock
def test_paginated_query(driver):
"""Test query calling returns data in expected format."""
connect = respx.post(re.compile(r"^https://.*\.cybereason.net/login.html")).respond(
200
)
connect = respx.post(
re.compile(r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/login.html")
).respond(200)
query1 = respx.post(
re.compile(r"^https://.*\.cybereason.net/rest/visualsearch/query/simple"),
re.compile(
r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/rest/visualsearch/query/simple"
),
params={"page": 0},
).respond(200, json=_CR_PAGINATED_RESULT[0])
query2 = respx.post(
re.compile(r"^https://.*\.cybereason.net/rest/visualsearch/query/simple"),
re.compile(
r"^https://[a-zA-Z0-9\-]+\.cybereason\.net/rest/visualsearch/query/simple"
),
params={"page": 1},
).respond(200, json=_CR_PAGINATED_RESULT[1])
with custom_mp_config(MP_PATH):
Expand Down

0 comments on commit 77f278c

Please sign in to comment.