mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
# 3.1.0 / 2020-09-08 **General** - Loosen team password confirmation in team settings to also accept the team captain's password to make it easier to change the team password - Adds the ability to add custom user and team fields for registration/profile settings. - Improve Notifications pubsub events system to use a subscriber per server instead of a subscriber per browser. This should improve the reliability of CTFd at higher load and make it easier to deploy the Notifications system **Admin Panel** - Add a comments functionality for admins to discuss challenges, users, teams, pages - Adds a legal section in Configs where users can add a terms of service and privacy policy - Add a Custom Fields section in Configs where admins can add/edit custom user/team fields - Move user graphs into a modal for Admin Panel **API** - Add `/api/v1/comments` to manipulate and create comments **Themes** - Make scoreboard caching only cache the score table instead of the entire page. This is done by caching the specific template section. Refer to #1586, specifically the changes in `scoreboard.html`. - Add rel=noopener to external links to prevent tab napping attacks - Change the registration page to reference links to Terms of Service and Privacy Policy if specified in configuration **Miscellaneous** - Make team settings modal larger in the core theme - Update tests in Github Actions to properly test under MySQL and Postgres - Make gevent default in serve.py and add a `--disable-gevent` switch in serve.py - Add `tenacity` library for retrying logic - Add `pytest-sugar` for slightly prettier pytest output - Add a `listen()` method to `CTFd.utils.events.EventManager` and `CTFd.utils.events.RedisEventManager`. - This method should implement subscription for a CTFd worker to whatever underlying notification system there is. This should be implemented with gevent or a background thread. - The `subscribe()` method (which used to implement the functionality of the new `listen()` function) now only handles passing notifications from CTFd to the browser. This should also be implemented with gevent or a background thread.
95 lines
2.6 KiB
Python
95 lines
2.6 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from CTFd.models import Users
|
|
from tests.helpers import (
|
|
create_ctfd,
|
|
destroy_ctfd,
|
|
gen_field,
|
|
gen_team,
|
|
login_as_user,
|
|
register_user,
|
|
)
|
|
|
|
|
|
def test_admin_view_fields():
|
|
app = create_ctfd()
|
|
with app.app_context():
|
|
register_user(app)
|
|
|
|
gen_field(
|
|
app.db, name="CustomField1", required=True, public=True, editable=True
|
|
)
|
|
gen_field(
|
|
app.db, name="CustomField2", required=False, public=True, editable=True
|
|
)
|
|
gen_field(
|
|
app.db, name="CustomField3", required=False, public=False, editable=True
|
|
)
|
|
gen_field(
|
|
app.db, name="CustomField4", required=False, public=False, editable=False
|
|
)
|
|
|
|
with login_as_user(app, name="admin") as admin:
|
|
# Admins should see all user fields regardless of public or editable
|
|
r = admin.get("/admin/users/2")
|
|
resp = r.get_data(as_text=True)
|
|
assert "CustomField1" in resp
|
|
assert "CustomField2" in resp
|
|
assert "CustomField3" in resp
|
|
assert "CustomField4" in resp
|
|
destroy_ctfd(app)
|
|
|
|
|
|
def test_admin_view_team_fields():
|
|
app = create_ctfd(user_mode="teams")
|
|
with app.app_context():
|
|
register_user(app)
|
|
team = gen_team(app.db)
|
|
user = Users.query.filter_by(id=2).first()
|
|
user.team_id = team.id
|
|
app.db.session.commit()
|
|
|
|
gen_field(
|
|
app.db,
|
|
name="CustomField1",
|
|
type="team",
|
|
required=True,
|
|
public=True,
|
|
editable=True,
|
|
)
|
|
gen_field(
|
|
app.db,
|
|
name="CustomField2",
|
|
type="team",
|
|
required=False,
|
|
public=True,
|
|
editable=True,
|
|
)
|
|
gen_field(
|
|
app.db,
|
|
name="CustomField3",
|
|
type="team",
|
|
required=False,
|
|
public=False,
|
|
editable=True,
|
|
)
|
|
gen_field(
|
|
app.db,
|
|
name="CustomField4",
|
|
type="team",
|
|
required=False,
|
|
public=False,
|
|
editable=False,
|
|
)
|
|
|
|
with login_as_user(app, name="admin") as admin:
|
|
# Admins should see all team fields regardless of public or editable
|
|
r = admin.get("/admin/teams/1")
|
|
resp = r.get_data(as_text=True)
|
|
assert "CustomField1" in resp
|
|
assert "CustomField2" in resp
|
|
assert "CustomField3" in resp
|
|
assert "CustomField4" in resp
|
|
destroy_ctfd(app)
|