camouflage
camouflage copied to clipboard
Request matcher not working on grpc
Describe the bug
Trying to match with is + capture doesn't work
To Reproduce Steps to reproduce the behavior:
- Tree structure:
./mocks
|- /test
|- Greeter
|- SayHello.mock
./protos
|- simple.proto
./config.yml
- File content:
// simple.proto
syntax = "proto3";
package test;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
// SayHello.mock
{{#is (capture using='jsonpath' selector='$.name') 'Bob' }}
{
"message": "{{capture using='jsonpath' selector='$.name'}}"
}
{{else}}
{
"message": "Not Bob, you are: {{capture using='jsonpath' selector='$.name'}}"
}
{{/is}}
// config.yml
...
grpc:
enable: true
#host: localhost
host: 0.0.0.0
port: 4312
mocks_dir: "./mocks"
protos_dir: "./protos"
grpc_tls: false
- Run camouflage:
docker run -d -p 4312:4312 -v $(pwd):/app --name camouflage shubhendumadhukar/camouflage - Hit endpoint with
Bob:
grpcurl \
-proto protos/simple.proto \
-d '{"name": "Bob"}' \
-plaintext \
localhost:4312 \
test.Greeter/SayHello
{
"message": "Not Bob, you are: Bob"
}
- Hit endpoint with
Alice:
grpcurl \
-proto protos/simple.proto \
-d '{"name": "Alice"}' \
-plaintext \
localhost:4312 \
test.Greeter/SayHello
{
"message": "Not Bob, you are: Alice"
}
Expected behavior
Step 4 should print a different message: { "message": "Bob" }.
The jsonpath is correct, because when returning the message, it correctly says "you are: Bob". However, the comparison doesn't seem to be working.
Additional context
2022-09-30 15:07:53 debug: Unary Request: {"name":"Bob"}
2022-09-30 15:07:53 debug: Mock file path: mocks/test/Greeter/SayHello.mock
2022-09-30 15:07:53 debug: Response: {
"message": "Not Bob, you are: Bob"
}