From 77779d15c573f11ffcef53aadd2a2fbae37f2ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sun, 23 Nov 2025 08:28:36 +0300 Subject: [PATCH] =?UTF-8?q?3/3=20=D1=82=D0=B5=D1=81=D1=82=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D1=80=D1=8B=D1=82=D1=8B=20=D1=84=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=D1=82=D1=83=D1=80=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- src/endpoints_handlers/AuthLoginExecutor.h | 4 ++-- src/endpoints_handlers/AuthLogoutExecutor.h | 4 ++-- src/endpoints_handlers/AuthRegistrationExecutor.h | 4 ++-- tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp | 2 +- tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp | 2 +- tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index da3171e..26610a6 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ - UseCase'ы по работе с личным кабинетом - Научиться поднимать базы данных под каждый тест - научиться Docker - docker-compose - а если тест что-то должен заполнить, то он заполняет в самом начале() - Возможно, сделать тесты на CI/CD - приоритет - низкий -- Заменить internal_server_error на bad_request и перепроверить коды ошибок -- Создание и удаление вспомогательных классов должно быть вынесено в фикстуру +- ~~Заменить internal_server_error на bad_request и перепроверить коды ошибок~~ +- ~~Создание и удаление вспомогательных классов должно быть вынесено в фикстуру~~ # UseCase'ы приложения: diff --git a/src/endpoints_handlers/AuthLoginExecutor.h b/src/endpoints_handlers/AuthLoginExecutor.h index d49e35e..47eef99 100644 --- a/src/endpoints_handlers/AuthLoginExecutor.h +++ b/src/endpoints_handlers/AuthLoginExecutor.h @@ -50,8 +50,8 @@ public: } catch (const system::system_error& err) { - BOOST_LOG_TRIVIAL(info) << "POST /api/v1/Auth/Login - Response 500: Cannot deserialize json"; - throw session_exception(http::status::internal_server_error, "Cannot deserialize json"); + BOOST_LOG_TRIVIAL(info) << "POST /api/v1/Auth/Login - Response 400: Cannot deserialize json"; + throw session_exception(http::status::bad_request, "Cannot deserialize json"); } diff --git a/src/endpoints_handlers/AuthLogoutExecutor.h b/src/endpoints_handlers/AuthLogoutExecutor.h index 152ce60..b78c2f9 100644 --- a/src/endpoints_handlers/AuthLogoutExecutor.h +++ b/src/endpoints_handlers/AuthLogoutExecutor.h @@ -43,8 +43,8 @@ public: } catch (const system::system_error& err) { - BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Logout - Response 500: Cannot deserialize json"; - throw session_exception(http::status::internal_server_error, "cannot deserialize json"s); + BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Logout - Response 400: Cannot deserialize json"; + throw session_exception(http::status::bad_request, "cannot deserialize json"s); } const std::string token = req_json.as_object().at("token").as_string().c_str(); diff --git a/src/endpoints_handlers/AuthRegistrationExecutor.h b/src/endpoints_handlers/AuthRegistrationExecutor.h index f659856..0153454 100644 --- a/src/endpoints_handlers/AuthRegistrationExecutor.h +++ b/src/endpoints_handlers/AuthRegistrationExecutor.h @@ -44,8 +44,8 @@ public: } catch (const system::system_error& err) { - BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Registration - Response 500: Cannot deserialize json"; - throw session_exception(http::status::internal_server_error, "Cannot deserialize json"); + BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Registration - Response 400: Cannot deserialize json"; + throw session_exception(http::status::bad_request, "Cannot deserialize json"); } const std::string login = req_json.as_object().at("login").as_string().c_str(); diff --git a/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp b/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp index bed4ef2..560ac7b 100644 --- a/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthLoginExecutor_TEST.cpp @@ -54,7 +54,7 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixt BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool { - return e.code == beast::http::status::internal_server_error; + return e.code == beast::http::status::bad_request; }); mysql_session->close(); diff --git a/tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp b/tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp index e1c958a..2a3d7b9 100644 --- a/tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp @@ -57,7 +57,7 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Find_User_Token, AuthFixtu BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool { - return e.code == beast::http::status::internal_server_error; + return e.code == beast::http::status::bad_request; }); mysql_session->close(); diff --git a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp index bc2e6ea..b916bc2 100644 --- a/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp +++ b/tests/endpoint_handlers/AuthRegistrationExecutor_TEST.cpp @@ -35,7 +35,7 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload, AuthFixtu BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool { - return e.code == beast::http::status::internal_server_error; + return e.code == beast::http::status::bad_request; }); }