Tests gRPC server's behavior when a gRPC client sends a frame with an invalid streamID. Per [HTTP/2 spec]: Streams initiated by a client MUST use odd-numbered stream identifiers. This test sets up a test server and sends a header frame with stream ID of 2. The test asserts that a subsequent read on
(t *testing.T)
| 4556 | // |
| 4557 | // [HTTP/2 spec]: https://httpwg.org/specs/rfc7540.html#StreamIdentifiers |
| 4558 | func (s) TestClientInvalidStreamID(t *testing.T) { |
| 4559 | lis, err := net.Listen("tcp", "localhost:0") |
| 4560 | if err != nil { |
| 4561 | t.Fatalf("Failed to listen: %v", err) |
| 4562 | } |
| 4563 | defer lis.Close() |
| 4564 | s := grpc.NewServer() |
| 4565 | defer s.Stop() |
| 4566 | go s.Serve(lis) |
| 4567 | |
| 4568 | conn, err := net.DialTimeout("tcp", lis.Addr().String(), defaultTestTimeout) |
| 4569 | if err != nil { |
| 4570 | t.Fatalf("Failed to dial: %v", err) |
| 4571 | } |
| 4572 | st := newServerTesterFromConn(t, conn) |
| 4573 | st.greet() |
| 4574 | st.writeHeadersGRPC(2, "/grpc.testing.TestService/StreamingInputCall", true) |
| 4575 | goAwayFrame := st.wantGoAway(http2.ErrCodeProtocol) |
| 4576 | want := "received an illegal stream id: 2." |
| 4577 | if got := string(goAwayFrame.DebugData()); !strings.Contains(got, want) { |
| 4578 | t.Fatalf(" Received: %v, Expected error message to contain: %v.", got, want) |
| 4579 | } |
| 4580 | } |
| 4581 | |
| 4582 | // Tests that a gRPC server transport does not deadlock when it receives a zero |
| 4583 | // second deadline, and properly returns a deadline exceeded error immediately. |
nothing calls this directly
no test coverage detected