mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 13:01:50 +02:00
add option to select hash method
this will fix tests
This commit is contained in:
parent
3894f1568a
commit
8847894421
2 changed files with 8 additions and 4 deletions
|
@ -34,10 +34,14 @@ def runserver(ctx):
|
||||||
|
|
||||||
|
|
||||||
@click.command(name="generate_password_hash")
|
@click.command(name="generate_password_hash")
|
||||||
def 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):
|
||||||
"""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))
|
print(generate_password_hash(password, method=method))
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
|
|
@ -89,8 +89,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)
|
result = runner.invoke(password_hash, ["--method", "pbkdf2:sha256:260000"])
|
||||||
self.assertEqual(len(result.output.strip()), 94)
|
self.assertEqual(len(result.output.strip()), 102)
|
||||||
|
|
||||||
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