From 397eb95dd74d5c7f119f4ed49199ac057f57a12d Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Sat, 7 Jan 2017 11:48:10 -0500 Subject: [PATCH] Adding test_user_login --- tests/test_ctfd.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_ctfd.py b/tests/test_ctfd.py index bb8f3c27..831fc152 100644 --- a/tests/test_ctfd.py +++ b/tests/test_ctfd.py @@ -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)