示例#1
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                          password='******')
        self.assertIsNone(user)

    def test_unknown_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#2
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')

        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')

        self.assertIsNone(user)

    def test_unkown_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')

        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#3
0
class EmailBackendTest(TestCase):
	def setUp(self):
		UserModel = get_user_model()
		UserModel.objects.create_user(
			username='******',
			email='*****@*****.**',
			password='******')
		self.backend = EmailBackend()

	def test_authenticate_with_email(self):
		user = self.backend.authenticate(
			email='*****@*****.**',
			password='******')
		self.assertIsNotNone(user)

	def test_wrong_password(self):
		user = self.backend.authenticate(
			email='*****@*****.**',
			password='******')
		self.assertIsNone(user)

	def test_unknown_user(self):
		user = self.backend.authenticate(
			email='*****@*****.**',
			password='******')
		self.assertIsNone(user)

	def test_get_user(self):
		self.assertIsNotNone(self.backend.get_user(1))
示例#4
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(
                username='******',
                email   ='*****@*****.**',
                password= '******',)                
        self.backend = EmailBackend()
        
    def test_autenticate_with_email(self):
        user = self.backend.authenticate(
                email   ='*****@*****.**',
                password='******',)        
        self.assertIsNotNone(user)
        
    def test_wrong_password(self):
        user = self.backend.authenticate(
                email   ='*****@*****.**',
                password= '******',)        
        self.assertIsNone(user)
        
    def test_unknown_user(self):
        user = self.backend.authenticate(
                email   ='*****@*****.**',
                password='******',)
        self.assertIsNone(user)
        
    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#5
0
class EmailBackendTest(TestCase):
	def setUp(self):
		UserModel = get_user_model()
		UserModel.objects.create_user(username='******',
			                          email='*****@*****.**',
			                          password='******')
		self.backend = EmailBackend()

	def test_authenticate_with_email(self):
		user = self.backend.authenticate(email='*****@*****.**',
			                             password='******')
		self.assertIsNotNone(user)

	def test_wrong_password(self):
		user = self.backend.authenticate(email='*****@*****.**',
			                             password='******')
		self.assertIsNone(user)

	def test_unknown_user(self):
		user = self.backend.authenticate(email='*****@*****.**',
			                             password='******')
		self.assertIsNone(user)

	def test_get_user(self):
		self.assertIsNotNone(self.backend.get_user(1))
示例#6
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_unknown_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#7
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_unknow_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#8
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******',
        )
        self.backend = EmailBackend()

    def test_autenticate_with_email(self):
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******',
        )
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******',
        )
        self.assertIsNone(user)

    def test_unknown_user(self):
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******',
        )
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#9
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_unknown_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#10
0
class EmailBackendTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
                                      email='*****@*****.**',
                                      password='******')
        self.backend = EmailBackend()
        
    def test_authenticate_with_email(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNotNone(user)
    
    def test_wrong_password(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)
    
    def test_unknown_user(self):
        user = self.backend.authenticate(email='*****@*****.**',
                                         password='******')
        self.assertIsNone(user)
        
    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#11
0
class EmailBackendTest(TestCase):
    """
    Test class.
    """
    def setUp(self):
        """
        Test initialization.
        """
        UserModel = get_user_model()
        UserModel.objects.create_user(
            username='******',
            email='*****@*****.**',
            password='******'
        )
        self.backend = EmailBackend()

    def test_authenticate_with_email(self):
        """
        Backend should be able to handle email as user id.
        """
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******'
        )
        self.assertIsNotNone(user)

    def test_wrong_password(self):
        """
        Backend should not authenticate user with bad password.
        """
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******'
        )
        self.assertIsNone(user)

    def test_unknown_user(self):
        """
        Backend should not authenticate unknown user.
        """
        user = self.backend.authenticate(
            email='*****@*****.**',
            password='******'
        )
        self.assertIsNone(user)

    def test_get_user(self):
        """
        Backend should have 'get_user' method.
        """
        self.assertIsNotNone(self.backend.get_user(1))
示例#12
0
class MultipleEmailsTest(TestCase):
    def setUp(self):
        UserModel = get_user_model()
        UserModel.objects.create_user(username='******',
            email='*****@*****.**', password='******')
        UserModel.objects.create_user(username='******',
            email='*****@*****.**', password='******')
        self.backend = EmailBackend()

    def test_multiple_emails(self):
        user = self.backend.authenticate(email='*****@*****.**',
            password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        self.assertIsNotNone(self.backend.get_user(1))
示例#13
0
 def test_get_user(self):
     backend = EmailBackend()
     self.assertIsNotNone(backend.get_user(1))