fix(install): a fresh install creates ntfy accounts without prompts (database created first; phone uses the web password)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import subprocess
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
@@ -68,5 +69,21 @@ class TokenTests(unittest.TestCase):
|
||||
self.assertEqual(path.stat().st_mode & 0o777, 0o600)
|
||||
|
||||
|
||||
class NonInteractiveAccounts(unittest.TestCase):
|
||||
def test_given_passwords_are_used_without_prompts(self):
|
||||
calls = []
|
||||
|
||||
def run(args, capture=False, interactive=False, password=None):
|
||||
calls.append((tuple(args), interactive, password))
|
||||
out = "token tk_abcdefghijklmnopqrstuvwxyz123 created" if args[0] == "token" else ""
|
||||
return subprocess.CompletedProcess(args, 0, stdout=out, stderr="")
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
save_token.bootstrap_accounts(run, Path(directory) / "token", 0o600, log=lambda _m: None,
|
||||
publisher_password="p1", reader_password="p2")
|
||||
adds = [(args[3], interactive, password) for args, interactive, password in calls if args[:2] == ("user", "add")]
|
||||
self.assertEqual(adds, [("pipeline-publisher", False, "p1"), ("phone-reader", False, "p2")])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user