Skip to content

Commit 129e634

Browse files
committed
Ruby: expand Twirp test
1 parent 423da55 commit 129e634

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
sourceTest
22
| hello_world_server.rb:8:13:8:15 | req |
3+
| hello_world_server.rb:32:18:32:20 | req |
34
ssrfSinkTest
45
| hello_world_client.rb:6:47:6:75 | "http://localhost:8080/twirp" |
56
serviceInstantiationTest
67
| hello_world_server.rb:24:11:24:61 | call to new |
8+
| hello_world_server.rb:38:1:38:57 | call to new |

ruby/ql/test/library-tests/frameworks/Twirp/hello_world_server.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,34 @@
55

66
class HelloWorldHandler
77
# test: request
8-
def hello(req, env)
8+
def hello(req, env)
99
puts ">> Hello #{req.name}"
1010
{message: "Hello #{req.name}"}
1111
end
1212
end
1313

1414
class FakeHelloWorldHandler
1515
# test: !request
16-
def hello(req, env)
16+
def hello(req, env)
1717
puts ">> Hello #{req.name}"
1818
{message: "Hello #{req.name}"}
1919
end
2020
end
2121

2222
handler = HelloWorldHandler.new()
2323
# test: serviceInstantiation
24-
service = Example::HelloWorld::HelloWorldService.new(handler)
24+
service = Example::HelloWorld::HelloWorldService.new(handler)
2525

2626
path_prefix = "/twirp/" + service.full_name
2727
server = WEBrick::HTTPServer.new(Port: 8080)
2828
server.mount path_prefix, Rack::Handler::WEBrick, service
2929
server.start
30+
31+
class StaticHandler
32+
def self.hello(req, env)
33+
puts ">> Hello #{req.name}"
34+
{message: "Hello #{req.name}"}
35+
end
36+
end
37+
38+
Example::HelloWorld::HelloWorldService.new(StaticHandler)

0 commit comments

Comments
 (0)