def test_simple(self): with test.Daemon() as d: rsp = requests.get("http://localhost:%s/p/202:da" % d.port) assert rsp.ok assert rsp.status_code == 202 with tutils.raises(requests.ConnectionError): requests.get("http://localhost:%s/p/202:da" % d.port)
def test_startstop_ssl(self): d = test.Daemon(ssl=True) rsp = requests.get("https://localhost:%s/p/202" % d.port, verify=False) assert rsp.ok assert rsp.status_code == 202 d.shutdown() tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202" % d.port)
def test_terminate_error(self): self.d = test.Daemon() sc = ServerConnection((self.d.IFACE, self.d.port)) sc.connect() sc.connection = mock.Mock() sc.connection.recv = mock.Mock(return_value=False) sc.connection.flush = mock.Mock(side_effect=TcpDisconnect) sc.finish() self.d.shutdown()
def setUpAll(self): self.d = test.Daemon(staticdir=test_data.path("data"), anchors=[("/anchor/.*", "202")], ssl=self.ssl, sizelimit=1 * 1024 * 1024, noweb=self.noweb, noapi=self.noapi, nohang=self.nohang, timeout=self.timeout, logreq=True, logresp=True)
def test_startstop_ssl_explicit(self): ssloptions = dict(certfile=tutils.test_data.path("data/testkey.pem"), cacert=tutils.test_data.path("data/testkey.pem"), ssl_after_connect=False) d = test.Daemon(ssl=ssloptions) rsp = requests.get("https://localhost:%s/p/202:da" % d.port, verify=False) assert rsp.ok assert rsp.status_code == 202 d.shutdown() tutils.raises("Connection aborted", requests.get, "http://localhost:%s/p/202:da" % d.port)
def test_startstop_ssl_explicit(self): ssloptions = dict( keyfile=utils.data.path("resources/server.key"), certfile=utils.data.path("resources/server.crt"), ) d = test.Daemon(ssl=ssloptions) rsp = requests.get("https://localhost:%s/p/202" % d.port, verify=False) assert rsp.ok assert rsp.status_code == 202 d.shutdown() tutils.raises(requests.ConnectionError, requests.get, "http://localhost:%s/p/202" % d.port)
def setUpAll(self): so = pathod.SSLOptions(not_after_connect=self.not_after_connect) self.d = test.Daemon(staticdir=test_data.path("data"), anchors=[("/anchor/.*", "202:da")], ssl=self.ssl, ssloptions=so, sizelimit=1 * 1024 * 1024, noweb=self.noweb, noapi=self.noapi, nohang=self.nohang, timeout=self.timeout, hexdump=self.hexdump, logreq=True, logresp=True, explain=True)
def test_simple(self): self.d = test.Daemon() sc = ServerConnection((self.d.IFACE, self.d.port)) sc.connect() f = tutils.tflow() f.server_conn = sc f.request.path = "/p/200:da" # use this protocol just to assemble - not for actual sending sc.wfile.write(http1.assemble_request(f.request)) sc.wfile.flush() assert http1.read_response(sc.rfile, f.request, 1000) assert self.d.last_log() sc.finish() self.d.shutdown()
def setup_class(cls): opts = cls.ssloptions or {} cls.confdir = tempfile.mkdtemp() opts["confdir"] = cls.confdir so = pathod.SSLOptions(**opts) cls.d = test.Daemon(staticdir=test_data.path("data"), anchors=[(re.compile("/anchor/.*"), "202:da")], 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)
def setUpAll(self): opts = self.ssloptions or {} self.confdir = tempfile.mkdtemp() opts["confdir"] = self.confdir so = pathod.SSLOptions(**opts) self.d = test.Daemon( staticdir=test_data.path("data"), anchors=[("/anchor/.*", "202:da")], ssl = self.ssl, ssloptions = so, sizelimit=1*1024*1024, noweb = self.noweb, noapi = self.noapi, nohang = self.nohang, timeout = self.timeout, hexdump = self.hexdump, logreq = True, logresp = True, explain = True )
def setUpAll(klass): opts = klass.ssloptions or {} klass.confdir = tempfile.mkdtemp() opts["confdir"] = klass.confdir so = pathod.SSLOptions(**opts) klass.d = test.Daemon( staticdir=test_data.path("data"), anchors=[ (re.compile("/anchor/.*"), language.parse_response("202:da")) ], ssl = klass.ssl, ssloptions = so, sizelimit = 1*1024*1024, noweb = klass.noweb, noapi = klass.noapi, nohang = klass.nohang, timeout = klass.timeout, hexdump = klass.hexdump, logreq = True, logresp = True, explain = True )
def setUpAll(self): self.d = test.Daemon(staticdir=tutils.test_data.path("data"), anchors=[("/anchor/.*", "202")])
def setUpAll(cls): cls.d = test.Daemon()
def setup_class(cls): cls.d = test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions, staticdir=tutils.test_data.path("data"), anchors=[(re.compile("/anchor/.*"), "202")])
def setup_class(cls): cls.d = test.Daemon()
def setUp(self): self.d = test.Daemon()
def setUpAll(self): self.d = test.Daemon(ssl=self.ssl, ssloptions=self.ssloptions, staticdir=tutils.test_data.path("data"), anchors=[(re.compile("/anchor/.*"), language.parse_response("202"))])