Esempio n. 1
0
 def test_access_token_get_expire_delta_value(self):
     user = self.get_user()
     client = self.get_client()
     token = AccessToken.objects.create(user=user, client=client)
     now = date_now()
     default_expiration_timedelta = constants.EXPIRE_DELTA
     current_expiration_timedelta = datetime.timedelta(
         seconds=token.get_expire_delta(reference=now))
     self.assertLessEqual(
         abs(current_expiration_timedelta - default_expiration_timedelta),
         datetime.timedelta(seconds=1))
Esempio n. 2
0
    def test_token_ignores_expired_tokens(self):
        AccessToken.objects.create(
            user=self.get_user(),
            client=self.get_client(),
            expires=date_now() - datetime.timedelta(days=1),
        )

        self.login()
        self.client.get(self.auth_url(),
                        data=self.get_auth_params(response_type="token"))
        self.client.post(self.auth_url2(), data={'authorize': 'Authorize'})

        self.assertEqual(AccessToken.objects.count(), 2)