当前位置: 首页>>代码示例>>Python>>正文


Python User.is_empty方法代码示例

本文整理汇总了Python中privacyidea.lib.user.User.is_empty方法的典型用法代码示例。如果您正苦于以下问题:Python User.is_empty方法的具体用法?Python User.is_empty怎么用?Python User.is_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在privacyidea.lib.user.User的用法示例。


在下文中一共展示了User.is_empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp_user_realm2

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import is_empty [as 别名]
    def setUp_user_realm2(self):
        # create user realm
        rid = save_resolver({"resolver": self.resolvername1,
                             "type": "passwdresolver",
                             "fileName": PWFILE})
        self.assertTrue(rid > 0, rid)

        (added, failed) = set_realm(self.realm2,
                                    [self.resolvername1])
        self.assertTrue(len(failed) == 0)
        self.assertTrue(len(added) == 1)

        user = User(login="root",
                    realm=self.realm2,
                    resolver=self.resolvername1)

        user_str = "{0!s}".format(user)
        self.assertTrue(user_str == "<[email protected]>", user_str)

        self.assertFalse(user.is_empty())
        self.assertTrue(User().is_empty())

        user_repr = "{0!r}".format(user)
        expected = "User(login='root', realm='realm2', resolver='resolver1')"
        self.assertTrue(user_repr == expected, user_repr)
开发者ID:salvorapi,项目名称:privacyidea,代码行数:27,代码来源:base.py

示例2: test_00_create_user

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import is_empty [as 别名]
 def test_00_create_user(self):
     rid = save_resolver({"resolver": self.resolvername1,
                          "type": "passwdresolver",
                          "fileName": PWFILE})
     self.assertTrue(rid > 0, rid)
            
     (added, failed) = set_realm(self.realm1,
                                 [self.resolvername1])
     self.assertTrue(len(failed) == 0)
     self.assertTrue(len(added) == 1)
     
     user = User(login="root",
                 realm=self.realm1,
                 resolver=self.resolvername1)
     
     user_str = "{0!s}".format(user)
     self.assertTrue(user_str == "<[email protected]>", user_str)
     # check proper unicode() and str() handling
     self.assertIsInstance(str(user), bytes)
     self.assertIsInstance(unicode(user), unicode)
     
     self.assertFalse(user.is_empty())
     self.assertTrue(User().is_empty())
     
     user_repr = "{0!r}".format(user)
     expected = "User(login='root', realm='realm1', resolver='resolver1')"
     self.assertTrue(user_repr == expected, user_repr)
开发者ID:STRML,项目名称:privacyidea,代码行数:29,代码来源:test_lib_user.py

示例3: test_00_create_user_realm

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import is_empty [as 别名]
    def test_00_create_user_realm(self):
        rid = save_resolver({"resolver": self.resolvername1, "type": "passwdresolver", "fileName": PWFILE})
        self.assertTrue(rid > 0, rid)

        (added, failed) = set_realm(self.realm1, [self.resolvername1])
        self.assertTrue(len(failed) == 0)
        self.assertTrue(len(added) == 1)

        user = User(login="root", realm=self.realm1, resolver=self.resolvername1)

        user_str = "%s" % user
        self.assertTrue(user_str == "<[email protected]>", user_str)

        self.assertFalse(user.is_empty())
        self.assertTrue(User().is_empty())

        user_repr = "%r" % user
        expected = "User(login='root', realm='realm1', resolver='resolver1')"
        self.assertTrue(user_repr == expected, user_repr)
开发者ID:tongwen-it,项目名称:privacyidea,代码行数:21,代码来源:test_lib_tokens_daplug.py

示例4: test_21_check_all_resolver

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import is_empty [as 别名]
    def test_21_check_all_resolver(self):
        # check_all_resolver allows to find a policy for a secondary user
        # resolver.
        # We create one realm "realm1" with the resolvers
        # reso1 (prio 1)
        # reso2 (prio 2)
        # reso3 (prio 3)
        # A user [email protected] will be identified as [email protected]
        # But we will also match policies for reso2.

        # no realm and resolver
        r = get_realms()
        self.assertEqual(r, {})

        r = get_resolver_list()
        self.assertEqual(r, {})

        # create user realm
        for reso in ["reso1", "resoX", "resoA"]:
            rid = save_resolver({"resolver": reso,
                                 "type": "passwdresolver",
                                 "fileName": PWFILE})
            self.assertTrue(rid > 0, rid)

        # create a realm with reso1 being the resolver with the highest priority
        (added, failed) = set_realm("realm1",
                                    ["reso1", "resoX", "resoA"],
                                    priority={"reso1": 1,
                                              "resoX": 2,
                                              "resoA": 3})
        self.assertTrue(len(failed) == 0)
        self.assertTrue(len(added) == 3)

        user = User(login="cornelius",
                    realm="realm1")
        # The user, that is created, is [email protected]
        user_str = "{0!s}".format(user)
        self.assertEqual(user_str, "<[email protected]>")
        # But the user "cornelius" is also contained in other resolves in
        # this realm
        r = user.get_ordererd_resolvers()
        self.assertEqual(r, ["reso1", "resoX", "resoA"])
        self.assertFalse(user.is_empty())
        self.assertTrue(User().is_empty())

        # define a policy with the wrong resolver
        p = set_policy(name="checkAll", scope=SCOPE.AUTHZ, realm="realm1",
                       resolver="resoX",
                       action="{0}=totp".format(ACTION.TOKENTYPE))
        self.assertTrue(p > 0)
        p = set_policy(name="catchAll", scope=SCOPE.AUTHZ, realm="realm1",
                       action="{0}=totp".format(ACTION.TOKENTYPE))
        self.assertTrue(p > 0)
        P = PolicyClass()
        pols = P.get_policies(scope=SCOPE.AUTHZ, realm=user.realm,
                              resolver=user.resolver, user=user.login)
        self.assertEqual(len(pols), 1)

        # Now we change the policy, so that it uses check_all_resolver, i.e.
        p = set_policy(name="checkAll", scope=SCOPE.AUTHZ, realm="realm1",
                       resolver="resoX", check_all_resolvers=True,
                       action="{0}=totp".format(ACTION.TOKENTYPE))
        self.assertTrue(p > 0)
        P = PolicyClass()
        pols = P.get_policies(scope=SCOPE.AUTHZ, realm=user.realm,
                              resolver=user.resolver, user=user.login)
        self.assertEqual(len(pols), 2)

        # delete policy
        delete_policy("checkAll")
        delete_policy("catchAll")
        # delete resolvers and realm
        delete_realm("realm1")
        for reso in ["reso1", "resoX", "resoA"]:
            rid = delete_resolver(reso)
            self.assertTrue(rid > 0, rid)
开发者ID:STRML,项目名称:privacyidea,代码行数:78,代码来源:test_lib_policy.py


注:本文中的privacyidea.lib.user.User.is_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。