mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 09:06:29 +00:00
Small cleanups with pwned handling (#2625)
This commit is contained in:
parent
115af4cadf
commit
739cfbb273
@ -138,7 +138,7 @@ class AddonOptions(CoreSysAttributes):
|
|||||||
range_args[group_name[2:]] = float(group_value)
|
range_args[group_name[2:]] = float(group_value)
|
||||||
|
|
||||||
if typ.startswith(_STR) or typ.startswith(_PASSWORD):
|
if typ.startswith(_STR) or typ.startswith(_PASSWORD):
|
||||||
if typ.startswith(_PASSWORD):
|
if typ.startswith(_PASSWORD) and value:
|
||||||
self.pwned.add(hashlib.sha1(str(value).encode()).hexdigest())
|
self.pwned.add(hashlib.sha1(str(value).encode()).hexdigest())
|
||||||
return vol.All(str(value), vol.Range(**range_args))(value)
|
return vol.All(str(value), vol.Range(**range_args))(value)
|
||||||
elif typ.startswith(_INT):
|
elif typ.startswith(_INT):
|
||||||
|
@ -22,7 +22,7 @@ async def check_pwned_password(websession: aiohttp.ClientSession, sha1_pw: str)
|
|||||||
data = await request.text()
|
data = await request.text()
|
||||||
|
|
||||||
buffer = io.StringIO(data)
|
buffer = io.StringIO(data)
|
||||||
for line in buffer.readline():
|
for line in buffer:
|
||||||
if sha1_pw != line.split(":")[0]:
|
if sha1_pw != line.split(":")[0]:
|
||||||
continue
|
continue
|
||||||
return True
|
return True
|
||||||
|
@ -181,6 +181,11 @@ def test_simple_schema_password(coresys):
|
|||||||
|
|
||||||
assert validate.pwned == {"7110eda4d09e062aa5e4a390b0a572ac0d2c0220"}
|
assert validate.pwned == {"7110eda4d09e062aa5e4a390b0a572ac0d2c0220"}
|
||||||
|
|
||||||
|
validate.pwned.clear()
|
||||||
|
assert validate({"name": "Pascal", "password": "", "fires": True, "alias": "test"})
|
||||||
|
|
||||||
|
assert not validate.pwned
|
||||||
|
|
||||||
|
|
||||||
def test_ui_simple_schema(coresys):
|
def test_ui_simple_schema(coresys):
|
||||||
"""Test with simple schema."""
|
"""Test with simple schema."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user