TEST_F(RouterTest, RedirectRecords) {
  auto redirect_records = std::make_shared<Network::Win32RedirectRecords>();
  memcpy(redirect_records->buf_, reinterpret_cast<void*>(redirect_records_data_.data()),
         redirect_records_data_.size());
  redirect_records->buf_size_ = redirect_records_data_.size();
  router_.downstream_connection_.stream_info_.filterState()->setData(
      Network::UpstreamSocketOptionsFilterState::key(),
      std::make_unique<Network::UpstreamSocketOptionsFilterState>(),
      StreamInfo::FilterState::StateType::Mutable, StreamInfo::FilterState::LifeSpan::Connection);
  router_.downstream_connection_.stream_info_.filterState()
      ->getDataMutable<Network::UpstreamSocketOptionsFilterState>(
          Network::UpstreamSocketOptionsFilterState::key())
      .addOption(Network::SocketOptionFactory::buildWFPRedirectRecordsOptions(*redirect_records));
  Http::TestRequestHeaderMapImpl headers;
  HttpTestUtility::addDefaultHeaders(headers);
  headers.setMethod("CONNECT");
  router_.decodeHeaders(headers, false);

  Network::Socket::OptionsSharedPtr expected_options =
      Network::SocketOptionFactory::buildWFPRedirectRecordsOptions(*redirect_records);
  auto options = router_.upstreamSocketOptions();
  EXPECT_EQ(1, options->size());

  NiceMock<Network::MockConnectionSocket> dummy_socket;
  auto state = envoy::config::core::v3::SocketOption::STATE_PREBIND;
  auto expected_details = expected_options->at(0)->getOptionDetails(dummy_socket, state);
  auto returned_details = options->at(0)->getOptionDetails(dummy_socket, state);
  EXPECT_TRUE(expected_details == returned_details);
  router_.onDestroy();
}
TEST_F(RouterTest, RedirectRecords) {
  auto redirect_records = std::make_shared<Network::Win32RedirectRecords>();
  memcpy(redirect_records->buf_, reinterpret_cast<void*>(redirect_records_data_.data()),
         redirect_records_data_.size());
  redirect_records->buf_size_ = redirect_records_data_.size();
  router_.downstream_connection_.stream_info_.filterState()->setData(
      Network::UpstreamSocketOptionsFilterState::key(),
      std::make_unique<Network::UpstreamSocketOptionsFilterState>(),
      StreamInfo::FilterState::StateType::Mutable, StreamInfo::FilterState::LifeSpan::Connection);
  router_.downstream_connection_.stream_info_.filterState()
      ->getDataMutable<Network::UpstreamSocketOptionsFilterState>(
          Network::UpstreamSocketOptionsFilterState::key())
      .addOption(Network::SocketOptionFactory::buildWFPRedirectRecordsOptions(*redirect_records));
  Http::TestRequestHeaderMapImpl headers;
  HttpTestUtility::addDefaultHeaders(headers);
  headers.setMethod("CONNECT");
  router_.decodeHeaders(headers, false);

  Network::Socket::OptionsSharedPtr expected_options =
      Network::SocketOptionFactory::buildWFPRedirectRecordsOptions(*redirect_records);
  auto options = router_.upstreamSocketOptions();
  EXPECT_EQ(1, options->size());

  NiceMock<Network::MockConnectionSocket> dummy_socket;
  auto state = envoy::config::core::v3::SocketOption::STATE_PREBIND;
  auto expected_details = expected_options->at(0)->getOptionDetails(dummy_socket, state);
  auto returned_details = options->at(0)->getOptionDetails(dummy_socket, state);
  EXPECT_TRUE(expected_details == returned_details);
  router_.onDestroy();
}