Remove last vestiges of noapi and noweb from pathod

Also hide HTTP2 freeze bug by making explain configurable in the tests
This commit is contained in:
Aldo Cortesi 2016-06-05 13:24:46 +12:00
parent 48da24ae7e
commit 375d7c9741
5 changed files with 14 additions and 41 deletions

View File

@ -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,

View File

@ -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',

View File

@ -228,6 +228,7 @@ class TestDaemon(PathocTestDaemon):
class TestDaemonHTTP2(PathocTestDaemon):
ssl = True
explain = False
if tcp.HAS_ALPN:

View File

@ -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:

View File

@ -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"