def run_test(self):
    if (not sys.platform.startswith('linux')):
        raise SkipTest('This test can only be run on linux.')
    non_loopback_ip = None
    for (name, ip) in all_interfaces():
        if (ip != '127.0.0.1'):
            non_loopback_ip = ip
            break
    if (non_loopback_ip is None):
        raise SkipTest('This test requires at least one non-loopback IPv4 interface.')
    try:
        s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
        s.connect(('::1', 1))
        s.close
    except OSError:
        raise SkipTest('This test requires IPv6 support.')
    self.log.info(('Using interface %s for testing' % non_loopback_ip))
    defaultport = rpc_port(0)
    self.run_bind_test(None, '127.0.0.1', [], [('127.0.0.1', defaultport), ('::1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', [], [('::0', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', ['127.0.0.1'], [('127.0.0.1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1:32171', ['127.0.0.1:32171'], [('127.0.0.1', 32171)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1:32171', ['127.0.0.1:32171', '127.0.0.1:32172'], [('127.0.0.1', 32171), ('127.0.0.1', 32172)])
    self.run_bind_test(['[::1]'], '[::1]', ['[::1]'], [('::1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', ['127.0.0.1', '[::1]'], [('127.0.0.1', defaultport), ('::1', defaultport)])
    self.run_bind_test([non_loopback_ip], non_loopback_ip, [non_loopback_ip], [(non_loopback_ip, defaultport)])
    self.run_allowip_test([non_loopback_ip], non_loopback_ip, defaultport)
    assert_raises_rpc_error((- 342), "non-JSON HTTP response with '403 Forbidden' from server", self.run_allowip_test, ['1.1.1.1'], non_loopback_ip, defaultport)
def run_test(self):
    if (not sys.platform.startswith('linux')):
        raise SkipTest('This test can only be run on linux.')
    non_loopback_ip = None
    for (name, ip) in all_interfaces():
        if (ip != '127.0.0.1'):
            non_loopback_ip = ip
            break
    if (non_loopback_ip is None):
        raise SkipTest('This test requires at least one non-loopback IPv4 interface.')
    try:
        s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
        s.connect(('::1', 1))
        s.close
    except OSError:
        raise SkipTest('This test requires IPv6 support.')
    self.log.info(('Using interface %s for testing' % non_loopback_ip))
    defaultport = rpc_port(0)
    self.run_bind_test(None, '127.0.0.1', [], [('127.0.0.1', defaultport), ('::1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', [], [('::0', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', ['127.0.0.1'], [('127.0.0.1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1:32171', ['127.0.0.1:32171'], [('127.0.0.1', 32171)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1:32171', ['127.0.0.1:32171', '127.0.0.1:32172'], [('127.0.0.1', 32171), ('127.0.0.1', 32172)])
    self.run_bind_test(['[::1]'], '[::1]', ['[::1]'], [('::1', defaultport)])
    self.run_bind_test(['127.0.0.1'], '127.0.0.1', ['127.0.0.1', '[::1]'], [('127.0.0.1', defaultport), ('::1', defaultport)])
    self.run_bind_test([non_loopback_ip], non_loopback_ip, [non_loopback_ip], [(non_loopback_ip, defaultport)])
    self.run_allowip_test([non_loopback_ip], non_loopback_ip, defaultport)
    assert_raises_rpc_error((- 342), "non-JSON HTTP response with '403 Forbidden' from server", self.run_allowip_test, ['1.1.1.1'], non_loopback_ip, defaultport)