Forget passwords clears every stored admin password in one step
The reporter of #28 asked for a way to clear one or all of the stored admin passwords. Del in the node picker forgets one. This adds the other: a "Forget passwords" row in the Managed nodes section of the menu, behind the red typed confirm (type FORGET), which names the nodes it will forget. It also forgets the password of a node that is no longer a contact, which no list shows. With nothing stored, it says so and asks nothing. On the CLI it is `forget-admin-passwords --yes`: without --yes it is a usage error, and with it the answer lists the nodes it forgot (NAME, LAST_LOGIN, KEY). It exits 5 when nothing was stored, and works with no device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e8a3b439cd
commit
4356bc9012
8 files changed
+406
-7
No files matched your search
@@ -581,8 +581,16 @@ def test_a_failure_says_so_on_stderr_and_never_on_stdout(run) -> None: # noqa:
|
||||
("config", "import-key", "00" * 32),
|
||||
("channels", "clear", "1"),
|
||||
("preferences", "reset"),
|
||||
("forget-admin-passwords",),
|
||||
],
|
||||
ids=[
|
||||
"reboot",
|
||||
"factory-reset",
|
||||
"import-key",
|
||||
"channels-clear",
|
||||
"preferences-reset",
|
||||
"forget-admin-passwords",
|
||||
],
|
||||
ids=["reboot", "factory-reset", "import-key", "channels-clear", "preferences-reset"],
|
||||
)
|
||||
def test_a_destructive_command_without_yes_is_a_silent_usage_error(run, args) -> None: # noqa: ANN001
|
||||
"""A missing confirmation is a bad argument, and the message goes where errors go.
|
||||
@@ -597,6 +605,30 @@ def test_a_destructive_command_without_yes_is_a_silent_usage_error(run, args) ->
|
||||
assert "--yes" in result.stderr
|
||||
|
||||
|
||||
def test_forget_admin_passwords_lists_what_it_forgot_and_exits_5_on_nothing(
|
||||
run, tmp_path: Path
|
||||
) -> None: # noqa: ANN001
|
||||
"""GitHub issue 28: one command forgets all the stored admin passwords.
|
||||
|
||||
The answer is the list of the nodes that it forgot, and the ✓ goes to stderr. A second
|
||||
run finds nothing, so it exits with ``5`` and its document is the empty array.
|
||||
"""
|
||||
assert run("repeater-admin", "Yagi-Repeater", "ver", "--password", "admin").exit_code == 0
|
||||
assert (tmp_path / "home" / "admin.json").read_text(encoding="utf-8").strip() != "{}"
|
||||
|
||||
result = run("forget-admin-passwords", "--yes")
|
||||
assert result.exit_code == exitcodes.OK, result.output
|
||||
header, row = result_lines(result)
|
||||
assert header.split() == ["NAME", "LAST_LOGIN", "KEY"]
|
||||
assert row.split()[:2] == ["Yagi-Repeater", "now"]
|
||||
assert "forgot 1 admin password" in result.stderr
|
||||
assert json.loads((tmp_path / "home" / "admin.json").read_text(encoding="utf-8")) == {}
|
||||
|
||||
again = run("--json", "forget-admin-passwords", "--yes")
|
||||
assert again.exit_code == exitcodes.NO_RESULT
|
||||
assert json.loads(again.stdout) == []
|
||||
|
||||
|
||||
def test_import_key_reads_a_file_and_keeps_the_key_out_of_the_run_log(run, tmp_path: Path) -> None: # noqa: ANN001
|
||||
"""The run log stores the parameters of each run, and a private key is not one to keep.
|
||||
|
||||
|
||||
Reference in new issue
Block a user