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.command(name="generate_password_hash")
|
||||||
@click.option(
|
def password_hash():
|
||||||
"--method",
|
|
||||||
help="""Password method. See https://werkzeug.palletsprojects.com/en/2.0.x/utils/#werkzeug.security.generate_password_hash""", # NOQA
|
|
||||||
)
|
|
||||||
def password_hash(method):
|
|
||||||
"""Get password from user and hash it without printing it in clear text."""
|
"""Get password from user and hash it without printing it in clear text."""
|
||||||
password = getpass.getpass(prompt="Password: ")
|
password = getpass.getpass(prompt="Password: ")
|
||||||
print(generate_password_hash(password, method=method))
|
print(generate_password_hash(password))
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
|
|
@ -11,6 +11,7 @@ from ihatemoney.currency_convertor import CurrencyConverter
|
||||||
from ihatemoney.manage import delete_project, generate_config, password_hash
|
from ihatemoney.manage import delete_project, generate_config, password_hash
|
||||||
from ihatemoney.run import load_configuration
|
from ihatemoney.run import load_configuration
|
||||||
from ihatemoney.tests.common.ihatemoney_testcase import BaseTestCase, IhatemoneyTestCase
|
from ihatemoney.tests.common.ihatemoney_testcase import BaseTestCase, IhatemoneyTestCase
|
||||||
|
from werkzeug.security import check_password_hash
|
||||||
|
|
||||||
# Unset configuration file env var if previously set
|
# Unset configuration file env var if previously set
|
||||||
os.environ.pop("IHATEMONEY_SETTINGS_FILE_PATH", None)
|
os.environ.pop("IHATEMONEY_SETTINGS_FILE_PATH", None)
|
||||||
|
@ -89,8 +90,8 @@ class CommandTestCase(BaseTestCase):
|
||||||
def test_generate_password_hash(self):
|
def test_generate_password_hash(self):
|
||||||
runner = self.app.test_cli_runner()
|
runner = self.app.test_cli_runner()
|
||||||
with patch("getpass.getpass", new=lambda prompt: "secret"):
|
with patch("getpass.getpass", new=lambda prompt: "secret"):
|
||||||
result = runner.invoke(password_hash, ["--method", "pbkdf2:sha256:260000"])
|
result = runner.invoke(password_hash)
|
||||||
self.assertEqual(len(result.output.strip()), 102)
|
self.assertTrue(check_password_hash(result.output.strip(), "secret"))
|
||||||
|
|
||||||
def test_demo_project_deletion(self):
|
def test_demo_project_deletion(self):
|
||||||
self.create_project("demo")
|
self.create_project("demo")
|
||||||
|
|
Loading…
Reference in a new issue