Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix password is not bytes in mysql #55

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nativeauthenticator/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import re
from jupyterhub.orm import Base

from sqlalchemy import Boolean, Column, Integer, String
from sqlalchemy import Boolean, Column, Integer, String, LargeBinary
from sqlalchemy.orm import validates


class UserInfo(Base):
__tablename__ = 'users_info'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String, nullable=False)
password = Column(String, nullable=False)
password = Column(LargeBinary, nullable=False)
is_authorized = Column(Boolean, default=False)
email = Column(String)

Expand Down
12 changes: 10 additions & 2 deletions nativeauthenticator/tests/test_orm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from jupyterhub.tests.mocking import MockHub
from sqlalchemy.exc import StatementError

from ..orm import UserInfo

Expand All @@ -19,10 +20,17 @@ def app():
@pytest.mark.parametrize('email', ['john', 'john@john'])
def test_validate_method_wrong_email(email, tmpdir, app):
with pytest.raises(AssertionError):
UserInfo(username='john', password='pwd', email=email)
UserInfo(username='john', password=b'pwd', email=email)


def test_validate_method_correct_email(tmpdir, app):
user = UserInfo(username='john', password='pwd', email='[email protected]')
user = UserInfo(username='john', password=b'pwd', email='[email protected]')
app.db.add(user)
assert UserInfo.find(app.db, 'john')


def test_wrong_pwd_type(tmpdir, app):
with pytest.raises(StatementError):
user = UserInfo(username='john', password='pwd', email='[email protected]')
app.db.add(user)
UserInfo.find(app.db, 'john')