generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
@@ -119,6 +119,27 @@ target_link_libraries(AuthLoginExecutorTests PRIVATE Boost::boost
|
|||||||
mysql::concpp)
|
mysql::concpp)
|
||||||
add_test(AuthLoginExecutorTests AuthLoginExecutorTests)
|
add_test(AuthLoginExecutorTests AuthLoginExecutorTests)
|
||||||
|
|
||||||
|
add_executable(AuthLogoutExecutorTests ./tests/endpoint_handlers/AuthLogoutExecutor_TEST.cpp
|
||||||
|
./src/endpoints_handlers/AuthRegistrationExecutor.h
|
||||||
|
./src/exceptions/session_exception.cpp
|
||||||
|
./src/exceptions/session_exception.h
|
||||||
|
./src/helpers/helpers.h
|
||||||
|
./src/helpers/helpers.cpp
|
||||||
|
./src/DAO/MySQLUserDAO.h
|
||||||
|
./src/DAO/MySQLUserDAO.cpp
|
||||||
|
./src/DAO/MemoryAuthDAO.h
|
||||||
|
./src/DAO/MemoryAuthDAO.cpp
|
||||||
|
./src/db/mysql_connector.h
|
||||||
|
./src/db/mysql_connector.cpp)
|
||||||
|
target_link_libraries(AuthLogoutExecutorTests PRIVATE Boost::boost
|
||||||
|
Boost::json
|
||||||
|
Boost::log
|
||||||
|
Boost::system
|
||||||
|
Boost::filesystem
|
||||||
|
Threads::Threads
|
||||||
|
mysql::concpp)
|
||||||
|
add_test(AuthLogoutExecutorTests AuthLogoutExecutorTests)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions(App PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
target_compile_definitions(App PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||||
target_compile_definitions(HelpersTests PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
target_compile_definitions(HelpersTests PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
#include <mysqlx/xdevapi.h>
|
#include <mysqlx/xdevapi.h>
|
||||||
#include <mysqlx/common/api.h>
|
|
||||||
#include <boost/uuid.hpp>
|
|
||||||
|
|
||||||
#include "IExecutor.h"
|
#include "IExecutor.h"
|
||||||
#include "../DAO/IUserDAO.h"
|
|
||||||
#include "../DAO/IAuthDAO.h"
|
#include "../DAO/IAuthDAO.h"
|
||||||
#include "../helpers/helpers.h"
|
#include "../exceptions/session_exception.h"
|
||||||
|
|
||||||
namespace uad
|
namespace uad
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#ifdef WIN32
|
||||||
|
#include <sdkddkver.h>
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOOST_TEST_MODULE AuthLoginExecutors
|
||||||
|
|
||||||
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "./../../src/endpoints_handlers/AuthLogoutExecutor.h"
|
||||||
|
|
||||||
|
#include "../../src/DAO/MemoryAuthDAO.h"
|
||||||
|
#include "./../../src/DAO/MySQLUserDAO.h"
|
||||||
|
#include "./../../src/db/mysql_connector.h"
|
||||||
|
#include "./../../src/exceptions/session_exception.h"
|
||||||
|
#include "./../../src/helpers/helpers.h"
|
||||||
|
|
||||||
|
const std::string kUUID = std::to_string(uad::Random());
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace uad;
|
||||||
|
using namespace boost;
|
||||||
|
using namespace beast;
|
||||||
|
using namespace json;
|
||||||
|
|
||||||
|
using RouteAuthLogoutExecutor = AuthLogoutExecutor<beast::http::string_body,
|
||||||
|
std::allocator<char>,
|
||||||
|
beast::http::string_body>;
|
||||||
|
using Request = boost::beast::http::request<beast::http::string_body,
|
||||||
|
beast::http::basic_fields<std::allocator<char>>>;
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Cant_Find_User_Token)
|
||||||
|
{
|
||||||
|
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 auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
||||||
|
auto executor = RouteAuthLogoutExecutor(GetMySqlSession(), auth_dao);
|
||||||
|
|
||||||
|
Request req;
|
||||||
|
value req_body;
|
||||||
|
|
||||||
|
req_body.emplace_object();
|
||||||
|
req_body.as_object().emplace("token", "1234567890");
|
||||||
|
|
||||||
|
req.body() = "{ \"token\": abcde }";
|
||||||
|
req.content_length(req.body().size());
|
||||||
|
|
||||||
|
BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception,
|
||||||
|
[](const session_exception& e) -> bool
|
||||||
|
{
|
||||||
|
return e.code == beast::http::status::internal_server_error;
|
||||||
|
});
|
||||||
|
|
||||||
|
mysql_session->close();
|
||||||
|
delete mysql_session;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user