python类has_usable_password()的实例源码

test_ext_django.py 文件源码 项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        self.assertTrue(user.has_usable_password(),
                        "hash should be usable: %r" % (user.password,))
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        if has_django1 or self.patched:
            self.assertTrue(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        if has_django1 or self.patched:
            self.assertTrue(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:GAMADV-X 作者: taers232c 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        self.assertTrue(user.has_usable_password(),
                        "hash should be usable: %r" % (user.password,))
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:enkiWS 作者: juliettef 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        if has_django1 or self.patched:
            self.assertTrue(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:python-flask-security 作者: weinbergdavid 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def assert_valid_password(self, user, hash=UNSET, saved=None):
        """check that user object has a usuable password hash.

        :param hash: optionally check it has this exact hash
        :param saved: check that mock commit history
                      for user.password matches this list
        """
        if hash is UNSET:
            self.assertNotEqual(user.password, "!")
            self.assertNotEqual(user.password, None)
        else:
            self.assertEqual(user.password, hash)
        if has_django1 or self.patched:
            self.assertTrue(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(),
                         [] if saved is None else [saved])
test_ext_django.py 文件源码 项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        self.assertTrue(user.password.startswith("!"))
        self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])
test_ext_django.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _iter_patch_candidates(cls):
        """helper to scan for monkeypatches.

        returns tuple containing:
        * object (module or class)
        * attribute of object
        * value of attribute
        * whether it should or should not be patched
        """
        # XXX: this and assert_unpatched() could probably be refactored to use
        #      the PatchManager class to do the heavy lifting.
        from django.contrib.auth import models
        user_attrs = ["check_password", "set_password"]
        model_attrs = ["check_password"]
        objs = [(models, model_attrs), (models.User, user_attrs)]
        if has_django14:
            from django.contrib.auth import hashers
            model_attrs.append("make_password")
            objs.append((hashers, ["check_password", "make_password",
                                   "get_hasher", "identify_hasher"]))
        if has_django0:
            user_attrs.extend(["has_usable_password", "set_unusable_password"])
        for obj, patched in objs:
            for attr in dir(obj):
                if attr.startswith("_"):
                    continue
                value = obj.__dict__.get(attr, UNSET) # can't use getattr() due to GAE
                if value is UNSET and attr not in patched:
                    continue
                value = get_method_function(value)
                source = getattr(value, "__module__", None)
                if source:
                    yield obj, attr, source, (attr in patched)

    #===================================================================
    # verify current patch state
    #===================================================================
test_ext_django.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        if DJANGO_VERSION >= (1,6):
            # 1.6 on adds a random(?) suffix
            self.assertTrue(user.password.startswith("!"))
        else:
            self.assertEqual(user.password, "!")
        if has_django1 or self.patched:
            self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])
test_ext_django.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _iter_patch_candidates(cls):
        """helper to scan for monkeypatches.

        returns tuple containing:
        * object (module or class)
        * attribute of object
        * value of attribute
        * whether it should or should not be patched
        """
        # XXX: this and assert_unpatched() could probably be refactored to use
        #      the PatchManager class to do the heavy lifting.
        from django.contrib.auth import models
        user_attrs = ["check_password", "set_password"]
        model_attrs = ["check_password"]
        objs = [(models, model_attrs), (models.User, user_attrs)]
        if has_django14:
            from django.contrib.auth import hashers
            model_attrs.append("make_password")
            objs.append((hashers, ["check_password", "make_password",
                                   "get_hasher", "identify_hasher"]))
        if has_django0:
            user_attrs.extend(["has_usable_password", "set_unusable_password"])
        for obj, patched in objs:
            for attr in dir(obj):
                if attr.startswith("_"):
                    continue
                value = obj.__dict__.get(attr, UNSET) # can't use getattr() due to GAE
                if value is UNSET and attr not in patched:
                    continue
                value = get_method_function(value)
                source = getattr(value, "__module__", None)
                if source:
                    yield obj, attr, source, (attr in patched)

    #===================================================================
    # verify current patch state
    #===================================================================
test_ext_django.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        if DJANGO_VERSION >= (1,6):
            # 1.6 on adds a random(?) suffix
            self.assertTrue(user.password.startswith("!"))
        else:
            self.assertEqual(user.password, "!")
        if has_django1 or self.patched:
            self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])
test_ext_django.py 文件源码 项目:GAMADV-X 作者: taers232c 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        self.assertTrue(user.password.startswith("!"))
        self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])
test_ext_django.py 文件源码 项目:enkiWS 作者: juliettef 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def _iter_patch_candidates(cls):
        """helper to scan for monkeypatches.

        returns tuple containing:
        * object (module or class)
        * attribute of object
        * value of attribute
        * whether it should or should not be patched
        """
        # XXX: this and assert_unpatched() could probably be refactored to use
        #      the PatchManager class to do the heavy lifting.
        from django.contrib.auth import models
        user_attrs = ["check_password", "set_password"]
        model_attrs = ["check_password"]
        objs = [(models, model_attrs), (models.User, user_attrs)]
        if has_django14:
            from django.contrib.auth import hashers
            model_attrs.append("make_password")
            objs.append((hashers, ["check_password", "make_password",
                                   "get_hasher", "identify_hasher"]))
        if has_django0:
            user_attrs.extend(["has_usable_password", "set_unusable_password"])
        for obj, patched in objs:
            for attr in dir(obj):
                if attr.startswith("_"):
                    continue
                value = obj.__dict__.get(attr, UNSET) # can't use getattr() due to GAE
                if value is UNSET and attr not in patched:
                    continue
                value = get_method_function(value)
                source = getattr(value, "__module__", None)
                if source:
                    yield obj, attr, source, (attr in patched)

    #===================================================================
    # verify current patch state
    #===================================================================
test_ext_django.py 文件源码 项目:enkiWS 作者: juliettef 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        if DJANGO_VERSION >= (1,6):
            # 1.6 on adds a random(?) suffix
            self.assertTrue(user.password.startswith("!"))
        else:
            self.assertEqual(user.password, "!")
        if has_django1 or self.patched:
            self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])
test_ext_django.py 文件源码 项目:python-flask-security 作者: weinbergdavid 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _iter_patch_candidates(cls):
        """helper to scan for monkeypatches.

        returns tuple containing:
        * object (module or class)
        * attribute of object
        * value of attribute
        * whether it should or should not be patched
        """
        # XXX: this and assert_unpatched() could probably be refactored to use
        #      the PatchManager class to do the heavy lifting.
        from django.contrib.auth import models
        user_attrs = ["check_password", "set_password"]
        model_attrs = ["check_password"]
        objs = [(models, model_attrs), (models.User, user_attrs)]
        if has_django14:
            from django.contrib.auth import hashers
            model_attrs.append("make_password")
            objs.append((hashers, ["check_password", "make_password",
                                   "get_hasher", "identify_hasher"]))
        if has_django0:
            user_attrs.extend(["has_usable_password", "set_unusable_password"])
        for obj, patched in objs:
            for attr in dir(obj):
                if attr.startswith("_"):
                    continue
                value = obj.__dict__.get(attr, UNSET) # can't use getattr() due to GAE
                if value is UNSET and attr not in patched:
                    continue
                value = get_method_function(value)
                source = getattr(value, "__module__", None)
                if source:
                    yield obj, attr, source, (attr in patched)

    #===================================================================
    # verify current patch state
    #===================================================================
test_ext_django.py 文件源码 项目:python-flask-security 作者: weinbergdavid 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def assert_unusable_password(self, user):
        """check that user object is set to 'unusable password' constant"""
        if DJANGO_VERSION >= (1,6):
            # 1.6 on adds a random(?) suffix
            self.assertTrue(user.password.startswith("!"))
        else:
            self.assertEqual(user.password, "!")
        if has_django1 or self.patched:
            self.assertFalse(user.has_usable_password())
        self.assertEqual(user.pop_saved_passwords(), [])


问题


面经


文章

微信
公众号

扫码关注公众号