mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 05:01:48 +02:00
revert method choice, but fix the test for every werkzeug version
This commit is contained in:
parent
8847894421
commit
ae8d7b2213
2 changed files with 5 additions and 8 deletions
|
@ -34,14 +34,10 @@ def runserver(ctx):
|
|||
|
||||
|
||||
@click.command(name="generate_password_hash")
|
||||
@click.option(
|
||||
"--method",
|
||||
help="""Password method. See https://werkzeug.palletsprojects.com/en/2.0.x/utils/#werkzeug.security.generate_password_hash""", # NOQA
|
||||
)
|
||||
def password_hash(method):
|
||||
def password_hash():
|
||||
"""Get password from user and hash it without printing it in clear text."""
|
||||
password = getpass.getpass(prompt="Password: ")
|
||||
print(generate_password_hash(password, method=method))
|
||||
print(generate_password_hash(password))
|
||||
|
||||
|
||||
@click.command()
|
||||
|
|
|
@ -11,6 +11,7 @@ from ihatemoney.currency_convertor import CurrencyConverter
|
|||
from ihatemoney.manage import delete_project, generate_config, password_hash
|
||||
from ihatemoney.run import load_configuration
|
||||
from ihatemoney.tests.common.ihatemoney_testcase import BaseTestCase, IhatemoneyTestCase
|
||||
from werkzeug.security import check_password_hash
|
||||
|
||||
# Unset configuration file env var if previously set
|
||||
os.environ.pop("IHATEMONEY_SETTINGS_FILE_PATH", None)
|
||||
|
@ -89,8 +90,8 @@ class CommandTestCase(BaseTestCase):
|
|||
def test_generate_password_hash(self):
|
||||
runner = self.app.test_cli_runner()
|
||||
with patch("getpass.getpass", new=lambda prompt: "secret"):
|
||||
result = runner.invoke(password_hash, ["--method", "pbkdf2:sha256:260000"])
|
||||
self.assertEqual(len(result.output.strip()), 102)
|
||||
result = runner.invoke(password_hash)
|
||||
self.assertTrue(check_password_hash(result.output.strip(), "secret"))
|
||||
|
||||
def test_demo_project_deletion(self):
|
||||
self.create_project("demo")
|
||||
|
|
Loading…
Reference in a new issue