예제 #1
0
파일: test_ice.py 프로젝트: jlaine/aioice
    async def test_add_remote_candidate_mdns_good(self):
        """
        Add an mDNS candidate which can be resolved.
        """
        hostname = mdns.create_mdns_hostname()
        publisher = await mdns.create_mdns_protocol()
        await publisher.publish(hostname, "1.2.3.4")

        conn_a = ice.Connection(ice_controlling=True)

        await conn_a.add_remote_candidate(
            Candidate(
                foundation="some-foundation",
                component=1,
                transport="udp",
                priority=1234,
                host=hostname,
                port=1234,
                type="host",
            ))
        self.assertEqual(len(conn_a.remote_candidates), 1)
        self.assertEqual(conn_a.remote_candidates[0].host, "1.2.3.4")
        self.assertEqual(conn_a._remote_candidates_end, False)

        # close
        await conn_a.close()
        await publisher.close()
예제 #2
0
    def test_resolve_simultaneous_bad(self):
        hostname = mdns.create_mdns_hostname()

        results = run(
            asyncio.gather(self.querier.resolve(hostname),
                           self.querier.resolve(hostname)))
        self.assertEqual(results, [None, None])
예제 #3
0
    def test_resolve_good_ipv6(self):
        hostaddr = "::ffff:1.2.3.4"
        hostname = mdns.create_mdns_hostname()
        run(self.responder.publish(hostname, hostaddr))

        result = run(self.querier.resolve(hostname))
        self.assertEqual(result, hostaddr)
예제 #4
0
    def test_resolve_simultaneous_good(self):
        hostaddr = "1.2.3.4"
        hostname = mdns.create_mdns_hostname()
        run(self.responder.publish(hostname, hostaddr))

        results = run(
            asyncio.gather(self.querier.resolve(hostname),
                           self.querier.resolve(hostname)))
        self.assertEqual(results, [hostaddr, hostaddr])
예제 #5
0
    def test_add_remote_candidate_mdns_bad(self):
        """
        Add an mDNS candidate which cannot be resolved.
        """
        conn_a = ice.Connection(ice_controlling=True)

        run(
            conn_a.add_remote_candidate(
                Candidate(
                    foundation="some-foundation",
                    component=1,
                    transport="udp",
                    priority=1234,
                    host=mdns.create_mdns_hostname(),
                    port=1234,
                    type="host",
                )))
        self.assertEqual(len(conn_a.remote_candidates), 0)
        self.assertEqual(conn_a._remote_candidates_end, False)
예제 #6
0
    def test_resolve_bad(self):
        hostname = mdns.create_mdns_hostname()

        result = run(self.querier.resolve(hostname))
        self.assertEqual(result, None)