Skip to content
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

ProtoBufMatcher not working when proto package name contains dots #1077

Closed
vgoranski opened this issue Mar 6, 2024 · 2 comments
Closed

ProtoBufMatcher not working when proto package name contains dots #1077

vgoranski opened this issue Mar 6, 2024 · 2 comments
Labels

Comments

@vgoranski
Copy link

Describe the bug

When I'm trying to use the recently introduced ProtoBufMatcher with package in proto that contains dots in the name, I'm getting Grpc.Core.RpcException with message Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404"). If I remove the dots everything works fine.

Expected behavior:

Package name containig dots works.

Test to reproduce

[Fact]
public async Task WireMockServer_WithBodyAsProtoBuf_InlineProtoDefinition_UsingGrpcGeneratedClient()
{
    const string packageName = "greet.foo";
    const string protoDefinition = $$"""

                                   syntax = "proto3";
                                   package {{packageName}};
                                   service Greeter {
                                     rpc SayHello (HelloRequest) returns (HelloReply);
                                   }
                                   message HelloRequest {
                                     string name = 1;
                                   }
                                   message HelloReply {
                                     string message = 1;
                                   }

                                   """;

    // Arrange
    using var server = WireMockServer.Start(useHttp2: true);

    var jsonMatcher = new JsonMatcher(new { name = "stef" });

    server
        .Given(Request.Create()
                      .UsingPost()
                      .WithPath($"/{packageName}.Greeter/SayHello")
                      .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloRequest", jsonMatcher)
        )
        .RespondWith(Response.Create()
                             .WithHeader("Content-Type", "application/grpc")
                             .WithTrailingHeader("grpc-status", "0")
                             .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloReply",
                                 new
                                 {
                                     message = "hello stef {{request.method}}"
                                 }
                             )
                             .WithTransformer()
        );

    // Act
    var channel = GrpcChannel.ForAddress(server.Url!);

    var client = new Greeter.GreeterClient(channel);

    var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });

    // Assert
    reply.Message.Should().Be("hello stef POST");

    server.Stop();
}
@StefH
Copy link
Collaborator

StefH commented Mar 6, 2024

@vgoranski Thank you for noticing, I'll fix this and release a new NuGet soon.

@StefH
Copy link
Collaborator

StefH commented Mar 6, 2024

#1078

@StefH StefH closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants