diff --git a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp index 6bd93d4..68cc44c 100644 --- a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp @@ -26,8 +26,6 @@ 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; @@ -104,7 +102,7 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login) req_body.emplace_object(); - req_body.as_object().emplace("login"s, "MyLogin12345678"s); + req_body.as_object().emplace("login"s, "MyLogin123456780"); req_body.as_object().emplace("password"s, "Qwerty123456"s); req.body() = serialize(req_body); @@ -116,3 +114,35 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login) mysql_session->close(); delete mysql_session; } + +BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Unsuccesfull_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, "MyLogin123456780"); + req_body.as_object().emplace("password"s, "Qwerty123456"s); + + req.body() = serialize(req_body); + + BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool + { + return e.code == beast::http::status::conflict; + }); + + mysql_session->close(); + delete mysql_session; +}