def test_salt_hash_to_dict(self): salt_hash = "sha$3863$d894911422c320e2f656f08fe32c13219537221d" check = { 'type': 'sha', 'salt': '3863', 'hash': 'd894911422c320e2f656f08fe32c13219537221d' } salt_hash_dict = salt_hash_to_dict(salt_hash) self.assertEqual(salt_hash_dict, check)
try: check_password_hash(password_hash) except WrongPassword, msg: # Display the form again self.request.page_msg.write(msg) else: # Password is ok. -> process the normal _instal view() response = self.view(*args) # insert a cookie with the hashed password in the response salt_hash = crypt.make_salt_hash(str(password_hash)) response.set_cookie( settings.INSTALL_COOKIE_NAME, value=salt_hash, max_age=None ) return response data = crypt.salt_hash_to_dict(settings.INSTALL_PASSWORD_HASH) self.context["salt"] = data["salt"] self.context["no_menu_link"] = True # no "back to menu" link # self.request.page_msg.write(_("Please input the password")) return render_to_response("install_login.html", self.context) #___________________________________________________________________________ def _redirect_execute(self, method, *args, **kwargs): """ run a method an redirect stdout writes (print) into a Buffer. puts the redirected outputs into self.context["output"]. usefull to run django management functions. """ redirect = SimpleStringIO()