Ejemplo n.º 1
0
    def test_isIPv6_randomIP6(self):
        """Test :func:`addr.isIPv6` with a random IPv6 address.

        This test asserts that the returned IP address is a :obj:`bool`
        (because the IP being tested is random, it *could* randomly be an
        invalid IP address and thus :func:`~bridgdb.addr.isIPv6` would return
        ``False``).
        """
        randomAddr = ipaddr.IPv6Address(random.getrandbits(128)).compressed
        log.msg("Testing randomly generated IPv6 address: %s" % randomAddr)
        result = addr.isIPv6(randomAddr)
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
Ejemplo n.º 2
0
    def test_isIPv6_randomIP6(self):
        """Test :func:`addr.isIPv6` with a random IPv6 address.

        This test asserts that the returned IP address is a :obj:`bool`
        (because the IP being tested is random, it *could* randomly be an
        invalid IP address and thus :func:`~bridgdb.addr.isIPv6` would return
        ``False``).
        """
        randomAddr = ipaddr.IPv6Address(random.getrandbits(128)).compressed
        log.msg("Testing randomly generated IPv6 address: %s" % randomAddr)
        result = addr.isIPv6(randomAddr)
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
Ejemplo n.º 3
0
    def runTestForIPv4(self, testAddress):
        """Test :func:`addr.isIPv6` with the specified IPv4 **testAddress**.

        This test asserts that the returned value is ``False``.

        :param str testAddress: A string which specifies the IPv4 address to
           test, which should cause :func:`addr.isIPv6` to return ``False``.
        """
        result = addr.isIPv6(testAddress)
        log.msg("addr.isIPv6(%r) => %s" % (testAddress, result))
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
        self.assertFalse(result,
                        "addr.isIPv6(%r) should be False!" % testAddress)
Ejemplo n.º 4
0
    def runTestForIPv4(self, testAddress):
        """Test :func:`addr.isIPv6` with the specified IPv4 **testAddress**.

        This test asserts that the returned value is ``False``.

        :param str testAddress: A string which specifies the IPv4 address to
           test, which should cause :func:`addr.isIPv6` to return ``False``.
        """
        result = addr.isIPv6(testAddress)
        log.msg("addr.isIPv6(%r) => %s" % (testAddress, result))
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
        self.assertFalse(result,
                         "addr.isIPv6(%r) should be False!" % testAddress)
Ejemplo n.º 5
0
    def runTestForIPv6(self, testAddress):
        """Test :func:`addr.isIPv6` with the specified IPv6 **testAddress**.

        This test asserts that the returned value is ``True``.

        Random addresses should *not* be tested with this function, because
        :func:`~addr.isIPv6` uses :func:`~addr.isValidIP` internally, and will
        return False if the IP is invalid.

        :param str testAddress: A string which specifies the IPv6 address to
            test, which should cause :func:`addr.isIPv6` to return ``True``.
        """
        result = addr.isIPv6(testAddress)
        log.msg("addr.isIPv6(%r) => %s" % (testAddress, result))
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
        self.assertTrue(result,
                        "addr.isIPv6(%r) should be True!" % testAddress)
Ejemplo n.º 6
0
    def runTestForIPv6(self, testAddress):
        """Test :func:`addr.isIPv6` with the specified IPv6 **testAddress**.

        This test asserts that the returned value is ``True``.

        Random addresses should *not* be tested with this function, because
        :func:`~addr.isIPv6` uses :func:`~addr.isValidIP` internally, and will
        return False if the IP is invalid.

        :param str testAddress: A string which specifies the IPv6 address to
            test, which should cause :func:`addr.isIPv6` to return ``True``.
        """
        result = addr.isIPv6(testAddress)
        log.msg("addr.isIPv6(%r) => %s" % (testAddress, result))
        self.assertTrue(isinstance(result, bool),
                        "addr.isIPv6() should be boolean: %r" % type(result))
        self.assertTrue(result,
                        "addr.isIPv6(%r) should be True!" % testAddress)
Ejemplo n.º 7
0
 def doubleCheck(self, match):
     """Additional check to ensure that **match** is an IPv6 address."""
     if addr.isIPv6(match):
         return True
Ejemplo n.º 8
0
 def doubleCheck(self, match):
     """Additional check to ensure that **match** is an IPv6 address."""
     if addr.isIPv6(match):
         return True