[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 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")
|
||||
original_config = load_config(str(config_file))
|
||||
out = StringIO()
|
||||
stream = FlagDetectorStream(out, r"flag\{[a-z_]+\}")
|
||||
stream.write("found flag{persisted_flag} in stdout")
|
||||
|
||||
try:
|
||||
out = StringIO()
|
||||
stream = FlagDetectorStream(out, r"flag\{[a-z_]+\}")
|
||||
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))
|
||||
# Reload config and check last_flag
|
||||
cfg = Config()
|
||||
assert cfg.data.get("Competition", {}).get("last_flag") == "flag{persisted_flag}"
|
||||
# }}}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user