mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Format all the things (#991)
* Format Javascript and CSS files with `prettier`: `prettier --write 'CTFd/themes/**/*'` * Format Python with `black`: `black CTFd` & `black tests` * Travis now uses xenial instead of trusty.
This commit is contained in:
@@ -11,7 +11,7 @@ from tests.helpers import (
|
||||
gen_team,
|
||||
gen_solve,
|
||||
gen_fail,
|
||||
gen_tracking
|
||||
gen_tracking,
|
||||
)
|
||||
import random
|
||||
|
||||
@@ -19,11 +19,11 @@ import random
|
||||
def test_reset():
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
base_user = 'user'
|
||||
base_user = "user"
|
||||
|
||||
for x in range(10):
|
||||
chal = gen_challenge(app.db, name='chal_name{}'.format(x))
|
||||
gen_flag(app.db, challenge_id=chal.id, content='flag')
|
||||
chal = gen_challenge(app.db, name="chal_name{}".format(x))
|
||||
gen_flag(app.db, challenge_id=chal.id, content="flag")
|
||||
|
||||
for x in range(10):
|
||||
user = base_user + str(x)
|
||||
@@ -41,10 +41,8 @@ def test_reset():
|
||||
client = login_as_user(app, name="admin", password="password")
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {
|
||||
"nonce": sess.get('nonce')
|
||||
}
|
||||
client.post('/admin/reset', data=data)
|
||||
data = {"nonce": sess.get("nonce")}
|
||||
client.post("/admin/reset", data=data)
|
||||
|
||||
assert Users.query.count() == 0
|
||||
assert Challenges.query.count() == 10
|
||||
@@ -57,18 +55,20 @@ def test_reset():
|
||||
def test_reset_team_mode():
|
||||
app = create_ctfd(user_mode="teams")
|
||||
with app.app_context():
|
||||
base_user = 'user'
|
||||
base_team = 'team'
|
||||
base_user = "user"
|
||||
base_team = "team"
|
||||
|
||||
for x in range(10):
|
||||
chal = gen_challenge(app.db, name='chal_name{}'.format(x))
|
||||
gen_flag(app.db, challenge_id=chal.id, content='flag')
|
||||
chal = gen_challenge(app.db, name="chal_name{}".format(x))
|
||||
gen_flag(app.db, challenge_id=chal.id, content="flag")
|
||||
|
||||
for x in range(10):
|
||||
user = base_user + str(x)
|
||||
user_email = user + "@ctfd.io"
|
||||
user_obj = gen_user(app.db, name=user, email=user_email)
|
||||
team_obj = gen_team(app.db, name=base_team + str(x), email=base_team + str(x) + '@ctfd.io')
|
||||
team_obj = gen_team(
|
||||
app.db, name=base_team + str(x), email=base_team + str(x) + "@ctfd.io"
|
||||
)
|
||||
team_obj.members.append(user_obj)
|
||||
team_obj.captain_id = user_obj.id
|
||||
app.db.session.commit()
|
||||
@@ -78,17 +78,17 @@ def test_reset_team_mode():
|
||||
gen_tracking(app.db, user_id=user_obj.id)
|
||||
|
||||
assert Teams.query.count() == 10
|
||||
assert Users.query.count() == 51 # 10 random users, 40 users (10 teams * 4), 1 admin user
|
||||
assert (
|
||||
Users.query.count() == 51
|
||||
) # 10 random users, 40 users (10 teams * 4), 1 admin user
|
||||
assert Challenges.query.count() == 10
|
||||
|
||||
register_user(app)
|
||||
client = login_as_user(app, name="admin", password="password")
|
||||
|
||||
with client.session_transaction() as sess:
|
||||
data = {
|
||||
"nonce": sess.get('nonce')
|
||||
}
|
||||
client.post('/admin/reset', data=data)
|
||||
data = {"nonce": sess.get("nonce")}
|
||||
client.post("/admin/reset", data=data)
|
||||
|
||||
assert Teams.query.count() == 0
|
||||
assert Users.query.count() == 0
|
||||
|
||||
Reference in New Issue
Block a user