1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-20 18:38:59 +00:00

Fix source-mod check (#3439)

* Fix source-mod check

* Fix stderr

* make handling robust
This commit is contained in:
Pascal Vizeli
2022-02-10 13:23:05 +01:00
committed by GitHub
parent d6e44b43b4
commit 597a27ba33
4 changed files with 35 additions and 10 deletions

View File

@@ -1,7 +1,9 @@
"""Test CodeNotary."""
import pytest
from supervisor.utils.codenotary import calc_checksum
from supervisor.exceptions import CodeNotaryUntrusted
from supervisor.utils.codenotary import calc_checksum, cas_validate
def test_checksum_calc():
@@ -11,3 +13,20 @@ def test_checksum_calc():
calc_checksum("test")
== "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
)
async def test_valid_checksum():
"""Test a valid autorization."""
await cas_validate(
"notary@home-assistant.io",
"4434a33ff9c695e870bc5bbe04230ea3361ecf4c129eb06133dd1373975a43f0",
)
async def test_invalid_checksum():
"""Test a invalid autorization."""
with pytest.raises(CodeNotaryUntrusted):
await cas_validate(
"notary@home-assistant.io",
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
)