diff --git a/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp b/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp index 3f59183..cd94142 100644 --- a/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp @@ -94,6 +94,40 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data) delete mysql_session; } +BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields) +{ + 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 auth_dao = make_shared(GetMySqlSession()); + auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao); + + Request req; + value req_body; + + req_body.emplace_object(); + + req_body.as_object().emplace("login"s, ""s); + req_body.as_object().emplace("password"s, ""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::unprocessable_entity; + }); + + mysql_session->close(); + delete mysql_session; +} + BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesful_Login) { auto& argv = boost::unit_test::framework::master_test_suite().argv;