Merge pull request #5466

55aae6a9 Fix socks tests in windows and handle errors better (Lee Clagett)
This commit is contained in:
Riccardo Spagni 2019-04-19 15:49:11 +02:00
commit 475481949a
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 13 additions and 7 deletions

View File

@ -546,7 +546,7 @@ namespace
connected(false)
{
acceptor.open(boost::asio::ip::tcp::v4());
acceptor.bind(stream_type::endpoint{boost::asio::ip::tcp::v4(), 0});
acceptor.bind(stream_type::endpoint{boost::asio::ip::address_v4::loopback(), 0});
acceptor.listen();
acceptor.async_accept(server, [this] (boost::system::error_code error) {
this->connected = true;
@ -621,7 +621,8 @@ TEST(socks_client, connect_command)
ASSERT_TRUE(test_client->set_connect_command("example.com", 8080));
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(std::move(test_client), io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(called);
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00,
@ -657,7 +658,8 @@ TEST(socks_client, connect_command_failed)
);
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(std::move(test_client), io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(called);
const std::uint8_t expected_bytes[] = {
4, 1, 0x0b, 0xb8, 0x00, 0x00, 0x13, 0x88, 0x00
@ -713,7 +715,8 @@ TEST(socks_client, resolve_command)
ASSERT_TRUE(test_client->set_resolve_command("example.com"));
EXPECT_FALSE(test_client->buffer().empty());
ASSERT_TRUE(net::socks::client::connect_and_send(test_client, io.acceptor.local_endpoint()));
while (!io.connected);
while (!io.connected)
ASSERT_EQ(0u, test_client->called_);
const std::uint8_t expected_bytes[] = {
4, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
@ -753,7 +756,8 @@ TEST(socks_connector, host)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("example.com", "8080", timeout);
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00,
'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', 0x00
@ -779,7 +783,8 @@ TEST(socks_connector, ipv4)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("250.88.125.99", "8080", timeout);
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0xfa, 0x58, 0x7d, 0x63, 0x00
};
@ -804,7 +809,8 @@ TEST(socks_connector, error)
boost::unique_future<boost::asio::ip::tcp::socket> sock =
net::socks::connector{io.acceptor.local_endpoint()}("250.88.125.99", "8080", timeout);
while (!io.connected);
while (!io.connected)
ASSERT_FALSE(sock.is_ready());
const std::uint8_t expected_bytes[] = {
4, 1, 0x1f, 0x90, 0xfa, 0x58, 0x7d, 0x63, 0x00
};