-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GRPC mappings are not created correctly when created through Admin API #1233
Comments
Can you try preview https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions |
Hmm I am not sure if there is still an issue or I am doing something wrong. I switched to 1.6.11-ci-19563. I am using below proto: syntax = "proto3";
package greet;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply);
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
} and load it with "greet" ID like: string protosFolder = args[0];
string[] filePaths = Directory.GetFiles(protosFolder);
foreach (string filePath in filePaths)
{
_server.AddProtoDefinition(Path.GetFileNameWithoutExtension(filePath), File.ReadAllText(filePath));
} Server configuration: _server
.Given(Request.Create()
.UsingPost()
.WithBodyAsProtoBuf("greet.HelloRequest")
)
.WithProtoDefinition("greet")
.RespondWith(Response.Create()
.WithHeader("Content-Type", "application/grpc")
.WithTrailingHeader("grpc-status", "0")
.WithBodyAsProtoBuf("greet.HelloReply", new { message = "hello {{request.BodyAsJson.name}} {{request.method}}" })
.WithTransformer()); I run it and I am able to get successful response from the servier using postman. Now, I am getting mapping via __admin/mappings: [
{
"Guid": "e7154d4b-cd5e-4d6b-9383-c15e058c0535",
"UpdatedAt": "2025-01-11T17:30:32.1365012Z",
"Request": {
"Methods": [
"POST"
],
"Body": {
"Matcher": {
"Name": "ProtoBufMatcher",
"ProtoBufMessageType": "greet.HelloRequest"
}
}
},
"Response": {
"BodyAsJson": {
"message": "hello {{request.BodyAsJson.name}} {{request.method}}"
},
"UseTransformer": true,
"TransformerType": "Handlebars",
"TransformerReplaceNodeOptions": "EvaluateAndTryToConvert",
"Headers": {
"Content-Type": "application/grpc"
},
"TrailingHeaders": {
"grpc-status": "0"
},
"ProtoBufMessageType": "greet.HelloReply"
},
"ProtoDefinition": "greet"
}
] I delete all the mappings, paste above JSON into file, then post it back to the server via __admin/mappings with curl If I get mapping again using Can you try replicating above situation? Maybe I am doing some dumb mistake on my side. Hard to say as mapping itself looks fine. |
@misiek150 Can you test preview version |
@misiek150 |
Describe the bug
It looks like mappings for GRPC call are not created correctly when created through __admin/mappings endpoint. It doesn't matter if we register proto at server level or pass its content to mapping response and request, directly. Created mapping miss some parts which causes requests to fail (returning 404 status code).
When proto is registered at server level following parts are not created despite the fact they are included in the JSON request for creating mappings:
When proto is passed as text directly (for request and response) following parts are not created despite the fact they are included in the JSON request for creating mappings:
Expected behavior:
Above parts of the mapping are created thus mapping works correctly and the same way as if they were created through code at server start.
Test to reproduce
Start server with below code, register attached proto, don't add any mappings, e.g.:
Proto definition:
Register following mapping through __admin/mappings endpoint:
Inspect mapping using __admin/mappings endpoint for missing parts of the mapping.
Sample code to get server working correctly (i.e. return proper response to client):
__admin/mappings endpoint may be used to obtain JSON mappings, posted earlier in this post.
Other related info
In case there is any problem with the approach I take, or maybe there is some specific convention required in terms of JSON mapping I tried I am more than happy to be corrected.
The text was updated successfully, but these errors were encountered: