TestUnaryServerInterceptorGetsConnection tests whether the accepted conn on the server gets to any unary interceptors on the server side.
(t *testing.T)
| 6653 | // TestUnaryServerInterceptorGetsConnection tests whether the accepted conn on |
| 6654 | // the server gets to any unary interceptors on the server side. |
| 6655 | func (s) TestUnaryServerInterceptorGetsConnection(t *testing.T) { |
| 6656 | ss := &stubserver.StubServer{} |
| 6657 | if err := ss.Start([]grpc.ServerOption{grpc.UnaryInterceptor(unaryInterceptorVerifyConn)}); err != nil { |
| 6658 | t.Fatalf("Error starting endpoint server: %v", err) |
| 6659 | } |
| 6660 | defer ss.Stop() |
| 6661 | |
| 6662 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 6663 | defer cancel() |
| 6664 | |
| 6665 | if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}); status.Code(err) != codes.OK { |
| 6666 | t.Fatalf("ss.Client.EmptyCall(_, _) = _, %v, want _, error code %s", err, codes.OK) |
| 6667 | } |
| 6668 | } |
| 6669 | |
| 6670 | func streamingInterceptorVerifyConn(_ any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error { |
| 6671 | conn := transport.GetConnection(ss.Context()) |