Ejemplo n.º 1
0
 def test_123_token_manager_access_token_get_access_no_user(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.access = True
     m.add(token)
     self.assertRaises(TokenInvalidError, m.getAccessToken, 'token-key')
     self.assertRaises(NotRequestTokenError, m.getRequestToken, 'token-key')
Ejemplo n.º 2
0
 def test_122_token_manager_access_token_get_user_no_access(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.user = '******'
     m.add(token)
     self.assertRaises(NotAccessTokenError, m.getAccessToken, 'token-key')
     self.assertEqual(m.getRequestToken('token-key'), token)
Ejemplo n.º 3
0
 def test_111_token_manager_addget_user(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.user = '******'
     token.access = True
     m.add(token)
     result = m.getTokensForUser('user')
     self.assertEqual(result, [token])
Ejemplo n.º 4
0
 def test_112_token_manager_addget_user(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.user = '******'
     m.add(token)
     result = m.getTokensForUser('user')
     # only access tokens are tracked.
     self.assertEqual(result, [])
Ejemplo n.º 5
0
 def test_101_token_manager_addget(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     m.add(token)
     result = m.get('token-key')
     self.assertEqual(result, token)
     result = m.get(token)
     self.assertEqual(result, token)
Ejemplo n.º 6
0
 def test_125_token_manager_access_token_inconsistent_fail(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.access = True
     m.add(token)
     # this would result in the token not being indexed.
     token.user = '******'
     self.assertRaises(TokenInvalidError, m.getAccessToken, 'token-key')
     self.assertRaises(NotRequestTokenError, m.getRequestToken, 'token-key')
Ejemplo n.º 7
0
 def test_103_token_manager_remove(self):
     m = TokenManager()
     t1 = Token('token-key', 'token-secret')
     t2 = Token('token-key2', 'token-secret')
     m.add(t1)
     m.add(t2)
     m.remove(t1.key)
     m.remove(t2)
     self.assertEqual(len(m._tokens), 1)
Ejemplo n.º 8
0
 def test_113_token_manager_doubleadd_user(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     token.user = '******'
     token.access = True
     m.add(token)
     self.assertRaises(ValueError, m.add, token)
     result = m.getTokensForUser('user')
     # should not result in double entry.
     self.assertEqual(result, [token])
Ejemplo n.º 9
0
 def test_115_token_manager_user_inconsistency(self):
     m = TokenManager()
     t1 = Token('token-key', 'token-secret')
     t1.user = '******'
     t1.access = True
     t2 = Token('token-key2', 'token-secret')
     t2.user = '******'
     t2.access = True
     m.add(t1)
     m.add(t2)
     m._del_user_map(t2)
     # User must know about the token for the getter to work.
     self.assertEqual(m.getTokensForUser('t2user'), [])
Ejemplo n.º 10
0
 def test_114_token_manager_addremove_user(self):
     m = TokenManager()
     t1 = Token('token-key', 'token-secret')
     t1.user = '******'
     t1.access = True
     t2 = Token('token-key2', 'token-secret')
     t2.user = '******'
     t2.access = True
     m.add(t1)
     m.add(t2)
     self.assertEqual(m.getTokensForUser('user'), [])
     self.assertEqual(m.getTokensForUser('t1user'), [t1])
     self.assertEqual(m.getTokensForUser('t2user'), [t2])
     m.remove(t1.key)
     m.remove(t2)
     self.assertEqual(m.getTokensForUser('t1user'), [])
     self.assertEqual(m.getTokensForUser('t2user'), [])
Ejemplo n.º 11
0
 def test_102_token_manager_doubleadd(self):
     m = TokenManager()
     token = Token('token-key', 'token-secret')
     m.add(token)
     self.assertRaises(ValueError, m.add, token)