Skip to content

Commit 57d08a8

Browse files
committed
Python: Rewrite old Tornado tests
Now you can run them, and the examples have been adjusted so they actually work!
1 parent 7db5590 commit 57d08a8

File tree

2 files changed

+54
-25
lines changed

2 files changed

+54
-25
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import tornado.web
2+
3+
4+
class BasicHandler(tornado.web.RequestHandler):
5+
def get(self):
6+
self.write("BasicHandler " + self.get_argument("xss"))
7+
8+
def post(self):
9+
self.write("BasicHandler (POST)")
10+
11+
12+
class DeepInheritance(BasicHandler):
13+
def get(self):
14+
self.write("DeepInheritance" + self.get_argument("also_xss"))
15+
16+
17+
class FormHandler(tornado.web.RequestHandler):
18+
def post(self):
19+
name = self.get_body_argument("name")
20+
self.write(name)
21+
22+
23+
class RedirectHandler(tornado.web.RequestHandler):
24+
def get(self):
25+
req = self.request
26+
h = req.headers
27+
url = h["url"]
28+
self.redirect(url)
29+
30+
31+
def make_app():
32+
return tornado.web.Application([
33+
(r"/basic", BasicHandler),
34+
(r"/deep", DeepInheritance),
35+
(r"/form", FormHandler),
36+
(r"/redirect", RedirectHandler),
37+
])
38+
39+
40+
if __name__ == "__main__":
41+
import tornado.ioloop
42+
43+
app = make_app()
44+
app.listen(8888)
45+
tornado.ioloop.IOLoop.current().start()
46+
47+
# http://localhost:8888/basic?xss=foo
48+
# http://localhost:8888/deep?also_xss=foo
49+
50+
# curl -X POST http://localhost:8888/basic
51+
# curl -X POST http://localhost:8888/deep
52+
53+
# curl -X POST -F "name=foo" http://localhost:8888/form
54+
# curl -v -H 'url: http://example.com' http://localhost:8888/redirect

python/ql/test/experimental/library-tests/frameworks/tornado/old_tests.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)