Skip to content

Commit 919a0b6

Browse files
committed
Python: aiohttp route setup is more complicated than expected
1 parent c69b857 commit 919a0b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/ql/test/library-tests/frameworks/aiohttp/routing_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,23 @@ async def get(self): # $ requestHandler
122122

123123
app.router.add_view("/MyWebViewNoSubclassButRoute", MyWebViewNoSubclassButRoute) # $ routeSetup="/MyWebViewNoSubclassButRoute"
124124

125+
126+
# Apparently there is no enforcement that `add_view` is only for views, and vice-versa
127+
# for `add_get` only being for async functions.
128+
if True:
129+
async def no_rules(request): # $ MISSING: requestHandler
130+
return web.Response(text="no_rules")
131+
132+
app.router.add_view("/no_rules", no_rules) # $ routeSetup="/no_rules"
133+
134+
135+
class NoRulesView(web.View):
136+
async def get(self): # $ requestHandler
137+
return web.Response(text="NoRulesView.get")
138+
139+
app.router.add_get("/NoRulesView", NoRulesView) # $ routeSetup="/NoRulesView"
140+
141+
125142
## =================== ##
126143
## "Routed parameters" ##
127144
## =================== ##

0 commit comments

Comments
 (0)