mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
@@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from CTFd.models import Users
|
||||
from CTFd.admin import admin
|
||||
from CTFd.utils import set_config, get_config
|
||||
from freezegun import freeze_time
|
||||
from tests.helpers import *
|
||||
from mock import patch
|
||||
from tests.helpers import (
|
||||
create_ctfd,
|
||||
destroy_ctfd,
|
||||
register_user,
|
||||
login_as_user,
|
||||
gen_page,
|
||||
gen_challenge,
|
||||
gen_team,
|
||||
)
|
||||
from flask import Flask
|
||||
|
||||
|
||||
@@ -20,6 +23,9 @@ def test_admin_access():
|
||||
"""Can a user access admin pages?"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
gen_page(app.db, title="title", route="/route", content="content")
|
||||
gen_challenge(app.db)
|
||||
gen_team(app.db)
|
||||
routes = [
|
||||
'/admin/challenges/new',
|
||||
'/admin/export/csv',
|
||||
@@ -42,7 +48,7 @@ def test_admin_access():
|
||||
'/admin/submissions',
|
||||
'/admin/challenges/1',
|
||||
# '/admin/plugins/<plugin>',
|
||||
# '/admin/pages/<int:page_id>',
|
||||
'/admin/pages/1',
|
||||
'/admin/teams/1',
|
||||
'/admin/users/1',
|
||||
]
|
||||
@@ -54,6 +60,13 @@ def test_admin_access():
|
||||
assert r.status_code == 302
|
||||
assert r.location.startswith('http://localhost/login')
|
||||
|
||||
admin = login_as_user(app, name="admin")
|
||||
routes.remove('/admin')
|
||||
routes.remove('/admin/export/csv')
|
||||
routes.remove('/admin/export')
|
||||
for route in routes:
|
||||
r = admin.get(route)
|
||||
assert r.status_code == 200
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user