mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 14:04:20 +01:00
Adds ondelete='CASCADE' to some models. (#979)
* Fixes `populate.py` to assign captains to teams.
* Adds `ondelete='CASCADE'` to most ForeignKeys in models
* Closes #794
* Test reset in team mode to test removing teams with captains
* Test deleting users/teams with awards to test cascading deletion
* `gen_team()` test helper now creates users for the team and assigns the first one as captain
* Added `Challenges.flags` relationship and moved the `Flags.challenge` relationship to a backref on `Challenges`
This commit is contained in:
@@ -5,11 +5,14 @@ from CTFd.models import Users
|
||||
from CTFd.utils import set_config
|
||||
from CTFd.utils.crypto import verify_password
|
||||
from CTFd.schemas.users import UserSchema
|
||||
from tests.helpers import (create_ctfd,
|
||||
destroy_ctfd,
|
||||
register_user,
|
||||
login_as_user,
|
||||
gen_user)
|
||||
from tests.helpers import (
|
||||
create_ctfd,
|
||||
destroy_ctfd,
|
||||
register_user,
|
||||
login_as_user,
|
||||
gen_user,
|
||||
simulate_user_activity
|
||||
)
|
||||
|
||||
|
||||
def test_api_users_get_public():
|
||||
@@ -322,10 +325,13 @@ def test_api_user_delete_admin():
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_user(app)
|
||||
user = Users.query.filter_by(id=2).first()
|
||||
simulate_user_activity(app.db, user=user)
|
||||
with login_as_user(app, 'admin') as client:
|
||||
r = client.delete('/api/v1/users/2', json="")
|
||||
assert r.status_code == 200
|
||||
assert r.get_json().get('data') is None
|
||||
assert Users.query.filter_by(id=2).first() is None
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user