generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
@@ -6,14 +6,18 @@
|
|||||||
|
|
||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "./../../src/endpoints_handlers/AuthRegistrationExecutor.h"
|
#include "./../../src/endpoints_handlers/AuthRegistrationExecutor.h"
|
||||||
#include "./../../src/DAO/MySQLUserDAO.h"
|
#include "./../../src/DAO/MySQLUserDAO.h"
|
||||||
#include "./../../src/db/mysql_connector.h"
|
#include "./../../src/db/mysql_connector.h"
|
||||||
#include "./../../src/exceptions/session_exception.h"
|
#include "./../../src/exceptions/session_exception.h"
|
||||||
|
#include "./../../src/helpers/helpers.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace uad;
|
using namespace uad;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
using namespace beast;
|
||||||
using namespace json;
|
using namespace json;
|
||||||
|
|
||||||
using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<beast::http::string_body,
|
using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<beast::http::string_body,
|
||||||
@@ -22,6 +26,8 @@ using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<beast::http::stri
|
|||||||
using Request = boost::beast::http::request<beast::http::string_body,
|
using Request = boost::beast::http::request<beast::http::string_body,
|
||||||
beast::http::basic_fields<std::allocator<char>>>;
|
beast::http::basic_fields<std::allocator<char>>>;
|
||||||
|
|
||||||
|
static const std::string kCreatedUserUUID = GenerateUUID();
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload)
|
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload)
|
||||||
{
|
{
|
||||||
auto& argv = boost::unit_test::framework::master_test_suite().argv;
|
auto& argv = boost::unit_test::framework::master_test_suite().argv;
|
||||||
@@ -79,3 +85,34 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data)
|
|||||||
mysql_session->close();
|
mysql_session->close();
|
||||||
delete mysql_session;
|
delete mysql_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login)
|
||||||
|
{
|
||||||
|
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 executor = RouteAuthRegistrationExecutor(GetMySqlSession(), user_dao);
|
||||||
|
|
||||||
|
Request req;
|
||||||
|
value req_body;
|
||||||
|
|
||||||
|
req_body.emplace_object();
|
||||||
|
|
||||||
|
req_body.as_object().emplace("login"s, "MyLogin12345678"s);
|
||||||
|
req_body.as_object().emplace("password"s, "Qwerty123456"s);
|
||||||
|
|
||||||
|
req.body() = serialize(req_body);
|
||||||
|
|
||||||
|
auto response = executor(std::move(req));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(response.result(), http::status::created);
|
||||||
|
|
||||||
|
mysql_session->close();
|
||||||
|
delete mysql_session;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user