mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 19:12:03 +03:00
Merge 863e7366bb into 8c99ac78b7
This commit is contained in:
commit
fafcb1b271
1 changed files with 25 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from netsleuth.iface import (
|
from netsleuth.iface import (
|
||||||
|
_match_iface_name,
|
||||||
available_interfaces_hint,
|
available_interfaces_hint,
|
||||||
resolve_bind_target,
|
resolve_bind_target,
|
||||||
usable_addresses,
|
usable_addresses,
|
||||||
|
|
@ -17,6 +18,30 @@ def up(**kw) -> dict[str, bool]:
|
||||||
return kw
|
return kw
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_exact():
|
||||||
|
assert _match_iface_name("eth0", ["eth0", "eth1"]) == "eth0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_case_insensitive_exact():
|
||||||
|
assert _match_iface_name("ETH0", ["eth0", "eth1"]) == "eth0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_case_insensitive_exact_multiple():
|
||||||
|
assert _match_iface_name("EtH0", ["eth0", "ETH0"]) == ["eth0", "ETH0"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_substring():
|
||||||
|
assert _match_iface_name("eth", ["my-eth0-iface", "wlan0"]) == "my-eth0-iface"
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_substring_multiple():
|
||||||
|
assert _match_iface_name("eth", ["eth0", "eth1"]) == ["eth0", "eth1"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_iface_name_no_match():
|
||||||
|
assert _match_iface_name("eth", ["wlan0", "lo"]) == []
|
||||||
|
|
||||||
|
|
||||||
def test_usable_addresses_picks_first_non_loopback_v4_and_v6():
|
def test_usable_addresses_picks_first_non_loopback_v4_and_v6():
|
||||||
v4, v6 = usable_addresses(
|
v4, v6 = usable_addresses(
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue