diff --git a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp index b51f9dc..97b0c40 100644 --- a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp @@ -14,6 +14,7 @@ using namespace std; using namespace uad; using namespace boost; +using namespace json; using RouteAuthRegistrationExecutor = AuthRegistrationExecutor, @@ -21,9 +22,8 @@ using RouteAuthRegistrationExecutor = AuthRegistrationExecutor>>; -BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesful_Login) +BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload) { - auto& args = boost::unit_test::framework::master_test_suite().argc; auto& argv = boost::unit_test::framework::master_test_suite().argv; const std::string mysql_credentials = argv[1]; @@ -44,7 +44,37 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesful_Login) return e.code == beast::http::status::internal_server_error; }); - BOOST_CHECK(true == true); + mysql_session->close(); + delete mysql_session; +} + +BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data) +{ + 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, "wq"); + req_body.as_object().emplace("password"s, "Qw"); + + 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::unprocessable_entity; + }); mysql_session->close(); delete mysql_session;