Update challenge plugins and flag plugins to have exception messages (#1491)

* Update challenge plugins and flag plugins to raise and catch exceptions for flag error messages
* Closes #1425
This commit is contained in:
Kevin Chung
2020-06-14 17:01:23 -04:00
committed by GitHub
parent 1143d751c8
commit 94bd8baca1
4 changed files with 45 additions and 8 deletions

View File

@@ -181,6 +181,29 @@ def test_submitting_correct_regex_case_insensitive_flag():
destroy_ctfd(app)
def test_submitting_invalid_regex_flag():
"""Test that invalid regex flags are errored out to the user"""
app = create_ctfd()
with app.app_context():
register_user(app)
client = login_as_user(app)
chal = gen_challenge(app.db)
gen_flag(
app.db,
challenge_id=chal.id,
type="regex",
content="**",
data="case_insensitive",
)
data = {"submission": "FLAG", "challenge_id": chal.id}
r = client.post("/api/v1/challenges/attempt", json=data)
assert r.status_code == 200
resp = r.get_json()["data"]
assert resp.get("status") == "incorrect"
assert resp.get("message") == "Regex parse error occured"
destroy_ctfd(app)
def test_submitting_incorrect_flag():
"""Test that incorrect flags are incorrect"""
app = create_ctfd()