feat(logins): optional keys for another platform's login accounts and sessions (NetOrk/netork#2895)
LoginAccountDict may carry sid, administrator and remote_desktop; uid stays an int and is the RID where a SID is given. LoginAccountsDict may carry groups (LoginGroupDict, LoginGroupMemberDict, LOGIN_GRANTS): the groups that grant administering the host or a remote desktop login, with every member. LoginSessionsDict may carry records_since, the oldest entry the record still holds. All optional: the Linux reading and every driver that builds one are unchanged.
This commit is contained in:
1 parent
2df46741f2
commit
a825d48c19
7 files changed
+176
-11
No files matched your search
@@ -481,3 +481,46 @@ class TestTheCommand:
|
||||
reading = parse_login_accounts(out)
|
||||
|
||||
assert isinstance(reading["accounts"], list)
|
||||
|
||||
|
||||
class TestWhatAnotherPlatformAdds:
|
||||
"""Keys a Windows host fills (NetOrk/netork#2895), optional, so the Linux reading and
|
||||
every driver that builds one stay as they are."""
|
||||
|
||||
def test_the_account_keys_linux_fills_stay_required(self):
|
||||
from napalm_device_types.login_accounts import LoginAccountDict
|
||||
|
||||
assert {"name", "uid", "home", "shell", "locked"} <= LoginAccountDict.__required_keys__
|
||||
assert LoginAccountDict.__optional_keys__ == frozenset(
|
||||
{"sid", "administrator", "remote_desktop"}
|
||||
)
|
||||
|
||||
def test_the_reading_may_name_the_privileged_groups(self):
|
||||
from napalm_device_types.login_accounts import (
|
||||
LoginAccountsDict,
|
||||
LoginGroupDict,
|
||||
LoginGroupMemberDict,
|
||||
)
|
||||
|
||||
assert LoginAccountsDict.__optional_keys__ == frozenset({"groups"})
|
||||
assert LoginGroupDict.__required_keys__ == frozenset({"name", "sid", "grants", "members"})
|
||||
assert LoginGroupMemberDict.__required_keys__ == frozenset(
|
||||
{"name", "sid", "local", "group"}
|
||||
)
|
||||
|
||||
def test_the_grants_are_named(self):
|
||||
from napalm_device_types.login_accounts import LOGIN_GRANTS
|
||||
|
||||
assert LOGIN_GRANTS == ("administrator", "remote_desktop")
|
||||
|
||||
def test_the_linux_reading_sets_none_of_them(self):
|
||||
reading = parse_login_accounts(_wire(DEBIAN_12))
|
||||
|
||||
assert "groups" not in reading
|
||||
for account in reading["accounts"]:
|
||||
assert not {"sid", "administrator", "remote_desktop"} & account.keys()
|
||||
|
||||
def test_they_are_exported(self):
|
||||
import napalm_device_types as dt
|
||||
|
||||
assert dt.LoginGroupDict and dt.LoginGroupMemberDict and dt.LOGIN_GRANTS
|
||||
@@ -290,3 +290,18 @@ class TestTheCommand:
|
||||
except LoginSessionsUnavailable: # a host without login records
|
||||
return
|
||||
assert isinstance(reading["sessions"], list)
|
||||
|
||||
|
||||
class TestWhatAnotherPlatformAdds:
|
||||
"""A key a Windows host fills (NetOrk/netork#2895), optional, so the Linux reading and
|
||||
every driver that builds one stay as they are."""
|
||||
|
||||
def test_the_keys_linux_fills_stay_required(self):
|
||||
from napalm_device_types.login_sessions import LoginSessionDict, LoginSessionsDict
|
||||
|
||||
assert LoginSessionsDict.__required_keys__ == frozenset({"own_address", "sessions"})
|
||||
assert LoginSessionsDict.__optional_keys__ == frozenset({"records_since"})
|
||||
assert LoginSessionDict.__optional_keys__ == frozenset()
|
||||
|
||||
def test_the_linux_reading_does_not_set_it(self):
|
||||
assert "records_since" not in parse_login_sessions(_wire(DEBIAN_12))
|
||||
Reference in new issue
Block a user