From 14a494df4f4e5557d7587fa87a08edce64f6f702 Mon Sep 17 00:00:00 2001 From: ldruschk <14059613+ldruschk@users.noreply.github.com> Date: Mon, 31 May 2021 12:41:55 +0200 Subject: [PATCH] add more tests, randomize taskChainId (#17) --- enochecker_test/tests.py | 41 +++++++++++++++++++++++++++++++++++++++- setup.py | 2 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/enochecker_test/tests.py b/enochecker_test/tests.py index e326761..49f1eba 100644 --- a/enochecker_test/tests.py +++ b/enochecker_test/tests.py @@ -16,6 +16,7 @@ global_round_id = 0 FLAG_REGEX = r"ENO[A-Za-z0-9+\/=]{48}" REQUEST_TIMEOUT = 10 +CHAIN_ID_PREFIX = secrets.token_hex(20) @pytest.fixture @@ -111,7 +112,9 @@ def _create_request_message( prefix = "noise" elif method == "exploit": prefix = "exploit" - task_chain_id = f"{prefix}_s0_r{round_id}_t0_i{unique_variant_index}" + task_chain_id = ( + f"{CHAIN_ID_PREFIX}_{prefix}_s0_r{round_id}_t0_i{unique_variant_index}" + ) return CheckerTaskMessage( task_id=round_id, @@ -375,6 +378,32 @@ def test_getflag(round_id, flag_id, service_address, checker_url): _test_getflag(flag, round_id, flag_id, service_address, checker_url) +def test_getflag_wrong_flag(round_id, flag_id, service_address, checker_url): + flag = generate_dummyflag() + _test_putflag(flag, round_id, flag_id, service_address, checker_url) + wrong_flag = generate_dummyflag() + _test_getflag( + wrong_flag, + round_id, + flag_id, + service_address, + checker_url, + expected_result=CheckerTaskResult.MUMBLE, + ) + + +def test_getflag_without_putflag(round_id, flag_id, service_address, checker_url): + flag = generate_dummyflag() + _test_getflag( + flag, + round_id, + flag_id, + service_address, + checker_url, + expected_result=CheckerTaskResult.MUMBLE, + ) + + def test_getflag_multiplied( round_id, flag_id_multiplied, flag_variants, service_address, checker_url ): @@ -442,6 +471,16 @@ def test_getnoise(round_id, noise_id, service_address, checker_url): _test_getnoise(round_id, noise_id, service_address, checker_url) +def test_getnoise_without_putnoise(round_id, noise_id, service_address, checker_url): + _test_getnoise( + round_id, + noise_id, + service_address, + checker_url, + expected_result=CheckerTaskResult.MUMBLE, + ) + + def test_getnoise_multiplied( round_id, noise_id_multiplied, noise_variants, service_address, checker_url ): diff --git a/setup.py b/setup.py index 733b603..fee3fab 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setuptools.setup( name="enochecker_test", - version="0.5.1", + version="0.6.0", author="ldruschk", author_email="ldruschk@posteo.de", description="Library to help testing checker scripts based on enochecker",