From 26a5389d2b0fcc9dece2344895e9ac88a380746b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sat, 25 Oct 2025 07:27:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=B8=D0=BD=D1=82=D0=B5=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthRegistrationExecutor_TEST.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp index 97b0c40..6bd93d4 100644 --- a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp @@ -6,14 +6,18 @@ #include +#include + #include "./../../src/endpoints_handlers/AuthRegistrationExecutor.h" #include "./../../src/DAO/MySQLUserDAO.h" #include "./../../src/db/mysql_connector.h" #include "./../../src/exceptions/session_exception.h" +#include "./../../src/helpers/helpers.h" using namespace std; using namespace uad; using namespace boost; +using namespace beast; using namespace json; using RouteAuthRegistrationExecutor = AuthRegistrationExecutor>>; +static const std::string kCreatedUserUUID = GenerateUUID(); + BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload) { 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(); 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(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; +}