generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <regex>
|
||||
#include <boost/json.hpp>
|
||||
@@ -32,6 +33,8 @@ public:
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "POST /api/v1/Auth/Registration - Request";
|
||||
|
||||
const auto& body = req.body();
|
||||
value req_json;
|
||||
|
||||
@@ -41,7 +44,8 @@ public:
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
throw session_exception(http::status::bad_request, "cannot deserialize json");
|
||||
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");
|
||||
}
|
||||
|
||||
const std::string login = req_json.as_object().at("login").as_string().c_str();
|
||||
@@ -49,6 +53,7 @@ public:
|
||||
|
||||
if (!ValidateLogin(login) || !ValidatePassword(password))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Registration - Response 422: Validations failed. Login should have length from 3 to 50. Password from 5 characters length.";
|
||||
throw session_exception(
|
||||
http::status::unprocessable_entity,
|
||||
"Validations failed. Login should have length from 3 to 50. Password from 5 characters length."s
|
||||
@@ -57,7 +62,8 @@ public:
|
||||
|
||||
if (user_dao_->GetByLogin(login).has_value())
|
||||
{
|
||||
throw session_exception(http::status::conflict, "user with login "s + login + " exists"s);
|
||||
BOOST_LOG_TRIVIAL(error) << "POST /api/v1/Auth/Registration - Response 409: "s + "User with login "s + login + " exists"s;
|
||||
throw session_exception(http::status::conflict, "User with login "s + login + " exists"s);
|
||||
}
|
||||
|
||||
user user;
|
||||
|
||||
Reference in New Issue
Block a user