TEST_F(RouterTest, IpTransparentOptions) {
  Network::Socket::OptionsSharedPtr expected_options =
      Network::SocketOptionFactory::buildIpTransparentOptions();
  EXPECT_CALL(callbacks_, getUpstreamSocketOptions())
      .Times(1)
      .WillRepeatedly(Return(expected_options));

  Http::TestRequestHeaderMapImpl headers;
  HttpTestUtility::addDefaultHeaders(headers);
  headers.setMethod("CONNECT");
  router_.decodeHeaders(headers, false);

  auto options = router_.upstreamSocketOptions();
  EXPECT_EQ(expected_options->size(), options->size());

  for (size_t i = 0; i < 2; i++) {
    NiceMock<Network::MockConnectionSocket> dummy_socket;
    auto state = envoy::config::core::v3::SocketOption::STATE_PREBIND;
    auto expected_details = expected_options->at(i)->getOptionDetails(dummy_socket, state);
    auto returned_details = options->at(i)->getOptionDetails(dummy_socket, state);
    EXPECT_TRUE(expected_details == returned_details);
  }
  router_.onDestroy();
}
TEST_F(RouterTest, IpTransparentOptions) {
  Network::Socket::OptionsSharedPtr expected_options =
      Network::SocketOptionFactory::buildIpTransparentOptions();
  EXPECT_CALL(callbacks_, getUpstreamSocketOptions())
      .Times(1)
      .WillRepeatedly(Return(expected_options));

  Http::TestRequestHeaderMapImpl headers;
  HttpTestUtility::addDefaultHeaders(headers);
  headers.setMethod("CONNECT");
  router_.decodeHeaders(headers, false);

  auto options = router_.upstreamSocketOptions();
  EXPECT_EQ(expected_options->size(), options->size());

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