Skip to content

Commit d27e695

Browse files
committed
Python: Add test setup for HTTP::Server::RouteSetup
1 parent ebc3d32 commit d27e695

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

python/ql/test/experimental/meta/ConceptsTest.qll

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class SystemCommandExecutionTest extends InlineExpectationsTest {
2222
override string getARelevantTag() { result = "getCommand" }
2323

2424
override predicate hasActualResult(Location location, string element, string tag, string value) {
25+
exists(location.getFile().getRelativePath()) and
2526
exists(SystemCommandExecution sce, DataFlow::Node command |
26-
exists(location.getFile().getRelativePath()) and
2727
command = sce.getCommand() and
2828
location = command.getLocation() and
2929
element = command.toString() and
@@ -32,3 +32,39 @@ class SystemCommandExecutionTest extends InlineExpectationsTest {
3232
)
3333
}
3434
}
35+
36+
class HttpServerRouteSetupTest extends InlineExpectationsTest {
37+
HttpServerRouteSetupTest() { this = "HttpServerRouteSetupTest" }
38+
39+
override string getARelevantTag() { result in ["routeSetup", "routeHandler", "routedParameter"] }
40+
41+
override predicate hasActualResult(Location location, string element, string tag, string value) {
42+
exists(HTTP::Server::RouteSetup setup |
43+
location = setup.getLocation() and
44+
element = setup.toString() and
45+
(
46+
value = "\"" + setup.getUrlPattern() + "\""
47+
or
48+
not exists(setup.getUrlPattern()) and
49+
value = ""
50+
) and
51+
tag = "routeSetup"
52+
)
53+
or
54+
exists(HTTP::Server::RouteSetup setup, Function func |
55+
func = setup.getARouteHandler() and
56+
location = func.getLocation() and
57+
element = func.toString() and
58+
value = "" and
59+
tag = "routeHandler"
60+
)
61+
or
62+
exists(HTTP::Server::RouteSetup setup, Parameter param |
63+
param = setup.getARoutedParameter() and
64+
location = param.getLocation() and
65+
element = param.toString() and
66+
value = param.asName().getId() and
67+
tag = "routedParameter"
68+
)
69+
}
70+
}

0 commit comments

Comments
 (0)