mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] re-put assert password is strong enough
This commit is contained in:
parent
2eb5f6b6da
commit
bcd2364d74
2 changed files with 24 additions and 2 deletions
|
@ -2484,6 +2484,9 @@ class PasswordArgumentParser(YunoHostArgumentFormatParser):
|
||||||
if any(char in question.value for char in self.forbidden_chars):
|
if any(char in question.value for char in self.forbidden_chars):
|
||||||
raise YunohostError('pattern_password_app', forbidden_chars=self.forbidden_chars)
|
raise YunohostError('pattern_password_app', forbidden_chars=self.forbidden_chars)
|
||||||
|
|
||||||
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
|
assert_password_is_strong_enough('user', question.value)
|
||||||
|
|
||||||
return super(PasswordArgumentParser, self)._post_parse_value(question)
|
return super(PasswordArgumentParser, self)._post_parse_value(question)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -247,8 +247,9 @@ def test_parse_args_in_yunohost_format_password_input_no_ask():
|
||||||
def test_parse_args_in_yunohost_format_password_no_input_optional():
|
def test_parse_args_in_yunohost_format_password_no_input_optional():
|
||||||
questions = [{"name": "some_password", "type": "password", "optional": True,}]
|
questions = [{"name": "some_password", "type": "password", "optional": True,}]
|
||||||
answers = {}
|
answers = {}
|
||||||
expected_result = OrderedDict({"some_password": ("", "password")})
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
with pytest.raises(YunohostError):
|
||||||
|
_parse_args_in_yunohost_format(answers, questions)
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_password_optional_with_input():
|
def test_parse_args_in_yunohost_format_password_optional_with_input():
|
||||||
|
@ -374,6 +375,24 @@ def test_parse_args_in_yunohost_format_password_bad_chars():
|
||||||
_parse_args_in_yunohost_format({"some_password": i * 8}, questions)
|
_parse_args_in_yunohost_format({"some_password": i * 8}, questions)
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_args_in_yunohost_format_password_strong_enough():
|
||||||
|
questions = [
|
||||||
|
{
|
||||||
|
"name": "some_password",
|
||||||
|
"type": "password",
|
||||||
|
"ask": "some question",
|
||||||
|
"example": "some_value",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
with pytest.raises(YunohostError):
|
||||||
|
# too short
|
||||||
|
_parse_args_in_yunohost_format({"some_password": "a"}, questions)
|
||||||
|
|
||||||
|
with pytest.raises(YunohostError):
|
||||||
|
_parse_args_in_yunohost_format({"some_password": "password"}, questions)
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_path():
|
def test_parse_args_in_yunohost_format_path():
|
||||||
questions = [{"name": "some_path", "type": "path",}]
|
questions = [{"name": "some_path", "type": "path",}]
|
||||||
answers = {"some_path": "some_value"}
|
answers = {"some_path": "some_value"}
|
||||||
|
|
Loading…
Add table
Reference in a new issue