Catch unkown domain in validate_url
This commit is contained in:
parent
7550664030
commit
469187e4f1
2 changed files with 10 additions and 2 deletions
|
@ -55,6 +55,11 @@ class TestsValidateProxyURL(TestCase):
|
|||
with self.assertRaises(AssertionError):
|
||||
validate_url(request)
|
||||
|
||||
def test_unkown_domain_raises(self):
|
||||
request = self.buildRequest("http://xlkjdkjsdlkjfd.com")
|
||||
with self.assertRaises(AssertionError):
|
||||
validate_url(request)
|
||||
|
||||
|
||||
class TestsProxy(TestCase):
|
||||
|
||||
|
|
|
@ -207,8 +207,11 @@ def validate_url(request):
|
|||
assert referer.hostname == local.hostname
|
||||
assert toproxy.hostname != "localhost"
|
||||
assert toproxy.netloc != local.netloc
|
||||
try:
|
||||
# clean this when in python 3.4
|
||||
ipaddress = socket.gethostbyname(toproxy.hostname)
|
||||
except:
|
||||
raise AssertionError()
|
||||
assert not ipaddress.startswith('127.')
|
||||
assert not ipaddress.startswith('192.168.')
|
||||
return url
|
||||
|
|
Loading…
Reference in a new issue