Beispiel #1
0
    def test_timeout(self):
        user1 = User.objects.create_user(username='******', password='******')
        token1 = token_generator.make(user1)

        self.assertTrue(token_generator.check(user1, token1))
        time.sleep(3)
        self.assertFalse(token_generator.check(user1, token1))
Beispiel #2
0
    def test_password_change(self):
        user1 = User.objects.create_user(username='******', password='******')
        token1 = token_generator.make(user1)

        self.assertTrue(token_generator.check(user1, token1))
        user1.set_password('new')
        self.assertFalse(token_generator.check(user1, token1))
Beispiel #3
0
    def test(self):
        user1 = User.objects.create_user(username='******', password='******')
        user2 = User.objects.create_user(username='******', password='******')

        token1 = token_generator.make(user1)
        token2 = token_generator.make(user2)

        self.assertTrue(token_generator.check(user1, token1))
        self.assertTrue(token_generator.check(user2, token2))

        self.assertFalse(token_generator.check(user1, token2))
        self.assertFalse(token_generator.check(user2, token1))
Beispiel #4
0
    def test_long_base_36_check(self):
        user1 = User.objects.create_user(username='******', password='******')
        token1 = token_generator.make(user1)
        pk, ts_b36, hash = token1.split('-')
        token1 = "{0}-{1}{2}{3}-{4}".format(pk, ts_b36, ts_b36, ts_b36, hash)

        self.assertFalse(token_generator.check(user1, token1))
Beispiel #5
0
    def test_unsplitable_token_check(self):
        user1 = User.objects.create_user(username='******', password='******')
        token1 = token_generator.make(user1)
        token1 = token1.replace('-', '')

        self.assertFalse(token_generator.check(user1, token1))