-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* allows login using username or email address * tests if login with email works * conforming with pep8 standards * testing email * added "username or e-mail" in the login form
- Loading branch information
Showing
4 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
from ramp_database.utils import check_password | ||
|
||
from ramp_database.tools.user import get_user_by_name | ||
from ramp_database.tools.user import get_user_by_name_or_email | ||
|
||
from ramp_frontend import create_app | ||
from ramp_frontend.testing import login_scope | ||
|
@@ -92,7 +93,21 @@ def test_login(client_session): | |
rv = client.post('/login', data=login_info) | ||
assert rv.status_code == 302 | ||
assert rv.location == 'http://localhost/problems' | ||
user = get_user_by_name(session, login_info['user_name']) | ||
user = get_user_by_name_or_email(session, login_info['user_name']) | ||
assert user.is_authenticated | ||
logout(client) | ||
rv = client.post('/login', data=login_info, follow_redirects=True) | ||
assert rv.status_code == 200 | ||
logout(client) | ||
|
||
# POST with a right email as login and password | ||
login_info = {'user_name': 'test_user', 'password': 'test', | ||
'email': '[email protected]'} | ||
rv = client.post('/login', data=login_info) | ||
assert rv.status_code == 302 | ||
assert rv.location == 'http://localhost/problems' | ||
user = get_user_by_name_or_email(session, | ||
login_info['email']) | ||
assert user.is_authenticated | ||
logout(client) | ||
rv = client.post('/login', data=login_info, follow_redirects=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters