[+] add tests for pr34

This commit is contained in:
Siarhei Siniak 2025-03-03 17:57:14 +03:00
parent 62063a1448
commit 731c507b95
5 changed files with 34 additions and 2 deletions

@ -6,6 +6,9 @@ host_deps:
python_lint:
./m.py mypy -- -f vscode 2>&1 | less
python_tests:
./m.py tests
#python_clean_online_fxreader_vpn:
# rm -fr \
# deps/com.github.aiortc.aiortc/src/online_fxreader/vpn/dist;

@ -26,6 +26,7 @@ logger = logging.getLogger(__name__)
class Command(enum.StrEnum):
mypy = 'mypy'
deploy_wheel = 'deploy:wheel'
tests = 'tests'
@dataclasses.dataclass
class Settings(
@ -145,8 +146,17 @@ class CLI(_cli.CLI):
self.mypy(
argv=args,
)
elif options.command is Command.tests:
for k, v in self.projects.items():
subprocess.check_call([
sys.executable,
'-m',
'unittest',
'online.fxreader.pr34.tests.test_crypto',
*args,
], cwd=str(v.source_dir))
else:
raise NotImplementedError
if __name__ == '__main__':
CLI().run()
CLI().run()

@ -45,7 +45,7 @@ class PasswordUtils:
return (salt, hashed_secret)
elif mode == 'base64':
res_tuple = tuple((
base64.b64encode(o, width=0).decode('utf-8')
base64.b64encode(o).decode('utf-8')
for o in (salt, hashed_secret,)
))
return (res_tuple[0], res_tuple[1])

@ -0,0 +1,19 @@
from online.fxreader.pr34.commands_typed import crypto
import unittest
class TestCrypto(unittest.TestCase):
def test_password_utils(self):
salt = b'asdfasdfasdf'
self.assertEqual(
crypto.PasswordUtils.encrypt(
'blah',
mode='bytes',
salt=salt,
),
[
salt,
b'asdfasdf',
]
)