aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/tests/ip_in_subnet.py
blob: 0b5a4a671497dd432ec9539f6c15b37ab1068c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import ipaddress

def test_ip_in_subnet(ip, cidr):
  return ipaddress.ip_address(ip) in ipaddress.ip_network(cidr)

def test_subnet_contains_ip(cidr, ip):
  return ipaddress.ip_address(ip) in ipaddress.ip_network(cidr)

class TestModule(object):
  test_map = {
    'in_subnet': test_ip_in_subnet,
    'contains_ip': test_subnet_contains_ip,
  }

  def tests(self):
    return self.test_map