test/extensions/filters/http/ext_proc/filter_test.cc
// Using the default configuration, test the filter with a processor that
// replies to the request_headers message incorrectly by sending a
// request_body message, which should result in the stream being closed
// and ignored.
Using the default configuration, test the filter with a processor that
replies to the request_headers message incorrectly by sending a
request_body message, which should result in the stream being closed
and ignored.
Using the default configuration test the filter with a processor that replies to the request_headers message incorrectly by sending a request_body message which should result in the stream being closed and ignored .
TEST_F(HttpFilterTest, OutOfOrder) {
  initialize(R"EOF(
  grpc_service:
    envoy_grpc:
      cluster_name: "ext_proc_server"
  )EOF");
  HttpTestUtility::addDefaultHeaders(request_headers_, "POST");
  EXPECT_EQ(FilterHeadersStatus::StopAllIterationAndWatermark,
            filter_->decodeHeaders(request_headers_, false));
  EXPECT_FALSE(last_request_.async_mode());
  EXPECT_FALSE(stream_close_sent_);
  ASSERT_TRUE(last_request_.has_request_headers());
  EXPECT_CALL(decoder_callbacks_, continueDecoding());
  std::unique_ptr<ProcessingResponse> resp1 = std::make_unique<ProcessingResponse>();
  resp1->mutable_request_body();
  stream_callbacks_->onReceiveMessage(std::move(resp1));
  data_.add("foo");
  EXPECT_EQ(FilterDataStatus::Continue, filter_->decodeData(data_, true));
  EXPECT_EQ(FilterTrailersStatus::Continue, filter_->decodeTrailers(request_trailers_));
  EXPECT_EQ(FilterHeadersStatus::Continue, filter_->encode100ContinueHeaders(response_headers_));
  EXPECT_EQ(FilterHeadersStatus::Continue, filter_->encodeHeaders(response_headers_, true));
  data_.add("bar");
  EXPECT_EQ(FilterDataStatus::Continue, filter_->encodeData(data_, false));
  EXPECT_EQ(FilterDataStatus::Continue, filter_->encodeData(data_, true));
  EXPECT_EQ(FilterTrailersStatus::Continue, filter_->encodeTrailers(response_trailers_));
  filter_->onDestroy();
  EXPECT_TRUE(stream_close_sent_);
  EXPECT_EQ(1, config_->stats().streams_started_.value());
  EXPECT_EQ(1, config_->stats().stream_msgs_sent_.value());
  EXPECT_EQ(1, config_->stats().spurious_msgs_received_.value());
  EXPECT_EQ(1, config_->stats().streams_closed_.value());
}
TEST_F ( HttpFilterTest , OutOfOrder ) { initialize ( R" EOF ( 
  grpc_service:
    envoy_grpc:
      cluster_name: "ext_proc_server"
   ) EOF " ) ; HttpTestUtility :: addDefaultHeaders ( request_headers_ , " " ) ; EXPECT_EQ ( FilterHeadersStatus :: StopAllIterationAndWatermark , filter_ -> decodeHeaders ( request_headers_ , false ) ) ; EXPECT_FALSE ( last_request_ . async_mode ( ) ) ; EXPECT_FALSE ( stream_close_sent_ ) ; ASSERT_TRUE ( last_request_ . has_request_headers ( ) ) ; EXPECT_CALL ( decoder_callbacks_ , continueDecoding ( ) ) ; std :: unique_ptr < ProcessingResponse > resp1 = std :: make_unique < ProcessingResponse > ( ) ; resp1 -> mutable_request_body ( ) ; stream_callbacks_ -> onReceiveMessage ( std :: move ( resp1 ) ) ; data_ . add ( " " ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> decodeData ( data_ , true ) ) ; EXPECT_EQ ( FilterTrailersStatus :: Continue , filter_ -> decodeTrailers ( request_trailers_ ) ) ; EXPECT_EQ ( FilterHeadersStatus :: Continue , filter_ -> encode100ContinueHeaders ( response_headers_ ) ) ; EXPECT_EQ ( FilterHeadersStatus :: Continue , filter_ -> encodeHeaders ( response_headers_ , true ) ) ; data_ . add ( " " ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> encodeData ( data_ , false ) ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> encodeData ( data_ , true ) ) ; EXPECT_EQ ( FilterTrailersStatus :: Continue , filter_ -> encodeTrailers ( response_trailers_ ) ) ; filter_ -> onDestroy ( ) ; EXPECT_TRUE ( stream_close_sent_ ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . streams_started_ . value ( ) ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . stream_msgs_sent_ . value ( ) ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . spurious_msgs_received_ . value ( ) ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . streams_closed_ . value ( ) ) ; }
Using the default configuration, test the filter with a processor that
replies to the request_headers message incorrectly by sending a
request_body message, which should result in the stream being closed
and ignored.
Using the default configuration test the filter with a processor that replies to the request_headers message incorrectly by sending a request_body message which should result in the stream being closed and ignored .
// Return an out-of-order message. The server should close the stream // and continue as if nothing happened. // We closed the stream