本文整理汇总了Python中privacyidea.lib.user.User.get_user_identifiers方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_user_identifiers方法的具体用法?Python User.get_user_identifiers怎么用?Python User.get_user_identifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.user.User
的用法示例。
在下文中一共展示了User.get_user_identifiers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_02_get_user_identifiers
# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import get_user_identifiers [as 别名]
def test_02_get_user_identifiers(self):
user = User(login="root",
realm=self.realm1)
(uid, rtype, resolvername) = user.get_user_identifiers()
self.assertTrue(uid == "0", uid)
self.assertTrue(rtype == "passwdresolver", rtype)
self.assertTrue(resolvername == self.resolvername1, resolvername)
示例2: test_03_get_identifiers
# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import get_user_identifiers [as 别名]
def test_03_get_identifiers(self):
# create realm
self._create_realm()
# delete user_cache
r = delete_user_cache()
self.assertTrue(r >= 0)
# The username is not in the cache. It is fetched from the resolver
# At the same time the cache is filled. Implicitly we test the
# _get_resolvers!
user = User(self.username, self.realm1, self.resolvername1)
uids = user.get_user_identifiers()
self.assertEqual(user.login, self.username)
self.assertEqual(user.uid, self.uid)
# Now, the cache should have exactly one entry
entry = UserCache.query.one()
self.assertEqual(entry.user_id, self.uid)
self.assertEqual(entry.username, self.username)
self.assertEqual(entry.resolver, self.resolvername1)
# delete the resolver, which also purges the cache
self._delete_realm()
# manually re-add the entry from above
UserCache(entry.username, entry.resolver, entry.user_id, entry.timestamp).save()
# the username is fetched from the cache
u_name = get_username(self.uid, self.resolvername1)
self.assertEqual(u_name, self.username)
# The `User` class also fetches the UID from the cache
user2 = User(self.username, self.realm1, self.resolvername1)
self.assertEqual(user2.uid, self.uid)
# delete the cache
r = delete_user_cache()
# try to fetch the username. It is not in the cache and the
# resolver does not exist anymore.
u_name = get_username(self.uid, self.resolvername1)
self.assertEqual(u_name, "")
# similar case for the `User` class
# The `User` class also tries to fetch the UID from the cache
with self.assertRaises(UserError):
user3 = User(self.username, self.realm1, self.resolvername1)