diff --git a/CTFd/admin/__init__.py b/CTFd/admin/__init__.py index cdacd97e..5be7241f 100644 --- a/CTFd/admin/__init__.py +++ b/CTFd/admin/__init__.py @@ -24,6 +24,7 @@ from CTFd.models import ( Solves, Submissions, Teams, + Tracking, Unlocks, Users, db, @@ -214,6 +215,7 @@ def reset(): Submissions.query.delete() Awards.query.delete() Unlocks.query.delete() + Tracking.query.delete() if require_setup: set_config("setup", False) diff --git a/CTFd/themes/admin/templates/reset.html b/CTFd/themes/admin/templates/reset.html index 7cdce09b..ccce2f7b 100644 --- a/CTFd/themes/admin/templates/reset.html +++ b/CTFd/themes/admin/templates/reset.html @@ -15,7 +15,12 @@

-
- +
+
+ +
+ + Deletes all user and team accounts and their associated information
+ (Users, Teams, Submissions, Tracking) +
-
- +
+
+ +
+ + Deletes all records that accounts gained points or took an action
+ (Submissions, Awards, Unlocks, Tracking) +
-
- +
+
+ +
+ + Deletes all challenges and associated data
+ (Challenges, Flags, Hints, Tags, Challenge Files) +
-
- +
+
+ +
+ + Deletes all pages and their associated files
+ (Pages, Page Files) +
-
- +
+
+ +
+ + Deletes all notifications
+ (Notifications) +

diff --git a/tests/admin/test_config.py b/tests/admin/test_config.py index bcc90568..498b47c5 100644 --- a/tests/admin/test_config.py +++ b/tests/admin/test_config.py @@ -78,20 +78,6 @@ def test_reset(): client = login_as_user(app, name="admin", password="password") - with client.session_transaction() as sess: - data = {"nonce": sess.get("nonce"), "submissions": "on"} - r = client.post("/admin/reset", data=data) - assert r.location.endswith("/admin/statistics") - assert Submissions.query.count() == 0 - assert Solves.query.count() == 0 - assert Fails.query.count() == 0 - assert Awards.query.count() == 0 - assert Unlocks.query.count() == 0 - assert Users.query.count() == 11 - assert Challenges.query.count() == 10 - assert Flags.query.count() == 10 - assert Tracking.query.count() == 11 - with client.session_transaction() as sess: data = {"nonce": sess.get("nonce"), "pages": "on"} r = client.post("/admin/reset", data=data) @@ -123,6 +109,20 @@ def test_reset(): assert Users.query.count() == 11 assert Tracking.query.count() == 11 + with client.session_transaction() as sess: + data = {"nonce": sess.get("nonce"), "submissions": "on"} + r = client.post("/admin/reset", data=data) + assert r.location.endswith("/admin/statistics") + assert Submissions.query.count() == 0 + assert Solves.query.count() == 0 + assert Fails.query.count() == 0 + assert Awards.query.count() == 0 + assert Unlocks.query.count() == 0 + assert Users.query.count() == 11 + assert Challenges.query.count() == 0 + assert Flags.query.count() == 0 + assert Tracking.query.count() == 0 + with client.session_transaction() as sess: data = {"nonce": sess.get("nonce"), "accounts": "on"} r = client.post("/admin/reset", data=data) @@ -187,21 +187,6 @@ def test_reset_team_mode(): client = login_as_user(app, name="admin", password="password") - with client.session_transaction() as sess: - data = {"nonce": sess.get("nonce"), "submissions": "on"} - r = client.post("/admin/reset", data=data) - assert r.location.endswith("/admin/statistics") - assert Submissions.query.count() == 0 - assert Solves.query.count() == 0 - assert Fails.query.count() == 0 - assert Awards.query.count() == 0 - assert Unlocks.query.count() == 0 - assert Teams.query.count() == 10 - assert Users.query.count() == 51 - assert Challenges.query.count() == 10 - assert Flags.query.count() == 10 - assert Tracking.query.count() == 11 - with client.session_transaction() as sess: data = {"nonce": sess.get("nonce"), "pages": "on"} r = client.post("/admin/reset", data=data) @@ -236,6 +221,21 @@ def test_reset_team_mode(): assert Users.query.count() == 51 assert Tracking.query.count() == 11 + with client.session_transaction() as sess: + data = {"nonce": sess.get("nonce"), "submissions": "on"} + r = client.post("/admin/reset", data=data) + assert r.location.endswith("/admin/statistics") + assert Submissions.query.count() == 0 + assert Solves.query.count() == 0 + assert Fails.query.count() == 0 + assert Awards.query.count() == 0 + assert Unlocks.query.count() == 0 + assert Teams.query.count() == 10 + assert Users.query.count() == 51 + assert Challenges.query.count() == 0 + assert Flags.query.count() == 0 + assert Tracking.query.count() == 0 + with client.session_transaction() as sess: data = {"nonce": sess.get("nonce"), "accounts": "on"} r = client.post("/admin/reset", data=data)