fixed various typos and variable name changes
This commit is contained in:
+3
-3
@@ -19,7 +19,7 @@ def register():
|
||||
error = None
|
||||
|
||||
if not userid:
|
||||
error = 'Username if required.'
|
||||
error = 'Userid is required.'
|
||||
elif not email:
|
||||
error = 'Email is required.'
|
||||
elif not password:
|
||||
@@ -53,9 +53,9 @@ def login():
|
||||
).fetchone()
|
||||
|
||||
if user is None:
|
||||
error = 'Incorrect username.'
|
||||
error = 'Userid or Password incorrect.'
|
||||
elif not check_password_hash(user['password'], password):
|
||||
error = 'Incorrect password.'
|
||||
error = 'Userid or Password incorrect.'
|
||||
|
||||
if error is None:
|
||||
session.clear()
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
<form method="post">
|
||||
<label for="userid">Userid</label>
|
||||
<input name="userid" id="userid" required>
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email" id="email" required>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password" id="password" required>
|
||||
<input type="submit" value="Login">
|
||||
|
||||
+2
-2
@@ -38,10 +38,10 @@ class AuthActions(object):
|
||||
def __init__(self, client):
|
||||
self._client = client
|
||||
|
||||
def login(self, username='test', password='test'):
|
||||
def login(self, username='test', email='a@.c', password='test'):
|
||||
return self._client.post(
|
||||
'auth/login',
|
||||
data={'username': username, 'password': password}
|
||||
data={'userid': username, 'email': email, 'password': password}
|
||||
)
|
||||
|
||||
def logout(self):
|
||||
|
||||
+10
-10
@@ -7,29 +7,29 @@ def test_register(client, app):
|
||||
response = client.post(
|
||||
'auth/register', data={'userid': 'a', 'email': 'a@b.c', 'password': 'a'}
|
||||
)
|
||||
assert 'http://localhost/auth/login' == response.headers['Location']
|
||||
assert 'http://localhost/auth/login' == response.headers['Path']
|
||||
|
||||
with app.app_context():
|
||||
assert get_db().execute(
|
||||
"SELECT * FROM users WHERE userid = 'a'",
|
||||
).fetchone() is not None
|
||||
|
||||
@pytest.mark.parametrize(('userid', 'password', 'message'), (
|
||||
('', '', b'Userid is required.'),
|
||||
('a', '', b'Password is required.'),
|
||||
('test', 'test', b'already registered'),
|
||||
@pytest.mark.parametrize(('userid', 'email', 'password', 'message'), (
|
||||
('', '', '', b'Userid is required.'),
|
||||
('a', 'a@b.c', '', b'Password is required.'),
|
||||
('test', 'test', 'test', b'already registered'),
|
||||
))
|
||||
def test_register_validate_input(client, userid, password, message):
|
||||
def test_register_validate_input(client, userid, email, password, message):
|
||||
response = client.post(
|
||||
'/auth/register',
|
||||
data={'userid': userid, 'password': password}
|
||||
data={'userid': userid, 'email': email, 'password': password}
|
||||
)
|
||||
assert message in response.data
|
||||
|
||||
def test_login(client, auth):
|
||||
assert client.get('/auth/login').status_code == 200
|
||||
response = auth.login()
|
||||
assert response.headers['Location'] == 'http://localhost/'
|
||||
assert response.headers['Path'] == 'http://localhost/'
|
||||
|
||||
with client:
|
||||
client.get('/')
|
||||
@@ -37,8 +37,8 @@ def test_login(client, auth):
|
||||
assert g.user['userid'] == 'test'
|
||||
|
||||
@pytest.mark.parametrize(('userid', 'password', 'message'), (
|
||||
('a', 'test', b'Incorrect userid'),
|
||||
('test', 'a', b'Incorrect password.'),
|
||||
('a', 'test', b'Userid or Password incorrect.'),
|
||||
('test', 'a', b'Userid or Password incorrect.'),
|
||||
))
|
||||
def test_login_validate_input(auth, userid, password, message):
|
||||
response = auth.login(userid, password)
|
||||
|
||||
@@ -6,4 +6,4 @@ def test_config():
|
||||
|
||||
def test_hello(client):
|
||||
response = client.get('/hello')
|
||||
assert response.data == b'Hello World!'
|
||||
assert response.data == b'Hello, World!'
|
||||
|
||||
Reference in New Issue
Block a user