[GEMINI] Fix test_flag_detector_stream_persistence test case
This commit is contained in:
@@ -86,21 +86,15 @@ def test_flag_detector_stream_persistence():
|
|||||||
"""
|
"""
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from ctf.helpers import FlagDetectorStream
|
from ctf.helpers import FlagDetectorStream
|
||||||
from ctf.config import load_config, write_config
|
from ctf.config import Config
|
||||||
|
|
||||||
config_file = Path("/home/venus/code/ctf/config.toml")
|
out = StringIO()
|
||||||
original_config = load_config(str(config_file))
|
stream = FlagDetectorStream(out, r"flag\{[a-z_]+\}")
|
||||||
|
stream.write("found flag{persisted_flag} in stdout")
|
||||||
|
|
||||||
try:
|
# Reload config and check last_flag
|
||||||
out = StringIO()
|
cfg = Config()
|
||||||
stream = FlagDetectorStream(out, r"flag\{[a-z_]+\}")
|
assert cfg.data.get("Competition", {}).get("last_flag") == "flag{persisted_flag}"
|
||||||
stream.write("found flag{persisted_flag} in stdout")
|
|
||||||
|
|
||||||
# Reload config and check last_flag
|
|
||||||
updated_config = load_config(str(config_file))
|
|
||||||
assert updated_config.get("Competition", {}).get("last_flag") == "flag{persisted_flag}"
|
|
||||||
finally:
|
|
||||||
write_config(original_config, str(config_file))
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user