diff --git a/request_token/models.py b/request_token/models.py index fc7789b..82a5cfe 100644 --- a/request_token/models.py +++ b/request_token/models.py @@ -231,7 +231,7 @@ def validate_max_uses(self): Raises MaxUseError if invalid. """ - if self.used_to_date >= self.max_uses: + if self.max_uses and self.used_to_date >= self.max_uses: raise MaxUseError( 'RequestToken [%s] has exceeded max uses' % self.id ) diff --git a/request_token/tests/test_models.py b/request_token/tests/test_models.py index fa7811d..f93377e 100644 --- a/request_token/tests/test_models.py +++ b/request_token/tests/test_models.py @@ -226,6 +226,12 @@ def test_validate_max_uses(self): token.used_to_date = token.max_uses self.assertRaises(MaxUseError, token.validate_max_uses) + def test_validate_max_uses_disabled(self): + token = RequestToken(max_uses=0, used_to_date=0) + token.validate_max_uses() + token.used_to_date = 1 + token.validate_max_uses() + def test__auth_is_anonymous(self): factory = RequestFactory() middleware = SessionMiddleware()