test/common/config/grpc_mux_impl_test.cc
//  Verifies that a messsage with some resources is rejected when there are no watches.
Verifies that a messsage with some resources is rejected when there are no watches.
Verifies that a messsage with some resources is rejected when there are no watches .
TEST_F(GrpcMuxImplTest, UnwatchedTypeRejectsResources) {
  setup();
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
  grpc_mux_->start();
  expectSendMessage(type_url, {"y"}, "");
  expectSendMessage(type_url, {}, "");
  grpc_mux_->subscribe(type_url, {"y"}, callbacks_);
  std::unique_ptr<envoy::api::v2::DiscoveryResponse> response(
      new envoy::api::v2::DiscoveryResponse());
  response->set_nonce("bar");
  response->set_version_info("1");
  response->set_type_url(type_url);
  envoy::api::v2::ClusterLoadAssignment load_assignment;
  load_assignment.set_cluster_name("x");
  response->add_resources()->PackFrom(load_assignment);
  expectSendMessage(type_url, {}, "", "bar");
  EXPECT_LOG_CONTAINS("warning", "Ignoring unwatched type URL " + type_url,
                      grpc_mux_->onReceiveMessage(std::move(response)));
}
TEST_F ( GrpcMuxImplTest , UnwatchedTypeRejectsResources ) { setup ( ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; const std :: string & type_url = Config :: TypeUrl :: get ( ) . ClusterLoadAssignment ; grpc_mux_ -> start ( ) ; expectSendMessage ( type_url , { " " } , " " ) ; expectSendMessage ( type_url , { } , " " ) ; grpc_mux_ -> subscribe ( type_url , { " " } , callbacks_ ) ; std :: unique_ptr < envoy :: api :: v2 :: DiscoveryResponse > response ( new envoy :: api :: v2 :: DiscoveryResponse ( ) ) ; response -> set_nonce ( " " ) ; response -> set_version_info ( " " ) ; response -> set_type_url ( type_url ) ; envoy :: api :: v2 :: ClusterLoadAssignment load_assignment ; load_assignment . set_cluster_name ( " " ) ; response -> add_resources ( ) -> PackFrom ( load_assignment ) ; expectSendMessage ( type_url , { } , " " , " " ) ; EXPECT_LOG_CONTAINS ( " " , " " + type_url , grpc_mux_ -> onReceiveMessage ( std :: move ( response ) ) ) ; }
Verifies that a messsage with some resources is rejected when there are no watches.
Verifies that a messsage with some resources is rejected when there are no watches .
// subscribe and unsubscribe (by not keeping the return watch) so that the type is known to envoy // simulate the server sending CLA message to notify envoy that the CLA was added, // even though envoy doesn't expect it. Envoy should reject this update. // The message should be rejected.