예제 #1
0
    def test_web_agent_error(self):
        reactor = Mock()
        cfg = Mock()

        tor = Tor(reactor, cfg)
        with self.assertRaises(ValueError) as ctx:
            agent = tor.web_agent(pool=self.pool, _socks_endpoint=object())
            yield agent.request('GET', b'meejah.ca')
        self.assertTrue("'_socks_endpoint' should be" in str(ctx.exception))
예제 #2
0
    def test_web_agent_deferred(self):
        socks_d = defer.succeed("9151")
        reactor = Mock()
        cfg = Mock()

        tor = Tor(reactor, cfg)
        agent = tor.web_agent(pool=self.pool, _socks_endpoint=socks_d)

        resp = yield agent.request('GET', b'meejah.ca')
        self.assertEqual(self.expected_response, resp)
예제 #3
0
    def test_web_agent_endpoint(self):
        socks = Mock()
        directlyProvides(socks, IStreamClientEndpoint)
        reactor = Mock()
        cfg = Mock()

        tor = Tor(reactor, cfg)
        agent = tor.web_agent(pool=self.pool, _socks_endpoint=socks)

        resp = yield agent.request('GET', b'meejah.ca')
        self.assertEqual(self.expected_response, resp)
예제 #4
0
    def test_web_agent_defaults(self):
        reactor = Mock()
        cfg = Mock()
        cfg.create_socks_endpoint = Mock(return_value=defer.succeed("9050"))

        tor = Tor(reactor, cfg)
        try:
            agent = tor.web_agent(pool=self.pool)
        except ImportError as e:
            if 'IAgentEndpointFactory' in str(e):
                print("Skipping; appears we don't have web support")
                return

        resp = yield agent.request('GET', b'meejah.ca')
        self.assertEqual(self.expected_response, resp)