Skip to content

Commit

Permalink
Merge pull request #204 from msmagnanijr/AAP-23958
Browse files Browse the repository at this point in the history
[AAP-23958] -  Investigate errors in unit tests in eda collection
  • Loading branch information
msmagnanijr authored May 14, 2024
2 parents 7d84d9c + 2db5d74 commit 895cdbb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion extensions/eda/plugins/event_source/alertmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Arguments:
---------
host: The webserver hostname to listen to. Set to 0.0.0.0 to listen on all
interfaces. Defaults to 127.0.0.1
interfaces. Defaults to localhost
port: The TCP port to listen to. Defaults to 5000
data_alerts_path: The json path to find alert data. Default to "alerts"
Use empty string "" to treat the whole payload data as
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/event_source_webhook/test_webhook_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_webhook_source_sanity(subprocess_teardown, port: int):
json.dumps({"shutdown": ""}).encode("ascii"),
]

url = f"http://127.0.0.1:{port}/webhook"
url = f"http://localhost:{port}/webhook"

env = os.environ.copy()
env["WH_PORT"] = str(port)
Expand All @@ -66,7 +66,7 @@ def test_webhook_source_sanity(subprocess_teardown, port: int):
stdout, _unused_stderr = proc.communicate()

assert "Rule fired successfully" in stdout.decode()
assert f"'Host': '127.0.0.1:{port}'" in stdout.decode()
assert f"'Host': 'localhost:{port}'" in stdout.decode()
assert proc.returncode == 0


Expand Down Expand Up @@ -105,7 +105,7 @@ def test_webhook_source_hmac_sanity(subprocess_teardown):
]

port = 5000
url = f"http://127.0.0.1:{port}/webhook"
url = f"http://localhost:{port}/webhook"

env = os.environ.copy()
env["WH_PORT"] = str(port)
Expand All @@ -132,7 +132,7 @@ def test_webhook_source_hmac_sanity(subprocess_teardown):
stdout, _unused_stderr = proc.communicate()

assert "Rule fired successfully" in stdout.decode()
assert f"'Host': '127.0.0.1:{port}'" in stdout.decode()
assert f"'Host': 'localhost:{port}'" in stdout.decode()
assert proc.returncode == 0


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/event_source/test_alertmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def cancel_code(server_task):
async def test_cancel():
queue = asyncio.Queue()

args = {"host": "127.0.0.1", "port": 8001}
args = {"host": "localhost", "port": 8001}
plugin_task = asyncio.create_task(start_server(queue, args))
cancel_task = asyncio.create_task(cancel_code(plugin_task))

Expand All @@ -41,7 +41,7 @@ async def test_cancel():
async def test_post_endpoint_with_default():
queue = asyncio.Queue()

args = {"host": "127.0.0.1", "port": 8002}
args = {"host": "localhost", "port": 8002}
plugin_task = asyncio.create_task(start_server(queue, args))

task_info = {
Expand Down Expand Up @@ -86,7 +86,7 @@ async def test_post_endpoint_with_options():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8003,
"data_alerts_path": "",
"data_host_path": "node",
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/event_source/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def cancel_code(server_task):
async def test_cancel():
queue = asyncio.Queue()

args = {"host": "127.0.0.1", "port": 8000, "token": "secret"}
args = {"host": "localhost", "port": 8000, "token": "secret"}
plugin_task = asyncio.create_task(start_server(queue, args))
cancel_task = asyncio.create_task(cancel_code(plugin_task))

Expand All @@ -64,7 +64,7 @@ async def test_cancel():
async def test_post_endpoint():
queue = asyncio.Queue()

args = {"host": "127.0.0.1", "port": 8000, "token": "secret"}
args = {"host": "localhost", "port": 8000, "token": "secret"}
plugin_task = asyncio.create_task(start_server(queue, args))

task_info = {
Expand All @@ -86,7 +86,7 @@ async def test_post_endpoint():
@pytest.mark.asyncio
async def test_post_unsupported_body():
queue = asyncio.Queue()
args = {"host": "127.0.0.1", "port": 8000}
args = {"host": "localhost", "port": 8000}

async def do_request():
async with aiohttp.ClientSession() as session:
Expand All @@ -105,7 +105,7 @@ async def test_post_hmac_hex_endpoint():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -138,7 +138,7 @@ async def test_post_hmac_hex_wo_digest_prefix_endpoint():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -171,7 +171,7 @@ async def test_post_hmac_hex_endpoint_invalid_signature():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -201,7 +201,7 @@ async def test_post_hmac_hex_endpoint_missing_signature():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -231,7 +231,7 @@ async def test_post_hmac_base64_endpoint():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -264,7 +264,7 @@ async def test_post_hmac_base64_endpoint_invalid_signature():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"hmac_secret": "secret",
"hmac_algo": "sha256",
Expand Down Expand Up @@ -294,7 +294,7 @@ async def test_post_token_and_hmac_hex_endpoint():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"token": "secret",
"hmac_secret": "secret",
Expand Down Expand Up @@ -326,7 +326,7 @@ async def test_post_token_and_hmac_hex_endpoint_invalid_signature():
queue = asyncio.Queue()

args = args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"token": "secret",
"hmac_secret": "secret",
Expand Down Expand Up @@ -356,7 +356,7 @@ async def test_post_token_and_hmac_hex_endpoint_invalid_token():
queue = asyncio.Queue()

args = {
"host": "127.0.0.1",
"host": "localhost",
"port": 8000,
"token": "secret",
"hmac_secret": "secret",
Expand Down

0 comments on commit 895cdbb

Please sign in to comment.