mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-02-08 15:54:21 +01:00
Adding test_user_login
This commit is contained in:
@@ -3,6 +3,7 @@ from CTFd.models import Teams
|
||||
|
||||
|
||||
def test_index():
|
||||
"""Does the index page return a 200 by default"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
with app.test_client() as client:
|
||||
@@ -11,6 +12,7 @@ def test_index():
|
||||
|
||||
|
||||
def test_register_user():
|
||||
"""Tests whether a user can be registered"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_user(app)
|
||||
@@ -18,7 +20,19 @@ def test_register_user():
|
||||
assert team_count == 2 # There's the admin user and the created user
|
||||
|
||||
|
||||
def test_user_login():
|
||||
"""Tests to see if a registered user can login"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_user(app)
|
||||
client = login_as_user(app)
|
||||
r = client.get('/profile')
|
||||
assert r.location != "http://localhost/login" # We didn't get redirected to login
|
||||
assert r.status_code == 200
|
||||
|
||||
|
||||
def test_user_isnt_admin():
|
||||
"""Tests to see if a registered user cannot access admin pages"""
|
||||
app = create_ctfd()
|
||||
with app.app_context():
|
||||
register_user(app)
|
||||
|
||||
Reference in New Issue
Block a user