Files
napalm-opnsense/tests/unit/test_ssh_settings.py
T
Christian Manivong b50732c63c
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 18s
driver / types (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / test (3.12) (pull_request) Successful in 1m15s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 37s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m37s
driver / publish (pull_request) Skipped
feat(ssh): say where the SSH algorithm lists are set
OPNsense writes sshd_config from config.xml (<system><ssh>), set on the
legacy Administration page; no API controller reads or writes that
section (26.1, 26.7, master). The driver cannot harden the SSH server,
so it declares, as data, the page and the field of each algorithm list:
SSH_SETTINGS_MENU and SSH_SETTINGS_FIELDS, keyed like device-types'
SSH_ALGORITHM_CLASSES. An application tells a person what to set there.

The CARP master check moves to virtual_ips, next to the CARP reader, so
opnsense.py stays under its line ratchet.

Refs NetOrk/netork#1769
2026-11-07 16:39:12 +01:00

37 lines
1.1 KiB
Python

"""Where the SSH server's algorithm lists are set (NetOrk/netork#1769).
OPNsense writes sshd_config from config.xml (``<system><ssh>``), and no API
controller reads or writes that section: the lists are set on the legacy
Administration page. The driver therefore does not harden the SSH server; it
says, as data, where a person sets the lists by hand.
"""
from __future__ import annotations
from napalm_device_types.ssh_server import SSH_ALGORITHM_CLASSES
from napalm_opnsense import OPNsenseDriver
def test_the_page_that_sets_the_lists():
assert OPNsenseDriver.SSH_SETTINGS_MENU == (
"System",
"Settings",
"Administration",
"Secure Shell",
)
def test_a_field_for_every_algorithm_class():
assert OPNsenseDriver.SSH_SETTINGS_FIELDS == {
"kex": "Key exchange algorithms",
"cipher": "Ciphers",
"mac": "MACs",
"hostkey": "Host key algorithms",
}
assert set(OPNsenseDriver.SSH_SETTINGS_FIELDS) == set(SSH_ALGORITHM_CLASSES)
def test_the_driver_does_not_harden_the_ssh_server_itself():
assert not callable(getattr(OPNsenseDriver, "harden_ssh_server", None))