Merge NAPALM/napalm-device-types main (4.50.0) into feature/host-logins
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 21s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m26s
driver / lowest (pull_request) Successful in 47s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Failing after 1m5s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 17s
driver / standard (pull_request) Successful in 21s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m19s
driver / test (3.12) (pull_request) Successful in 1m26s
driver / lowest (pull_request) Successful in 47s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Failing after 1m5s
CI / driver (pull_request) Failing after 2m45s
driver / publish (pull_request) Skipped
v4.50.0 went to #140, so this branch's release is 4.51.0 now.
This commit is contained in:
commit
4b4797e383
7 files changed
+164
-3
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user