From 375d7c9741c1debbc55bf21c864c514d307691ef Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 5 Jun 2016 13:24:46 +1200 Subject: [PATCH] Remove last vestiges of noapi and noweb from pathod Also hide HTTP2 freeze bug by making explain configurable in the tests --- pathod/pathod.py | 24 +++++++++--------------- pathod/pathod_cmdline.py | 8 -------- test/pathod/test_pathoc.py | 1 + test/pathod/test_pathod.py | 12 +----------- test/pathod/tutils.py | 10 +++------- 5 files changed, 14 insertions(+), 41 deletions(-) diff --git a/pathod/pathod.py b/pathod/pathod.py index add339449..ed35a92e6 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -304,9 +304,7 @@ class Pathod(tcp.TCPServer): staticdir=None, anchors=(), sizelimit=None, - noweb=False, nocraft=False, - noapi=False, nohang=False, timeout=None, logreq=False, @@ -328,7 +326,6 @@ class Pathod(tcp.TCPServer): None. sizelimit: Limit size of served data. nocraft: Disable response crafting. - noapi: Disable the API. nohang: Disable pauses. """ tcp.TCPServer.__init__(self, addr) @@ -337,8 +334,8 @@ class Pathod(tcp.TCPServer): self.staticdir = staticdir self.craftanchor = craftanchor self.sizelimit = sizelimit - self.noweb, self.nocraft = noweb, nocraft - self.noapi, self.nohang = noapi, nohang + self.nocraft = nocraft + self.nohang = nohang self.timeout, self.logreq = timeout, logreq self.logresp, self.hexdump = logresp, hexdump self.http2_framedump = http2_framedump @@ -404,14 +401,13 @@ class Pathod(tcp.TCPServer): return def add_log(self, d): - if not self.noapi: - with self.loglock: - d["id"] = self.logid - self.log.insert(0, d) - if len(self.log) > self.LOGBUF: - self.log.pop() - self.logid += 1 - return d["id"] + with self.loglock: + d["id"] = self.logid + self.log.insert(0, d) + if len(self.log) > self.LOGBUF: + self.log.pop() + self.logid += 1 + return d["id"] def clear_log(self): with self.loglock: @@ -469,9 +465,7 @@ def main(args): # pragma: no cover staticdir=args.staticdir, anchors=args.anchors, sizelimit=args.sizelimit, - noweb=args.noweb, nocraft=args.nocraft, - noapi=args.noapi, nohang=args.nohang, timeout=args.timeout, logreq=args.logreq, diff --git a/pathod/pathod_cmdline.py b/pathod/pathod_cmdline.py index a4f05fafe..5ca2ca859 100644 --- a/pathod/pathod_cmdline.py +++ b/pathod/pathod_cmdline.py @@ -74,18 +74,10 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr): default=None, type=str, help='Size limit of served responses. Understands size suffixes, i.e. 100k.') - parser.add_argument( - "--noapi", dest='noapi', default=False, action="store_true", - help='Disable API.' - ) parser.add_argument( "--nohang", dest='nohang', default=False, action="store_true", help='Disable pauses during crafted response generation.' ) - parser.add_argument( - "--noweb", dest='noweb', default=False, action="store_true", - help='Disable both web interface and API.' - ) parser.add_argument( "--nocraft", dest='nocraft', diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index a88cfa91a..8b69a2a67 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -228,6 +228,7 @@ class TestDaemon(PathocTestDaemon): class TestDaemonHTTP2(PathocTestDaemon): ssl = True + explain = False if tcp.HAS_ALPN: diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index f64b0f611..0bbad6c27 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -23,18 +23,10 @@ class TestPathod(object): assert len(p.get_log()) <= p.LOGBUF -class TestNoWeb(tutils.DaemonTests): - noweb = True - - def test_noweb(self): - assert self.get("200:da").status_code == 200 - assert self.getpath("/").status_code == 800 - - class TestTimeout(tutils.DaemonTests): timeout = 0.01 - def test_noweb(self): + def test_timeout(self): # FIXME: Add float values to spec language, reduce test timeout to # increase test performance # This is a bodge - we have some platform difference that causes @@ -261,8 +253,6 @@ class TestDaemonSSL(CommonTests): class TestHTTP2(tutils.DaemonTests): ssl = True - noweb = True - noapi = True nohang = True if tcp.HAS_ALPN: diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index 1a883c93c..56cd20025 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -24,14 +24,13 @@ def treader(bytes): class DaemonTests(object): - noweb = False - noapi = False nohang = False ssl = False timeout = None hexdump = False ssloptions = None nocraft = False + explain = True @classmethod def setup_class(cls): @@ -47,15 +46,13 @@ class DaemonTests(object): ssl=cls.ssl, ssloptions=so, sizelimit=1 * 1024 * 1024, - noweb=cls.noweb, - noapi=cls.noapi, nohang=cls.nohang, timeout=cls.timeout, hexdump=cls.hexdump, nocraft=cls.nocraft, logreq=True, logresp=True, - explain=True + explain=cls.explain ) @classmethod @@ -65,8 +62,7 @@ class DaemonTests(object): def teardown(self): self.d.wait_for_silence() - if not (self.noweb or self.noapi): - self.d.clear_log() + self.d.clear_log() def _getpath(self, path, params=None): scheme = "https" if self.ssl else "http"