def Address_tests(): print "+-----------------------------+" print "| Address Tests |" print "+-----------------------------+" # There should be a valid subnet for each valid ip. They should share the same index. If you add more then make sure you add a subnet that works with the ip AT THE SAME INDEX AS EACHOTHER. valid_ip = ["255.255.255.255", "1.1.1.1", "30.25.255.10", "0.0.0.0"] valid_subnets = [ "255.255.255.0/24", "1.1.1.0/31", "30.25.255.0/28", "0.0.0.0/32" ] invalid_ip = ["0.0.0.256", "-1.1.1.1", "1.1.1.1.1", "1000.80.10.2"] invalid_subnets = [] for idx in range(len(valid_ip)): assert (Address.isValidIPv4(valid_ip[idx])) print "[+] Successfully validated IP '{}'".format(valid_ip[idx]) assert (Address.isValidSubnet(valid_subnets[idx])) print "[+] Successfully validated subnet '{}'".format( valid_subnets[idx]) assert (Address.isMemberOfSubnet(valid_ip[idx], valid_subnets[idx])) print "[+] Successfully verified that '{0}' is a member of '{1}'".format( valid_ip[idx], valid_subnets[idx]) for ip in invalid_ip: assert (not Address.isValidIPv4(ip)) print "[+] Successfully caught invalid IP '{}'".format(ip) print "Address Tests Succeeded!"