test_ext_django.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:enkiWS 作者: juliettef 项目源码 文件源码
def setUp(self):
            # NOTE: omitted orig setup, want to install our extension,
            #       and load hashers through it instead.
            self.load_extension(PASSLIB_CONTEXT=stock_config, check=False)
            from passlib.ext.django.models import password_context

            # update test module to use our versions of some hasher funcs
            from django.contrib.auth import hashers
            for attr in ["make_password",
                         "check_password",
                         "identify_hasher",
                         "get_hasher"]:
                patchAttr(self, _thmod, attr, getattr(hashers, attr))

            # django 1.5 tests expect empty django_des_crypt salt field
            if DJANGO_VERSION > (1,4):
                from passlib.hash import django_des_crypt
                patchAttr(self, django_des_crypt, "use_duplicate_salt", False)

            # hack: need password_context to keep up to date with hasher.iterations
            if DJANGO_VERSION >= (1,6):
                def update_hook(self):
                    rounds = _thmod.get_hasher("pbkdf2_sha256").iterations
                    self.update(
                        django_pbkdf2_sha256__min_rounds=rounds,
                        django_pbkdf2_sha256__default_rounds=rounds,
                        django_pbkdf2_sha256__max_rounds=rounds,
                    )
                patchAttr(self, password_context, "__class__", ContextWithHook)
                patchAttr(self, password_context, "update_hook", update_hook)

        # omitting this test, since it depends on updated to django hasher settings
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号