From c198406b1236cc0c108c450efc06b300d2509370 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 7 Sep 2014 11:38:44 +1200 Subject: [PATCH] Silence insecure requets warnings in our test package --- libpathod/test.py | 4 ++++ test/test_pathoc.py | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libpathod/test.py b/libpathod/test.py index 398e94be3..57d40300a 100644 --- a/libpathod/test.py +++ b/libpathod/test.py @@ -1,7 +1,11 @@ import threading, Queue import requests +import requests.packages.urllib3 import pathod +requests.packages.urllib3.disable_warnings() + + class Daemon: IFACE = "127.0.0.1" diff --git a/test/test_pathoc.py b/test/test_pathoc.py index 3eeec9f6c..fe7adc4d5 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -1,7 +1,9 @@ -import json, cStringIO +import json +import cStringIO from libpathod import pathoc, test, version, pathod import tutils + def test_response(): r = pathoc.Response("1.1", 200, "Message", {}, None, None) assert repr(r) @@ -9,6 +11,7 @@ def test_response(): class _TestDaemon: ssloptions = pathod.SSLOptions() + @classmethod def setUpAll(self): self.d = test.Daemon( @@ -34,8 +37,8 @@ class _TestDaemon: r = c.request("get:/api/info") assert tuple(json.loads(r.content)["version"]) == version.IVERSION - def tval(self, requests, showreq=False, showresp=False, explain=False, - showssl=False, hexdump=False, timeout=None, ignorecodes=None, + def tval(self, requests, showreq=False, showresp=False, explain=False, + showssl=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None): c = pathoc.Pathoc(("127.0.0.1", self.d.port), ssl=self.ssl) c.connect() @@ -60,6 +63,7 @@ class _TestDaemon: class TestDaemonSSL(_TestDaemon): ssl = True ssloptions = pathod.SSLOptions(request_client_cert=True) + def test_sni(self): c = pathoc.Pathoc( ("127.0.0.1", self.d.port), @@ -73,7 +77,7 @@ class TestDaemonSSL(_TestDaemon): assert d["log"][0]["request"]["sni"] == "foobar.com" def test_showssl(self): - assert "certificate chain" in self.tval(["get:/p/200"], showssl=True) + assert "certificate chain" in self.tval(["get:/p/200"], showssl=True) def test_clientcert(self): c = pathoc.Pathoc( @@ -90,12 +94,13 @@ class TestDaemonSSL(_TestDaemon): class TestDaemon(_TestDaemon): ssl = False + def test_ssl_error(self): c = pathoc.Pathoc(("127.0.0.1", self.d.port), ssl = True) tutils.raises("ssl handshake", c.connect) def test_showssl(self): - assert not "certificate chain" in self.tval(["get:/p/200"], showssl=True) + assert not "certificate chain" in self.tval(["get:/p/200"], showssl=True) def test_ignorecodes(self): assert "200" in self.tval(["get:'/p/200:b@1'"]) @@ -109,7 +114,7 @@ class TestDaemon(_TestDaemon): assert not "HTTP" in self.tval(["get:'/p/200:p5,10'"], showresp=True, timeout=0.01, ignoretimeout=True) def test_showresp(self): - reqs = [ "get:/api/info:p0,0", "get:/api/info:p0,0" ] + reqs = ["get:/api/info:p0,0", "get:/api/info:p0,0"] assert self.tval(reqs).count("200") == 2 assert self.tval(reqs, showresp=True).count("unprintables escaped") == 2 assert self.tval(reqs, showresp=True, hexdump=True).count("hex dump") == 2