"""AMT's own network ports (AMT_EthernetPortSettings), from the recorded NUC9.""" from napalm_amt.parsers import parse_ethernet_ports from ..conftest import instances def test_the_wired_port_is_kept_and_the_unused_wireless_one_dropped(): # The NUC9 lists a wireless port without a MAC address: there is no WLAN card. ports = parse_ethernet_ports(instances("AMT_EthernetPortSettings.pull.xml")) assert ports == [ { "name": "wired", "mac_address": "00:be:43:d8:22:a4", "link_up": True, "dhcp": True, "shared_ip": True, "ip": "", "prefix_length": None, } ] def test_a_static_address_with_its_mask(): (port,) = parse_ethernet_ports( [ { "InstanceID": "Intel(r) AMT Ethernet Port Settings 0", "MACAddress": "6C-4B-90-12-34-56", "LinkIsUp": "true", "DHCPEnabled": "false", "SharedStaticIp": "false", "IPAddress": "172.22.8.61", "SubnetMask": "255.255.255.0", "PhysicalConnectionType": "0", } ] ) assert port["mac_address"] == "6c:4b:90:12:34:56" assert (port["ip"], port["prefix_length"]) == ("172.22.8.61", 24) assert port["dhcp"] is False assert port["shared_ip"] is False def test_a_wireless_port_with_a_card_is_named_wireless(): ports = parse_ethernet_ports( [ { "InstanceID": "Intel(r) AMT Ethernet Port Settings 1", "MACAddress": "a0-88-69-01-02-03", "PhysicalConnectionType": "3", "LinkIsUp": "false", }, ] ) assert [(p["name"], p["link_up"]) for p in ports] == [("wireless", False)] def test_an_invalid_mask_gives_no_prefix(): (port,) = parse_ethernet_ports( [{"MACAddress": "00-be-43-d8-22-a4", "IPAddress": "10.0.0.5", "SubnetMask": "255.0.255.0"}] ) assert port["prefix_length"] is None