test/common/config/grpc_mux_impl_test.cc
// Validate behavior when type URL mismatches occur.
Validate behavior when type URL mismatches occur.
Validate behavior when type URL mismatches occur .
TEST_F(GrpcMuxImplTest, TypeUrlMismatch) {
  setup();
  std::unique_ptr<envoy::api::v2::DiscoveryResponse> invalid_response(
      new envoy::api::v2::DiscoveryResponse());
  InSequence s;
  auto foo_sub = grpc_mux_->subscribe("foo", {"x", "y"}, callbacks_);
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  expectSendMessage("foo", {"x", "y"}, "");
  grpc_mux_->start();
  {
    std::unique_ptr<envoy::api::v2::DiscoveryResponse> response(
        new envoy::api::v2::DiscoveryResponse());
    response->set_type_url("bar");
    grpc_mux_->onReceiveMessage(std::move(response));
  }
  {
    invalid_response->set_type_url("foo");
    invalid_response->mutable_resources()->Add()->set_type_url("bar");
    EXPECT_CALL(callbacks_, onConfigUpdateFailed(_)).WillOnce(Invoke([](const EnvoyException* e) {
      EXPECT_TRUE(
          IsSubstring("", "", "bar does not match foo type URL is DiscoveryResponse", e->what()));
    }));
    expectSendMessage("foo", {"x", "y"}, "", "", Grpc::Status::GrpcStatus::Internal,
                      fmt::format("bar does not match foo type URL is DiscoveryResponse {}",
                                  invalid_response->DebugString()));
    grpc_mux_->onReceiveMessage(std::move(invalid_response));
  }
  expectSendMessage("foo", {}, "");
}
TEST_F ( GrpcMuxImplTest , TypeUrlMismatch ) { setup ( ) ; std :: unique_ptr < envoy :: api :: v2 :: DiscoveryResponse > invalid_response ( new envoy :: api :: v2 :: DiscoveryResponse ( ) ) ; InSequence s ; auto foo_sub = grpc_mux_ -> subscribe ( " " , { " " , " " } , callbacks_ ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; expectSendMessage ( " " , { " " , " " } , " " ) ; grpc_mux_ -> start ( ) ; { std :: unique_ptr < envoy :: api :: v2 :: DiscoveryResponse > response ( new envoy :: api :: v2 :: DiscoveryResponse ( ) ) ; response -> set_type_url ( " " ) ; grpc_mux_ -> onReceiveMessage ( std :: move ( response ) ) ; } { invalid_response -> set_type_url ( " " ) ; invalid_response -> mutable_resources ( ) -> Add ( ) -> set_type_url ( " " ) ; EXPECT_CALL ( callbacks_ , onConfigUpdateFailed ( _ ) ) . WillOnce ( Invoke ( [ ] ( const EnvoyException * e ) { EXPECT_TRUE ( IsSubstring ( " " , " " , " " , e -> what ( ) ) ) ; } ) ) ; expectSendMessage ( " " , { " " , " " } , " " , " " , Grpc :: Status :: GrpcStatus :: Internal , fmt :: format ( " " , invalid_response -> DebugString ( ) ) ) ; grpc_mux_ -> onReceiveMessage ( std :: move ( invalid_response ) ) ; } expectSendMessage ( " " , { } , " " ) ; }
Validate behavior when type URL mismatches occur.
Validate behavior when type URL mismatches occur .