mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Show length error when Configs provided are too long (#1920)
* Show an error when a config is too long
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user