postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Access gRPC mock server/url from outside postman #11621

Open viralams opened 1 year ago

viralams commented 1 year ago

Is there an existing request for this feature?

Is your feature request related to a problem?

Id like to take advantage of the mock servers for gRPC in a few ways :

  1. Testing
  2. Check if my UI across the network works as expected
  3. Check from an other endpoint in the back end to see if the server responds the way I want it to

Describe the solution you'd like

Ensure this mock server is available to use outside of postman.

Describe alternatives you've considered

Havent gotten any alternatives

Additional context

This would be great for manual/automated integration testing.

codenirvana commented 1 year ago

@viralams gRPC mock URLs are publicly accessible, can you share more details about your use case?

viralams commented 1 year ago

I am able to create a mock URL from the UI no issues. But I am unable to curl or hit the url from the service/ui to get a mocked response. image

codenirvana commented 1 year ago

@viralams It's a gRPC server URL, an HTTP/cURL request will not work.

viralams commented 1 year ago

My bad for bad wording. I tried it with grpcurl and a service that expects http2 calls.

martinschaer commented 1 year ago

I'm interested on this too. In my case I tried using postman to mock a grpc server to help me develop a python client without the real grpc server.

Trying this:

grpc.insecure_channel("g-xyz.srv.pstmn.io")

Yields to this error:

E           grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E               status = StatusCode.UNAVAILABLE
E               details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv4:xxx.xxx.xxx.xxx:443: Socket closed"
E               debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNAVAILABLE: ipv4:xxx.xxx.xxx.xxx:443: Socket closed {created_time:"2023-09-27T14:31:50.700184+01:00", grpc_status:14}"
E           >

And this:

grpc.secure_channel("g-xyz.srv.pstmn.io", grpc.ssl_channel_credentials())

Yields to:

E           grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E               status = StatusCode.UNAVAILABLE
E               details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:xxx.xxx.xxx.xxx:443: Cannot check peer: missing selected ALPN property."
E               debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNKNOWN: ipv4:xxx.xxx.xxx.xxx:443: Cannot check peer: missing selected ALPN property. {grpc_status:14, created_time:"2023-09-27T14:33:39.861124+01:00"}"
E           >
martinschaer commented 1 year ago

I just tried with grpcurl and its working like this:

$ grpcurl -import-path ../protos \
    -proto my-stuff.proto \
    g-xyz.srv.pstmn.io:443 \
    my.custom.server.Service/Method
ryanmitchener commented 1 year ago

Our team has ran into the same issue when trying to test an Android application. grpcurl works fine, but the Java/Kotlin gRPC library (https://github.com/grpc/grpc-kotlin) cannot connect to the mock grpc server provided by Postman. I get the following error:

java.lang.RuntimeException: TLS ALPN negotiation failed with protocols: [h2]

It does not appear that the Postman server supports ALPN over HTTP/2.

I was able to use a mock server using https://github.com/tokopedia/gripmock with Android successfully, but that is not ideal as we have done all of our gRPC specification in Postman. It would be great if this were a supported usecase.