Add web administration
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import unittest
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
from site_engine.cli import main
|
||||
from site_engine.services.auth import verify_password
|
||||
|
||||
|
||||
class CliAuthTest(unittest.TestCase):
|
||||
def test_hash_password_prints_verifiable_hash(self):
|
||||
result = CliRunner().invoke(main, ["hash-password"], input="correct horse battery\ncorrect horse battery\n")
|
||||
self.assertEqual(result.exit_code, 0, result.output)
|
||||
stored = [line for line in result.output.splitlines() if line.startswith("scrypt$")][0]
|
||||
self.assertTrue(verify_password("correct horse battery", stored))
|
||||
self.assertNotIn("correct horse battery", stored)
|
||||
|
||||
def test_hash_password_rejects_short_password(self):
|
||||
result = CliRunner().invoke(main, ["hash-password"], input="short\nshort\n")
|
||||
self.assertNotEqual(result.exit_code, 0)
|
||||
self.assertIn("минимум", result.output)
|
||||
|
||||
def test_gen_secret_is_long_and_random(self):
|
||||
a = CliRunner().invoke(main, ["gen-secret"]).output.strip()
|
||||
b = CliRunner().invoke(main, ["gen-secret"]).output.strip()
|
||||
self.assertGreaterEqual(len(a), 48)
|
||||
self.assertNotEqual(a, b)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user