feat(local-accounts): a deleted key can take the password with it
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Successful in 1m2s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / lowest (pull_request) Successful in 38s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m7s
CI / driver (pull_request) Successful in 2m29s
driver / publish (pull_request) Skipped

napalm-device-types 4.29.0 lets remove_local_account_keys clear the password and sudo too (NetOrk/netork#2033). This driver's _account_clear_password already does the work; a test pins the commands, and the floor rises to 4.29.0.
This commit is contained in:
Christian Manivong committed 2026-11-04 15:22:49 +01:00
1 parent 5c13ce1a8b
commit 60ccea9a98
3 files changed
+27 -1

No files matched your search

+17
View File
@@ -205,6 +205,23 @@ def test_a_replaced_key_is_written_out_of_the_key_file_as_the_person() -> None:
assert installs and all(c.startswith("sudo -n -u alice install") for c in installs)
def test_a_deleted_key_takes_the_password_and_sudo_with_it_when_asked() -> None:
"""NetOrk/netork#2033: the password went with the person's key, so it goes from the
host too, with sudo; the account stays open."""
host = _Host(_OPEN, keys=f"{ALICE_KEY}\n{OWN_KEY}\n")
result = host.remove_local_account_keys("alice", [ALICE_KEY], clear_password=True)
assert result["success"], result["output"]
assert [s["step"] for s in result["steps"]] == ["keys", "password", "sudo"]
assert host.files[_KEYS] == f"{OWN_KEY}\n"
assert host.as_root() == [
["usermod", "-p", "*", "alice"],
["rm", "-f", "--", "/etc/sudoers.d/80-account-alice"],
["gpasswd", "-d", "alice", "sudo"],
]
def test_a_deleted_key_goes_and_the_account_stays_open() -> None:
host = _Host(_OPEN, keys=f"{ALICE_KEY}\n{OWN_KEY}\n")