TEST_F(ConnectionManagerUtilityTest, UseRemoteAddressWhenUserConfiguredRemoteAddress) {
  auto config = std::make_unique<NiceMock<MockInternalAddressConfig>>();
  ON_CALL(*config, isInternalAddress).WillByDefault(Return(true));
  config_.internal_address_config_ = std::move(config);

  Network::Address::Ipv4Instance local_address("10.3.2.1");
  ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(true));
  ON_CALL(config_, localAddress()).WillByDefault(ReturnRef(local_address));

  connection_.stream_info_.downstream_address_provider_->setRemoteAddress(
      std::make_shared<Network::Address::Ipv4Instance>("12.12.12.12"));

  TestRequestHeaderMapImpl headers;
  EXPECT_EQ((MutateRequestRet{"12.12.12.12:0", true, Tracing::Reason::NotTraceable}),
            callMutateRequestHeaders(headers, Protocol::Http2));
  EXPECT_EQ("12.12.12.12", headers.get_(Headers::get().ForwardedFor));
}
TEST_F(ConnectionManagerUtilityTest, UseRemoteAddressWhenUserConfiguredRemoteAddress) {
  auto config = std::make_unique<NiceMock<MockInternalAddressConfig>>();
  ON_CALL(*config, isInternalAddress).WillByDefault(Return(true));
  config_.internal_address_config_ = std::move(config);

  Network::Address::Ipv4Instance local_address("10.3.2.1");
  ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(true));
  ON_CALL(config_, localAddress()).WillByDefault(ReturnRef(local_address));

  connection_.stream_info_.downstream_address_provider_->setRemoteAddress(
      std::make_shared<Network::Address::Ipv4Instance>("12.12.12.12"));

  TestRequestHeaderMapImpl headers;
  EXPECT_EQ((MutateRequestRet{"12.12.12.12:0", true, Tracing::Reason::NotTraceable}),
            callMutateRequestHeaders(headers, Protocol::Http2));
  EXPECT_EQ("12.12.12.12", headers.get_(Headers::get().ForwardedFor));
}