wiremock / wiremock-grpc-extension

WireMock Extension: gRPC mocking
https://wiremock.org/docs/grpc/
Apache License 2.0
15 stars 9 forks source link

Allow the gRPC extension to be used with Jetty 12 #73

Open leeturner opened 6 months ago

leeturner commented 6 months ago

Proposal

At the moment, the gRPC extension is tied to the Jetty11HttpServer in the buildHttpServer method.

@Override
  public HttpServer buildHttpServer(
      Options options,
      AdminRequestHandler adminRequestHandler,
      StubRequestHandler stubRequestHandler) {
    return new Jetty11HttpServer(options, adminRequestHandler, stubRequestHandler) {
      @Override
      protected void decorateMockServiceContextBeforeConfig(
          ServletContextHandler mockServiceContext) {

        final GrpcFilter grpcFilter = new GrpcFilter(stubRequestHandler, fileDescriptors);
        final FilterHolder filterHolder = new FilterHolder(grpcFilter);
        mockServiceContext.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
      }
    };
  }

This means it won't work anywhere where we need to rely on Jetty12 like the 3.x.x releases of Spring Boot. It would be nice to support both Jetty 11 and 12 like we do in WireMock core

References

https://github.com/wiremock/wiremock/tree/master/wiremock-jetty12 https://wiremock-community.slack.com/archives/C04HHJ7F20G/p1715613366000319

marcinex7 commented 3 months ago

Is there any follow-up on this? Any plans to enable gRPC on Jetty 12?

HuppiFluppi commented 2 months ago

Also ran into this. Wiremock has a jetty12 version, the grpc extension unfortunately does not. This makes it very hard to use it in setups like with SpringBoot 3.x

For reference, i can actually run the combination of org.wiremock:wiremock-jetty12:3.9.1 and org.wiremock:wiremock-grpc-extension:0.8.0, but at runtime the call fails for mssing/invalid content type:

UNKNOWN: HTTP status code 200
invalid content-type: null
headers: Metadata(:status=200,grpc-status-name=OK,matched-stub-id=8a8efae9-1239-4f20-9fde-bd785dcf05d2)
DATA-----------------------------
{}
DATA-----------------------------

grpc: 1.66 protobuf: 4.28


The standalone versions of wiremock and the grpc-extension can be used, but this poses a new problem. The java style creation of stubs wont work with a mixed setup.

message() expects an wiremock.com.google.protobuf.MessageOrBuilder but the messages created for use in the project implement com.google.protobuf.MessageOrBuilder

I resorted to use standalone and json stubbing but it clearly is not an ideal solution.

Would be happy if this can be fixed in next version.