2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-14 12:52:17 +00:00
Files
mysql/test/integration/handshake.cpp

77 lines
1.8 KiB
C++

/*
* handshake.cpp
*
* Created on: Oct 22, 2019
* Author: ruben
*/
#include "mysql/connection.hpp"
#include "integration_test_common.hpp"
#include "test_common.hpp"
#include <boost/asio/use_future.hpp>
namespace net = boost::asio;
using namespace testing;
using namespace mysql::test;
using mysql::detail::make_error_code;
using mysql::error_info;
using mysql::Error;
namespace
{
struct HandshakeTest : public NetworkTest<IntegTest>
{
auto do_handshake() { return GetParam()->handshake(conn, connection_params); }
};
TEST_P(HandshakeTest, FastAuthSuccessfulLogin)
{
auto result = do_handshake();
result.validate_no_error();
}
// TODO: review failure in Mac
/*TEST_P(HandshakeTest, FastAuthSuccessfulLoginEmptyPassword)
{
connection_params.username = "empty_password_user";
connection_params.password = "";
auto result = do_handshake();
result.validate_no_error();
}*/
TEST_P(HandshakeTest, FastAuthSuccessfulLoginNoDatabase)
{
connection_params.database = "";
auto result = do_handshake();
result.validate_no_error();
}
TEST_P(HandshakeTest, FastAuthBadUser)
{
connection_params.username = "non_existing_user";
auto result = do_handshake();
EXPECT_NE(result.err, mysql::error_code());
// TODO: if default auth plugin is unknown, unknown auth plugin is returned instead of access denied
// EXPECT_EQ(errc, make_error_code(mysql::Error::access_denied_error));
}
TEST_P(HandshakeTest, FastAuthBadPassword)
{
connection_params.password = "bad_password";
auto result = do_handshake();
result.validate_error(mysql::Error::access_denied_error, {"access denied", "integ_user"});
}
TEST_P(HandshakeTest, FastAuthBadDatabase)
{
connection_params.database = "bad_database";
auto result = do_handshake();
result.validate_error(mysql::Error::bad_db_error, {"unknown database", "bad_database"});
}
MYSQL_NETWORK_TEST_SUITE(HandshakeTest);
} // anon namespace