mirror of https://github.com/scrapy/scrapy.git
Add test case for tunneling proxy
This commit is contained in:
parent
c1a108b447
commit
484a0159d0
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from threading import Thread
|
||||
|
|
@ -9,13 +9,11 @@ from netlib import http_auth
|
|||
from twisted.internet import defer
|
||||
from twisted.trial.unittest import TestCase
|
||||
from scrapy.utils.test import get_testlog, docrawl
|
||||
from tests.spiders import SimpleSpider
|
||||
from scrapy.http import Request
|
||||
from tests.spiders import SimpleSpider, SingleRequestSpider
|
||||
from tests.mockserver import MockServer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class HTTPSProxy(controller.Master, Thread):
|
||||
|
||||
def __init__(self, port):
|
||||
|
|
@ -79,6 +77,15 @@ class ProxyConnectTestCase(TestCase):
|
|||
self._assert_got_tunnel_error()
|
||||
os.environ['https_proxy'] = 'http://scrapy:scrapy@localhost:8888'
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_https_tunnel_without_leak_proxy_authorization_header(self):
|
||||
request = Request("https://localhost:8999/echo")
|
||||
spider = SingleRequestSpider(seed=request)
|
||||
yield docrawl(spider)
|
||||
self._assert_got_response_code(200)
|
||||
echo = json.loads(spider.meta['responses'][0].body)
|
||||
self.assertTrue('Proxy-Authorization' not in echo['headers'])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_https_noconnect_auth_error(self):
|
||||
os.environ['https_proxy'] = 'http://wrong:wronger@localhost:8888?noconnect'
|
||||
|
|
|
|||
Loading…
Reference in New Issue