def test_generate_token_default_iat_lifetime(self): token_gen = joat.TokenGenerator("My Provider") token = token_gen.issue_token(client_id="abc123DEF", user_id="12345", scope=['email', 'profile']) self.assertIsNotNone(token)
def test_generate_token_missing_scope(self): token_gen = joat.TokenGenerator("My Provider") token_gen.client_id = "abc123DEF" with self.assertRaises(TypeError): token = self.token_generator.issue_token(user_id="12345") token_gen.user_id = "12345" with self.assertRaises(TypeError): token = self.token_generator.issue_token()
def test_validate_expired_token(self): lifetime = datetime.timedelta(seconds=1) generator = joat.TokenGenerator("My Provider") generator.client_id = 'abc123DEF' token = generator.issue_token(user_id='12345', scope=['email', 'profile'], lifetime=lifetime) time.sleep(2) self.assertIsNone(joat.parse_token(token))
def test_create_token_generator_after_setting_salter(self): joat.salt_generator = some_salt_generator generator = joat.TokenGenerator("Some Provider")
def test_create_token_generator_without_setting_salter(self): with self.assertRaises(NotImplementedError): generator = joat.TokenGenerator("Some Provider")
def test_generate_token_missing_user(self): token_gen = joat.TokenGenerator("My Provider") with self.assertRaises(TypeError): token = self.token_generator.issue_token(client_id="abc123DEF")
def setUp(self): super(TestTokenGeneration, self).setUp() joat.salt_generator = self.generate_salt self.token_generator = joat.TokenGenerator("My OAuth2 Provider") self.token_generator.client_id = 'abc123DEF'