You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_auth_backend.py 819B

1234567891011121314151617181920212223
  1. from django.test import TestCase
  2. from oscar.apps.customer.auth_backends import EmailBackend
  3. from oscar.test.factories import UserFactory
  4. class AuthBackendTestCase(TestCase):
  5. def setUp(self):
  6. self.user = UserFactory(email="foo@example.com", is_staff=True)
  7. self.user.set_password("letmein")
  8. self.user.save()
  9. self.backend = EmailBackend()
  10. def test_authentication_method_signature_post_django_1_11(self):
  11. auth_result = self.backend.authenticate(None, "foo@example.com", "letmein")
  12. self.assertEqual(auth_result, self.user)
  13. def test_inactive_users_cannot_authenticate(self):
  14. self.user.is_active = False
  15. self.user.save()
  16. auth_result = self.backend.authenticate(None, "foo@example.com", "letmein")
  17. self.assertIsNone(auth_result)