Merge feature/host-logins (4.51.0, on main's 4.50.0) into feature/live-kernel-patches
driver / standard (pull_request) Failing after 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m22s
driver / lowest (pull_request) Successful in 41s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Failing after 58s
CI / driver (pull_request) Failing after 2m52s
driver / publish (pull_request) Skipped

The live patches are 4.52.0 now.
This commit is contained in:
christianmanivong committed 2026-11-28 08:23:05 +01:00
commit 780e4247a1
7 files changed
+165 -4

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
"""Where a device checks a login, and what each place asks for (NetOrk/netork#662).
The module is a contract, not a reader: the shapes a driver returns from
``get_web_login_auth`` and, where its platform says it, in ``get_ssh_server_auth``.
These tests pin the vocabulary consumers match on.
"""
from __future__ import annotations
from typing import get_args, get_type_hints
import napalm_device_types
from napalm_device_types.login_sources import (
LOGIN_FACTORS,
LoginFactors,
LoginSourceDict,
WebLoginAuthDict,
)
from napalm_device_types.ssh_server_auth import SshServerAuthDict
def test_the_factor_names_are_the_literal_s():
assert LOGIN_FACTORS == get_args(LoginFactors)
assert LOGIN_FACTORS == ("password", "password_otp", "external", "unknown")
def test_a_source_names_itself_its_kind_and_what_it_asks_for():
assert set(get_type_hints(LoginSourceDict)) == {"name", "kind", "factors"}
def test_a_web_reading_is_its_sources_in_the_device_s_order():
assert set(get_type_hints(WebLoginAuthDict)) == {"sources"}
def test_an_ssh_reading_may_say_where_a_password_is_checked_and_that_sshd_is_off():
optional = SshServerAuthDict.__optional_keys__
assert {"password_sources", "server_enabled"} <= optional
# The keys every OpenSSH reading carries stay required.
assert "password_authentication" in SshServerAuthDict.__required_keys__
def test_the_package_exports_the_shapes():
for name in ("LOGIN_FACTORS", "LoginFactors", "LoginSourceDict", "WebLoginAuthDict"):
assert name in napalm_device_types.__all__
assert hasattr(napalm_device_types, name)