def test_physdev(self): myset = WiSet(name=self.name, attr_type="hash:net,iface") myset.create() myset.add("192.168.0.0/24,eth0", physdev=False) myset.add("192.168.1.0/24,eth0", physdev=True) content = myset.content myset.destroy() assert content["192.168.0.0/24,eth0"].physdev is False assert content["192.168.1.0/24,eth0"].physdev is True
def test_wildcard_entries(self): require_kernel(5, 5) myset = WiSet(name=self.name, attr_type="hash:net,iface") myset.create() myset.add("192.168.0.0/24,eth", wildcard=True) myset.add("192.168.1.0/24,wlan0", wildcard=False) content = myset.content myset.destroy() assert content["192.168.0.0/24,eth"].wildcard is True assert content["192.168.1.0/24,wlan0"].wildcard is False
def test_add_ipstats(self, sock=None): data = IPStats(packets=10, bytes=1000, comment="hello world", skbmark="0x10/0x10", timeout=None) myset = WiSet(name=self.name, attr_type="hash:net", comment=True, skbinfo=True, counters=True, sock=sock) myset.create() myset.add("198.51.100.0/24", **data._asdict()) assert "198.51.100.0/24" in myset.content assert data == myset.content["198.51.100.0/24"] myset.destroy()
def test_hashnet_with_comment(self, sock=None): comment = "abcdef" myset = WiSet(name=self.name, attr_type="hash:net", comment=True, sock=sock) myset.create() inherit_sock = sock is not None myset = load_ipset(self.name, sock=sock, inherit_sock=inherit_sock) assert myset.comment myset.add("192.168.1.1", comment=comment) myset.update_content() assert myset.content["192.168.1.1/32"].comment == comment myset.destroy()