TEST_F(ConnectionManagerUtilityTest, NoPreserveExternalRequestIdEdgeRequestGenerateRequestId) {
  ON_CALL(config_, preserveExternalRequestId()).WillByDefault(Return(false));
  connection_.stream_info_.downstream_address_provider_->setRemoteAddress(
      std::make_shared<Network::Address::Ipv4Instance>("134.2.2.11"));

  // with request id
  {
    ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(true));
    TestRequestHeaderMapImpl headers{{"x-forwarded-for", "198.51.100.1"},
                                     {"x-request-id", "my-request-id"}};
    EXPECT_CALL(*request_id_extension_, set(testing::Ref(headers), true));
    EXPECT_CALL(*request_id_extension_, set(_, false)).Times(0);
    EXPECT_EQ((MutateRequestRet{"134.2.2.11:0", false, Tracing::Reason::NotTraceable}),
              callMutateRequestHeaders(headers, Protocol::Http2));
    EXPECT_EQ(random_.uuid_, headers.get_(Headers::get().RequestId));
  }

  // with no request id
  {
    TestRequestHeaderMapImpl headers{{"x-forwarded-for", "198.51.100.1"}};
    EXPECT_CALL(*request_id_extension_, set(testing::Ref(headers), true));
    EXPECT_CALL(*request_id_extension_, set(_, false)).Times(0);
    EXPECT_EQ((MutateRequestRet{"134.2.2.11:0", false, Tracing::Reason::NotTraceable}),
              callMutateRequestHeaders(headers, Protocol::Http2));
    EXPECT_EQ(random_.uuid_, headers.get_(Headers::get().RequestId));
  }
}
TEST_F(ConnectionManagerUtilityTest, NoPreserveExternalRequestIdEdgeRequestGenerateRequestId) {
  ON_CALL(config_, preserveExternalRequestId()).WillByDefault(Return(false));
  connection_.stream_info_.downstream_address_provider_->setRemoteAddress(
      std::make_shared<Network::Address::Ipv4Instance>("134.2.2.11"));

   
  {
    ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(true));
    TestRequestHeaderMapImpl headers{{"x-forwarded-for", "198.51.100.1"},
                                     {"x-request-id", "my-request-id"}};
    EXPECT_CALL(*request_id_extension_, set(testing::Ref(headers), true));
    EXPECT_CALL(*request_id_extension_, set(_, false)).Times(0);
    EXPECT_EQ((MutateRequestRet{"134.2.2.11:0", false, Tracing::Reason::NotTraceable}),
              callMutateRequestHeaders(headers, Protocol::Http2));
    EXPECT_EQ(random_.uuid_, headers.get_(Headers::get().RequestId));
  }

   
  {
    TestRequestHeaderMapImpl headers{{"x-forwarded-for", "198.51.100.1"}};
    EXPECT_CALL(*request_id_extension_, set(testing::Ref(headers), true));
    EXPECT_CALL(*request_id_extension_, set(_, false)).Times(0);
    EXPECT_EQ((MutateRequestRet{"134.2.2.11:0", false, Tracing::Reason::NotTraceable}),
              callMutateRequestHeaders(headers, Protocol::Http2));
    EXPECT_EQ(random_.uuid_, headers.get_(Headers::get().RequestId));
  }
}