Skip to content
Browse files

Add test case for tunneling proxy

  • Loading branch information
ivannotes authored and dangra committed Aug 8, 2014
1 parent d8793af commit f090260d1004b022112ef99dc5cf855d668e3df1
Showing with 12 additions and 5 deletions.
  1. +12 −5 scrapy/tests/
@@ -1,5 +1,5 @@
import json
import os
import subprocess
import time

from threading import Thread
@@ -8,14 +8,12 @@

from twisted.internet import defer
from twisted.trial.unittest import TestCase
from scrapy.http import Request
from scrapy.utils.test import get_testlog, docrawl
from scrapy.tests.spiders import SimpleSpider
from scrapy.tests.spiders import SimpleSpider, SingleRequestSpider
from scrapy.tests.mockserver import MockServer

class HTTPSProxy(controller.Master, Thread):

def __init__(self, port):
@@ -79,6 +77,15 @@ def test_https_tunnel_auth_error(self):
os.environ['https_proxy'] = 'http://scrapy:scrapy@localhost:8888'

def test_https_tunnel_without_leak_proxy_authorization_header(self):
request = Request("https://localhost:8999/echo")
spider = SingleRequestSpider(seed=request)
yield docrawl(spider)
echo = json.loads(spider.meta['responses'][0].body)
self.assertTrue('Proxy-Authorization' not in echo['headers'])

def test_https_noconnect_auth_error(self):
os.environ['https_proxy'] = 'http://wrong:wronger@localhost:8888?noconnect'

0 comments on commit f090260

Please sign in to comment.