generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
+2
-1
@@ -3,7 +3,7 @@ project(UpAndDown)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
add_definitions(-D_WIN32_WINNT=0x0602)
|
||||||
if(POLICY CMP0167)
|
if(POLICY CMP0167)
|
||||||
cmake_policy(SET CMP0167 OLD)
|
cmake_policy(SET CMP0167 OLD)
|
||||||
endif()
|
endif()
|
||||||
@@ -48,6 +48,7 @@ add_executable(App ./src/main.cpp
|
|||||||
./src/DAO/MemoryAuthDAO.cpp
|
./src/DAO/MemoryAuthDAO.cpp
|
||||||
./src/DAO/MemoryAuthDAO.h
|
./src/DAO/MemoryAuthDAO.h
|
||||||
./src/endpoints_handlers/AuthLogoutExecutor.h
|
./src/endpoints_handlers/AuthLogoutExecutor.h
|
||||||
|
./src/endpoints_handlers/AuthLoginExecutor.h
|
||||||
./src/exceptions/session_exception.cpp
|
./src/exceptions/session_exception.cpp
|
||||||
./src/exceptions/session_exception.h
|
./src/exceptions/session_exception.h
|
||||||
src/log/Log.h
|
src/log/Log.h
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
#include "Listener.h"
|
|
||||||
|
|
||||||
namespace uad
|
|
||||||
{
|
|
||||||
Listener::Listener(boost::asio::io_context& ioc,
|
|
||||||
boost::asio::ip::tcp::endpoint endpoint,
|
|
||||||
const std::shared_ptr<const std::string>& doc_root)
|
|
||||||
: ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root)
|
|
||||||
{
|
|
||||||
beast::error_code ec;
|
|
||||||
|
|
||||||
acceptor_.open(endpoint.protocol(), ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
uad::Fail(ec, "open");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
acceptor_.set_option(net::socket_base::reuse_address(true), ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
uad::Fail(ec, "set_option");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
acceptor_.bind(endpoint, ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
uad::Fail(ec, "bind");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
acceptor_.listen(
|
|
||||||
net::socket_base::max_listen_connections, ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
uad::Fail(ec, "listen");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::Run()
|
|
||||||
{
|
|
||||||
DoAccept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::DoAccept()
|
|
||||||
{
|
|
||||||
acceptor_.async_accept(
|
|
||||||
net::make_strand(ioc_),
|
|
||||||
beast::bind_front_handler(
|
|
||||||
&Listener::OnAccept,
|
|
||||||
shared_from_this()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::OnAccept(beast::error_code ec, tcp::socket socket)
|
|
||||||
{
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
uad::Fail(ec, "accept");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::make_shared<uad::Session>(
|
|
||||||
std::move(socket),
|
|
||||||
doc_root_)->Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
DoAccept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#include <boost/beast/core.hpp>
|
|
||||||
#include <boost/beast/http.hpp>
|
|
||||||
#include <boost/beast/version.hpp>
|
|
||||||
#include <boost/asio/dispatch.hpp>
|
|
||||||
#include <boost/asio/strand.hpp>
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <functional>
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "helpers.h"
|
|
||||||
#include "Session.h"
|
|
||||||
|
|
||||||
namespace uad
|
|
||||||
{
|
|
||||||
namespace beast = boost::beast;
|
|
||||||
namespace http = beast::http;
|
|
||||||
namespace net = boost::asio;
|
|
||||||
using tcp = boost::asio::ip::tcp;
|
|
||||||
|
|
||||||
class Listener : public std::enable_shared_from_this<Listener>
|
|
||||||
{
|
|
||||||
net::io_context& ioc_;
|
|
||||||
tcp::acceptor acceptor_;
|
|
||||||
std::shared_ptr<std::string const> doc_root_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Listener(
|
|
||||||
net::io_context& ioc,
|
|
||||||
tcp::endpoint endpoint,
|
|
||||||
std::shared_ptr<std::string const> const& doc_root);
|
|
||||||
|
|
||||||
void Run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void DoAccept();
|
|
||||||
|
|
||||||
void OnAccept(beast::error_code ec, tcp::socket socket);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
#include <mysqlx/xdevapi.h>
|
#include <mysqlx/xdevapi.h>
|
||||||
#include <mysqlx/common/api.h>
|
#include <mysqlx/common/api.h>
|
||||||
#include <boost/uuid.hpp>
|
|
||||||
|
|
||||||
|
#include <boost/uuid.hpp>
|
||||||
#include "IExecutor.h"
|
#include "IExecutor.h"
|
||||||
#include "../DAO/IUserDAO.h"
|
#include "../DAO/IUserDAO.h"
|
||||||
#include "../DAO/IAuthDAO.h"
|
#include "../DAO/IAuthDAO.h"
|
||||||
@@ -38,6 +39,8 @@ public:
|
|||||||
using namespace boost::beast;
|
using namespace boost::beast;
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "POST /api/v1/Auth/Login - Request";
|
||||||
|
|
||||||
const auto body = req.body();
|
const auto body = req.body();
|
||||||
value req_json;
|
value req_json;
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -14,8 +14,9 @@ void InitLogs()
|
|||||||
logging::keywords::file_name = "app_%Y-%m-%d_%H-%M-%S.log",
|
logging::keywords::file_name = "app_%Y-%m-%d_%H-%M-%S.log",
|
||||||
logging::keywords::rotation_size = 10 * 1024 * 1024,
|
logging::keywords::rotation_size = 10 * 1024 * 1024,
|
||||||
logging::keywords::time_based_rotation =
|
logging::keywords::time_based_rotation =
|
||||||
logging::sinks::file::rotation_at_time_point(0, 0, 0),
|
logging::sinks::file::rotation_at_time_point(0, 0, 0),
|
||||||
logging::keywords::format = "[%TimeStamp%] [%Severity%]: %Message%"
|
logging::keywords::format = "[%TimeStamp%] [%Severity%]: %Message%"
|
||||||
);
|
);
|
||||||
|
logging::add_common_attributes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-5
@@ -1,10 +1,9 @@
|
|||||||
|
#include <boost/log/trivial.hpp>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <sdkddkver.h>
|
#include <sdkddkver.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
#include <boost/log/utility/setup/file.hpp>
|
|
||||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/asio/signal_set.hpp>
|
#include <boost/asio/signal_set.hpp>
|
||||||
#include <boost/beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
@@ -52,7 +51,6 @@ int main(int argc, char* argv[])
|
|||||||
InitLogs();
|
InitLogs();
|
||||||
|
|
||||||
// Добавление общих атрибутов (включая время)
|
// Добавление общих атрибутов (включая время)
|
||||||
logging::add_common_attributes();
|
|
||||||
|
|
||||||
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
||||||
|
|
||||||
@@ -63,7 +61,7 @@ int main(int argc, char* argv[])
|
|||||||
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
||||||
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Приложение запущено";
|
BOOST_LOG_TRIVIAL(info) << "Приложение запущено2";
|
||||||
|
|
||||||
std::vector<std::thread> v;
|
std::vector<std::thread> v;
|
||||||
v.reserve(threads - 1);
|
v.reserve(threads - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user