예제 #1
0
 def test_policy_hostaddr_ipv6_wildcard(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     aaa = HostAddr("*")
     self.check_hostaddr_match(aaa,"::0")
     self.check_hostaddr_match(aaa,"::1")
     self.check_hostaddr_match(aaa,"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
예제 #2
0
    def test_simple_pre_settled(self):

        if not is_ipv6_enabled():
            return self.skipTest("Skipping test..IPV6 not enabled")

        addr = self.routers[0].addresses[4] + "/test/1"
        M1 = self.messenger()
        M2 = self.messenger()

        M1.start()
        M2.start()
        M2.subscribe(addr)

        tm = Message()
        rm = Message()

        tm.address = addr
        for i in range(100):
            tm.body = {'number': i}
            M1.put(tm)
        M1.send()

        for i in range(100):
            M2.recv(1)
            M2.get(rm)
            self.assertEqual(i, rm.body['number'])

        M1.stop()
        M2.stop()
예제 #3
0
 def test_policy_hostaddr_ipv6_wildcard(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     aaa = HostAddr("*")
     self.check_hostaddr_match(aaa,"::0")
     self.check_hostaddr_match(aaa,"::1")
     self.check_hostaddr_match(aaa,"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
예제 #4
0
    def setUpClass(cls):
        """Start the router"""
        super(LoadPolicyFromFolder, cls).setUpClass()

        ipv6_enabled = is_ipv6_enabled()

        policy_config_path = os.path.join(DIR, 'policy-1')
        replacements = {'{IPV6_LOOPBACK}': ', ::1'}
        for f in os.listdir(policy_config_path):
            if f.endswith(".json.in"):
                with open(policy_config_path + "/" + f[:-3], 'w') as outfile:
                    with open(policy_config_path + "/" + f) as infile:
                        for line in infile:
                            for src, target in replacements.iteritems():
                                if ipv6_enabled:
                                    line = line.replace(src, target)
                                else:
                                    line = line.replace(src, '')
                            outfile.write(line)

        config = Qdrouterd.Config([('router', {
            'mode': 'standalone',
            'id': 'QDR.Policy'
        }), ('listener', {
            'port': cls.tester.get_port()
        }),
                                   ('policy', {
                                       'maxConnections': 2,
                                       'policyDir': policy_config_path,
                                       'enableVhostPolicy': 'true'
                                   })])

        cls.router = cls.tester.qdrouterd('conn-limit-router',
                                          config,
                                          wait=True)
    def test_simple_send_receive(self):

        if not is_ipv6_enabled():
            return self.skipTest("Skipping test..IPV6 not enabled")

        simple_send_receive_test = SimpleSndRecv(self.routers[0].addresses[4])
        simple_send_receive_test.run()
        self.assertTrue(simple_send_receive_test.message_received)
예제 #6
0
    def test_simple_send_receive(self):

        if not is_ipv6_enabled():
            return self.skipTest("Skipping test..IPV6 not enabled")

        simple_send_receive_test = SimpleSndRecv(self.routers[0].addresses[4])
        simple_send_receive_test.run()
        self.assertTrue(simple_send_receive_test.message_received)
예제 #7
0
 def test_policy_hostaddr_ipv6(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     # Create simple host and range
     aaa = HostAddr("::1")
     bbb = HostAddr("::1,::ffff")
     ccc = HostAddr("ffff::0,ffff:ffff::0")
     # Verify host and range
     self.check_hostaddr_match(aaa, "::1")
     self.check_hostaddr_match(aaa, "::2", False)
     self.check_hostaddr_match(aaa, "ffff:ffff::0", False)
     self.check_hostaddr_match(bbb, "::1")
     self.check_hostaddr_match(bbb, "::fffe")
     self.check_hostaddr_match(bbb, "::1:0", False)
     self.check_hostaddr_match(bbb, "ffff::0", False)
     self.check_hostaddr_match(ccc, "ffff::1")
     self.check_hostaddr_match(ccc, "ffff:fffe:ffff:ffff::ffff")
     self.check_hostaddr_match(ccc, "ffff:ffff::1", False)
     self.check_hostaddr_match(ccc, "ffff:ffff:ffff:ffff::ffff", False)
예제 #8
0
 def test_policy_hostaddr_ipv6(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     # Create simple host and range
     aaa = HostAddr("::1")
     bbb = HostAddr("::1,::ffff")
     ccc = HostAddr("ffff::0,ffff:ffff::0")
     # Verify host and range
     self.check_hostaddr_match(aaa, "::1")
     self.check_hostaddr_match(aaa, "::2", False)
     self.check_hostaddr_match(aaa, "ffff:ffff::0", False)
     self.check_hostaddr_match(bbb, "::1")
     self.check_hostaddr_match(bbb, "::fffe")
     self.check_hostaddr_match(bbb, "::1:0", False)
     self.check_hostaddr_match(bbb, "ffff::0", False)
     self.check_hostaddr_match(ccc, "ffff::1")
     self.check_hostaddr_match(ccc, "ffff:fffe:ffff:ffff::ffff")
     self.check_hostaddr_match(ccc, "ffff:ffff::1", False)
     self.check_hostaddr_match(ccc, "ffff:ffff:ffff:ffff::ffff", False)
예제 #9
0
    def setUpClass(cls):
        """
        Starts three routers with various listeners and connectors.
        There is a call to wait_router_connected to make sure that the routers are able to communicate with each
        other on ports using the assigned protocol family.
        """
        super(ProtocolFamilyTest, cls).setUpClass()

        def router(name, connection):

            config = [
                ('router', {
                    'mode': 'interior',
                    'id': 'QDR.%s' % name
                }),

                # No protocolFamily is specified for this listener.
                # This will test if the router defaults host to 127.0.0.1 and if the router auto-detects protocol family
                ('listener', {
                    'port': cls.tester.get_port()
                }),

                # Specify host as 127.0.0.1 and protocol family as IPv4
                ('listener', {
                    'host': '127.0.0.1',
                    'protocolFamily': 'IPv4',
                    'port': cls.tester.get_port()
                }),

                # Specify protocol family as IPv4 but don't specify any host
                # This will test if the router defaults the host field to 127.0.0.1
                ('listener', {
                    'protocolFamily': 'IPv4',
                    'port': cls.tester.get_port()
                }),

                # Specify the host as 127.0.0.1
                # This will test router's auto-detection of protocol family
                ('listener', {
                    'host': '127.0.0.1',
                    'port': cls.tester.get_port()
                }),

                # Specify host as ::1 and protocol family as IPv6
                ('listener', {
                    'host': '::1',
                    'protocolFamily': 'IPv6',
                    'port': cls.tester.get_port(protocol_family='IPv6')
                }),
            ] + connection

            config = Qdrouterd.Config(config)

            # The wait=True attempts to connect to each listening port with the appropriate protocol family
            # and tests each connector
            cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))

        if not is_ipv6_enabled():
            return

        cls.routers = []

        inter_router_port = cls.tester.get_port(protocol_family='IPv6')
        inter_router_ipv4_port = cls.tester.get_port(protocol_family='IPv4')

        router('A', [('listener', {
            'host': '::1',
            'role': 'inter-router',
            'protocolFamily': 'IPv6',
            'port': inter_router_port
        })])

        router(
            'B',
            [
                # Tests an IPv6 connector
                ('connector', {
                    'host': '::1',
                    'role': 'inter-router',
                    'protocolFamily': 'IPv6',
                    'port': inter_router_port
                }),
                ('listener', {
                    'host': '127.0.0.1',
                    'role': 'inter-router',
                    'port': inter_router_ipv4_port
                })
            ])

        router(
            'C',
            [
                # Tests an IPv4 connector
                ('connector', {
                    'host': '127.0.0.1',
                    'role': 'inter-router',
                    'port': inter_router_ipv4_port
                })
            ])
        cls.routers[0].wait_router_connected('QDR.B')
        cls.routers[1].wait_router_connected('QDR.A')
        cls.routers[2].wait_router_connected('QDR.B')
예제 #10
0
 def test_policy_malformed_hostaddr_ipv6(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     self.expect_deny("1::2::3", "Name or service not known")
     self.expect_deny("::1,::2,::3", "arg count")
     self.expect_deny("0:ff:0,0:fe:ffff:ffff::0", "a > b")
    def setUpClass(cls):

        """
        Starts three routers with various listeners and connectors.
        There is a call to wait_router_connected to make sure that the routers are able to communicate with each
        other on ports using the assigned protocol family.
        """
        super(ProtocolFamilyTest, cls).setUpClass()

        def router(name, connection):

            config = [
                ('router', {'mode': 'interior', 'id': 'QDR.%s'%name}),

                # No protocolFamily is specified for this listener.
                # This will test if the router defaults host to 127.0.0.1 and if the router auto-detects protocol family

                ('listener', {'port': cls.tester.get_port()}),

                # Specify host as 127.0.0.1 and protocol family as IPv4
                ('listener', {'host': '127.0.0.1', 'protocolFamily': 'IPv4','port': cls.tester.get_port()}),

                # Specify protocol family as IPv4 but don't specify any host
                # This will test if the router defaults the host field to 127.0.0.1
                ('listener', {'protocolFamily': 'IPv4', 'port': cls.tester.get_port()}),

                # Specify the host as 127.0.0.1
                # This will test router's auto-detection of protocol family
                ('listener', {'host': '127.0.0.1', 'port': cls.tester.get_port()}),


                # Specify host as ::1 and protocol family as IPv6
                ('listener', {'host': '::1', 'protocolFamily': 'IPv6', 'port': cls.tester.get_port(protocol_family='IPv6')}),

            ] + connection

            config = Qdrouterd.Config(config)

            # The wait=True attempts to connect to each listening port with the appropriate protocol family
            # and tests each connector
            cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))

        if not is_ipv6_enabled():
            return

        cls.routers = []

        inter_router_port = cls.tester.get_port(protocol_family='IPv6')
        inter_router_ipv4_port = cls.tester.get_port(protocol_family='IPv4')

        router('A',
               [
                   ('listener', {'host': '::1', 'role': 'inter-router', 'protocolFamily': 'IPv6', 'port': inter_router_port})
               ]
        )

        router('B',
               [
                   # Tests an IPv6 connector
                   ('connector', {'host': '::1', 'role': 'inter-router', 'protocolFamily': 'IPv6', 'port': inter_router_port}),
                   ('listener', {'host': '127.0.0.1', 'role': 'inter-router', 'port': inter_router_ipv4_port})
                ]

        )

        router('C',
               [
                   # Tests an IPv4 connector
                   ('connector', {'host': '127.0.0.1', 'role': 'inter-router', 'port': inter_router_ipv4_port})
               ]
        )
        cls.routers[0].wait_router_connected('QDR.B')
        cls.routers[1].wait_router_connected('QDR.A')
        cls.routers[2].wait_router_connected('QDR.B')
예제 #12
0
 def test_policy_malformed_hostaddr_ipv6(self):
     if not is_ipv6_enabled():
         self.skipTest("System IPv6 support is not available")
     self.expect_deny( "1::2::3", "Name or service not known")
     self.expect_deny( "::1,::2,::3", "arg count")
     self.expect_deny( "0:ff:0,0:fe:ffff:ffff::0", "a > b")