Show length error when Configs provided are too long (#1920)

* Show an error when a config is too long
This commit is contained in:
Ife Lawal
2021-06-26 00:04:36 -04:00
committed by GitHub
parent dd05f57b6a
commit 08ff0f2ed6
6 changed files with 52 additions and 4 deletions

View File

@@ -103,3 +103,23 @@ def test_api_config_delete_admin():
assert r.status_code == 200
assert get_config("ctf_name") is None
destroy_ctfd(app)
def test_long_values():
"""Can a config value that is bigger than 64,000 be accepted"""
app = create_ctfd()
with app.app_context():
with login_as_user(app, "admin") as admin:
long_text = "a" * 65000
r = admin.post(
"/api/v1/configs", json={"key": "ctf_footer", "value": long_text}
)
data = r.get_json()
assert data["errors"]["value"][0] == "ctf_footer config is too long"
r = admin.patch("/api/v1/configs", json={"ctf_theme": long_text})
data = r.get_json()
assert data["errors"]["value"][0] == "ctf_theme config is too long"
assert r.status_code == 400
destroy_ctfd(app)