Ejemplo n.º 1
0
    def test_safe_ip_address_negative(self, mock_logging):
        for value in self.INVALID_IP_ADDRESS_STR_LIST:
            self.assertIsNone(utils.safe_ip_address(value), value)

        addr_list = self.GOOD_IP_V4_ADDRESS_STR_LIST
        mask_list = self.GOOD_IP_V4_MASK_STR_LIST
        for addr_mask_pair in product(addr_list, mask_list):
            value = ''.join(addr_mask_pair)
            self.assertIsNone(utils.safe_ip_address(value), value)

        addr_list = self.GOOD_IP_V6_ADDRESS_STR_LIST
        mask_list = self.GOOD_IP_V6_MASK_STR_LIST
        for addr_mask_pair in product(addr_list, mask_list):
            value = ''.join(addr_mask_pair)
            self.assertIsNone(utils.safe_ip_address(value), value)
Ejemplo n.º 2
0
    def test_safe_ip_address_negative(self, *args):
        # NOTE(ralonsoh): check the calls to mocked functions.
        for value in self.INVALID_IP_ADDRESS_STR_LIST:
            self.assertIsNone(utils.safe_ip_address(value), value)

        addr_list = self.GOOD_IP_V4_ADDRESS_STR_LIST
        mask_list = self.GOOD_IP_V4_MASK_STR_LIST
        for addr_mask_pair in product(addr_list, mask_list):
            value = ''.join(addr_mask_pair)
            self.assertIsNone(utils.safe_ip_address(value), value)

        addr_list = self.GOOD_IP_V6_ADDRESS_STR_LIST
        mask_list = self.GOOD_IP_V6_MASK_STR_LIST
        for addr_mask_pair in product(addr_list, mask_list):
            value = ''.join(addr_mask_pair)
            self.assertIsNone(utils.safe_ip_address(value), value)
Ejemplo n.º 3
0
 def test_safe_ip_address_v6_ip(self):
     addr_list = self.GOOD_IP_V6_ADDRESS_STR_LIST
     for addr in addr_list:
         # test with no mask
         expected = ipaddress.ip_address(addr)
         self.assertEqual(utils.safe_ip_address(addr), expected, addr)