generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
@@ -106,6 +106,8 @@ add_executable(AuthLoginExecutorTests ./tests/endpoint_handlers/AuthLoginExecuto
|
||||
./src/helpers/helpers.cpp
|
||||
./src/DAO/MySQLUserDAO.h
|
||||
./src/DAO/MySQLUserDAO.cpp
|
||||
./src/DAO/MemoryAuthDAO.h
|
||||
./src/DAO/MemoryAuthDAO.cpp
|
||||
./src/db/mysql_connector.h
|
||||
./src/db/mysql_connector.cpp)
|
||||
target_link_libraries(AuthLoginExecutorTests PRIVATE Boost::boost
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./../../src/endpoints_handlers/AuthRegistrationExecutor.h"
|
||||
#include "./../../src/endpoints_handlers/AuthLoginExecutor.h"
|
||||
|
||||
#include "../../src/DAO/MemoryAuthDAO.h"
|
||||
#include "./../../src/DAO/MySQLUserDAO.h"
|
||||
#include "./../../src/db/mysql_connector.h"
|
||||
#include "./../../src/exceptions/session_exception.h"
|
||||
@@ -23,13 +25,37 @@ using namespace boost;
|
||||
using namespace beast;
|
||||
using namespace json;
|
||||
|
||||
using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<beast::http::string_body,
|
||||
std::allocator<char>,
|
||||
beast::http::string_body>;
|
||||
using RouteAuthLoginExecutor = AuthLoginExecutor<beast::http::string_body,
|
||||
std::allocator<char>,
|
||||
beast::http::string_body>;
|
||||
using Request = boost::beast::http::request<beast::http::string_body,
|
||||
beast::http::basic_fields<std::allocator<char>>>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data)
|
||||
{
|
||||
BOOST_CHECK(true == true);
|
||||
auto& argv = boost::unit_test::framework::master_test_suite().argv;
|
||||
|
||||
const std::string mysql_credentials = argv[1];
|
||||
|
||||
mysqlx::Session* mysql_session = new mysqlx::Session(mysql_credentials);
|
||||
|
||||
uad::SetMySqlSession(mysql_session);
|
||||
|
||||
auto user_dao = make_shared<MySQLUserDAO>(GetMySqlSession());
|
||||
auto auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
||||
auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao);
|
||||
|
||||
Request req;
|
||||
|
||||
req.body() = "{ \"login\": ABS3 }"s;
|
||||
req.content_length(req.body().size());
|
||||
|
||||
BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception,
|
||||
[](const session_exception& e) -> bool
|
||||
{
|
||||
return e.code == beast::http::status::internal_server_error;
|
||||
});
|
||||
|
||||
mysql_session->close();
|
||||
delete mysql_session;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user