[GEMINI] Add unit tests for is_valid_flag helper

This commit is contained in:
venus
2026-07-19 01:02:33 -05:00
parent 4bddd4a49b
commit b03df0af6f

View File

@@ -12,3 +12,20 @@ def test_check_for_flag():
assert set(res_custom) == {"custom{first}", "custom{second}"} assert set(res_custom) == {"custom{first}", "custom{second}"}
assert check_for_flag("no flag matches here") == [] assert check_for_flag("no flag matches here") == []
# }}} # }}}
# {{{ test_is_valid_flag
def test_is_valid_flag():
"""
Verifies that is_valid_flag validates flags and supports uniqueness checks.
"""
from ctf.helpers import is_valid_flag
# Valid flag
assert is_valid_flag("flag{test}")
# Invalid flag
assert not is_valid_flag("no flag here")
# Uniqueness check (success)
assert is_valid_flag("flag{new}", original="flag{old}")
# Uniqueness check (failure)
assert not is_valid_flag("flag{same}", original="flag{same}")
# }}}