2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-14 12:52:17 +00:00
Files
mysql/test/integration/connect.cpp
Ruben Perez 4c7ca0a1b4 Row reading reworks
- Removed distinction between row and owning_row
- Changed semantics for fetch_one to row& + bool
- Renamed all fetch_* fns to read_*
- Added row.clear()
2021-02-28 22:03:28 +01:00

49 lines
1.7 KiB
C++

//
// Copyright (c) 2019-2020 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "integration_test_common.hpp"
using namespace boost::mysql::test;
using boost::mysql::socket_connection;
using boost::mysql::errc;
using boost::mysql::error_code;
BOOST_AUTO_TEST_SUITE(test_connect)
BOOST_MYSQL_NETWORK_TEST(physical_and_handshake_ok, network_fixture, network_ssl_gen)
{
auto ep = get_endpoint<Stream>(endpoint_kind::localhost);
auto result = sample.net->connect(this->conn, ep, this->params);
result.validate_no_error();
// We are able to query
auto query_result = sample.net->query(this->conn, "SELECT 1");
query_result.validate_no_error();
query_result.value.read_all(); // discard any result
}
BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture, network_ssl_gen)
{
auto ep = get_endpoint<Stream>(endpoint_kind::inexistent);
auto result = sample.net->connect(this->conn, ep, this->params);
// depending on system and stream type, error code will be different
result.validate_any_error({"physical connect failed"});
BOOST_TEST(!this->conn.next_layer().is_open());
}
BOOST_MYSQL_NETWORK_TEST(physical_ok_handshake_error, network_fixture, network_ssl_gen)
{
auto ep = get_endpoint<Stream>(endpoint_kind::localhost);
this->set_credentials("integ_user", "bad_password");
auto result = sample.net->connect(this->conn, ep, this->params);
result.validate_error(errc::access_denied_error, {"access denied", "integ_user"});
BOOST_TEST(!this->conn.next_layer().is_open());
}
BOOST_AUTO_TEST_SUITE_END() // test_connect