Пример #1
0
    def test_two_factor_auth(self, mock_has_two_factor_auth):
        mock_has_two_factor_auth.return_value = True

        s = AuthTokenSerializer(data={
            'username': self.user.username,
            'password': self.user_password,
        }, context={'request': self.fake_request})
        assert s.is_valid() is True
Пример #2
0
    def test_inactive_user(self):
        d = {
            'username': self.inactive_user.username,
            'password': '******',
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        assert s.is_valid() is False
        assert 'User account is disabled.' in s.errors['non_field_errors']
Пример #3
0
 def test_validate(self):
     s = AuthTokenSerializer(data={
         'username': self.user.username,
         'password': self.user_password,
         'platform': 'linux',
         'device_id': '701143c1238e6736b61c20e73de82fc95989c413',
         'device_name': 'test',
     },
                             context={'request': self.fake_request})
     assert s.is_valid() is True
Пример #4
0
    def test_two_factor_auth(self, mock_has_two_factor_auth):
        mock_has_two_factor_auth.return_value = True

        s = AuthTokenSerializer(data={
            'username': self.user.username,
            'password': self.user_password,
            'platform': 'linux',
            'device_id': '701143c1238e6736b61c20e73de82fc95989c413',
            'device_name': 'test',
        },
                                context={'request': self.fake_request})
        assert s.is_valid() is True
Пример #5
0
    def test_primary_id(self):
        d = {
            'username': '******',
            'password': self.user_password,
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertSuccess(s)
Пример #6
0
    def test_contact_email(self):
        d = {
            'username': '******',
            'password': self.user_password,
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertSuccess(s)
Пример #7
0
    def test_login_id(self):
        d = {
            'username': '******',
            'password': self.user_password,
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertSuccess(s)
Пример #8
0
    def test_login_failed(self):
        d = {
            'username': self.user.username,
            'password': '******',
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertFailed(s)
Пример #9
0
    def test_invalid_user(self):
        d = {
            'username': '******',
            'password': '******',
        }

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertFailed(s)
Пример #10
0
    def test_validate(self):
        d = {
            'username': self.user.username,
            'password': self.user_password,
            'platform': 'linux',
            'device_id': '701143c1238e6736b61c20e73de82fc95989c413',
            'device_name': 'test',
        }

        assert AuthTokenSerializer(data=d,
                                   context={
                                       'request': self.fake_request
                                   }).is_valid() is True

        Profile.objects.add_or_update(username=self.user.username,
                                      login_id='aaa')
        d1 = d.copy()
        d1.update({'username': '******'})
        assert AuthTokenSerializer(data=d,
                                   context={
                                       'request': self.fake_request
                                   }).is_valid() is True
        assert AuthTokenSerializer(data=d1,
                                   context={
                                       'request': self.fake_request
                                   }).is_valid() is True

        Profile.objects.add_or_update(username=self.user.username,
                                      contact_email='*****@*****.**')
        d1 = d.copy()
        d1.update({'username': '******'})
        assert AuthTokenSerializer(data=d,
                                   context={
                                       'request': self.fake_request
                                   }).is_valid() is True
        assert AuthTokenSerializer(data=d1,
                                   context={
                                       'request': self.fake_request
                                   }).is_valid() is True
Пример #11
0
    def test_inactive_user_incorrect_password(self):
        """An invalid login doesn't leak the inactive status of a user."""
        d = {'username': self.inactive_user.username, 'password': '******'}

        s = AuthTokenSerializer(data=d, context={'request': self.fake_request})
        self.assertFailed(s)
Пример #12
0
 def test_validate(self):
     s = AuthTokenSerializer(data={
         'username': self.user.username,
         'password': self.user_password,
     }, context={'request': self.fake_request})
     assert s.is_valid() is True