Files
@ 7777a6f70fd5
Branch filter:
Location: rattail-project/rattail/tests/db/test_auth.py - annotation
7777a6f70fd5
1.3 KiB
text/x-python
Remove deprecated `RattailConfig.getboolean()` method.
All calling code should be refactored, I believe..
All calling code should be refactored, I believe..
57f6ebd8ea4b 57f6ebd8ea4b 92c03f5d8db0 92c03f5d8db0 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b 57f6ebd8ea4b | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .. import DataTestCase
from rattail.db import auth
from rattail.db import model
class TestAuthenticateUser(DataTestCase):
def test_nonexistent_user_returns_none(self):
self.assertTrue(auth.authenticate_user(self.session, u'fred', u'fredpass') is None)
def test_correct_credentials_returns_user(self):
fred = model.User(username=u'fred')
auth.set_user_password(fred, u'fredpass')
self.session.add(fred)
self.session.commit()
user = auth.authenticate_user(self.session, u'fred', u'fredpass')
self.assertTrue(user is fred)
def test_wrong_password_user_returns_none(self):
fred = model.User(username=u'fred', active=False)
auth.set_user_password(fred, u'fredpass')
self.session.add(fred)
self.session.commit()
self.assertTrue(auth.authenticate_user(self.session, u'fred', u'BADPASS') is None)
def test_inactive_user_returns_none(self):
fred = model.User(username=u'fred', active=False)
auth.set_user_password(fred, u'fredpass')
self.session.add(fred)
self.session.commit()
self.assertTrue(auth.authenticate_user(self.session, u'fred', u'fredpass') is None)
|