generated from Sithas/conan_template
UseCase редактирования дня в дневнике
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
- Возможно, сделать тесты на CI/CD - приоритет - низкий
|
- Возможно, сделать тесты на CI/CD - приоритет - низкий
|
||||||
- ~~Заменить internal_server_error на bad_request и перепроверить коды ошибок~~
|
- ~~Заменить internal_server_error на bad_request и перепроверить коды ошибок~~
|
||||||
- ~~Создание и удаление вспомогательных классов должно быть вынесено в фикстуру~~
|
- ~~Создание и удаление вспомогательных классов должно быть вынесено в фикстуру~~
|
||||||
|
- К следующему занятию сделать ручку из кейса 3 + восстановить фикстуры из тестов
|
||||||
|
|
||||||
# UseCase'ы приложения:
|
# UseCase'ы приложения:
|
||||||
|
|
||||||
|
|||||||
@@ -34,20 +34,6 @@ using Request = boost::beast::http::request<beast::http::string_body,
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixture)
|
||||||
{
|
{
|
||||||
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<MySQLUserDAO>(GetMySqlSession());
|
|
||||||
auto auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
|
||||||
auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao);
|
|
||||||
|
|
||||||
Request req;
|
|
||||||
|
|
||||||
req.body() = "{ \"login\": ABS3 }"s;
|
req.body() = "{ \"login\": ABS3 }"s;
|
||||||
req.content_length(req.body().size());
|
req.content_length(req.body().size());
|
||||||
|
|
||||||
@@ -56,26 +42,10 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixt
|
|||||||
{
|
{
|
||||||
return e.code == beast::http::status::bad_request;
|
return e.code == beast::http::status::bad_request;
|
||||||
});
|
});
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture)
|
||||||
{
|
{
|
||||||
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<MySQLUserDAO>(GetMySqlSession());
|
|
||||||
auto auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
|
||||||
auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao);
|
|
||||||
|
|
||||||
Request req;
|
|
||||||
value req_body;
|
value req_body;
|
||||||
|
|
||||||
req_body.emplace_object();
|
req_body.emplace_object();
|
||||||
@@ -90,26 +60,10 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture
|
|||||||
{
|
{
|
||||||
return e.code == beast::http::status::forbidden;
|
return e.code == beast::http::status::forbidden;
|
||||||
});
|
});
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields, AuthFixture)
|
||||||
{
|
{
|
||||||
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<MySQLUserDAO>(GetMySqlSession());
|
|
||||||
auto auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
|
||||||
auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao);
|
|
||||||
|
|
||||||
Request req;
|
|
||||||
value req_body;
|
value req_body;
|
||||||
|
|
||||||
req_body.emplace_object();
|
req_body.emplace_object();
|
||||||
@@ -124,26 +78,10 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields, AuthFixture)
|
|||||||
{
|
{
|
||||||
return e.code == beast::http::status::unprocessable_entity;
|
return e.code == beast::http::status::unprocessable_entity;
|
||||||
});
|
});
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Login, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Login, AuthFixture)
|
||||||
{
|
{
|
||||||
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<MySQLUserDAO>(GetMySqlSession());
|
|
||||||
auto auth_dao = make_shared<MemoryAuthDAO>(GetMySqlSession());
|
|
||||||
auto executor = RouteAuthLoginExecutor(GetMySqlSession(), user_dao, auth_dao);
|
|
||||||
|
|
||||||
Request req;
|
|
||||||
value req_body;
|
value req_body;
|
||||||
|
|
||||||
user_dao->Create({""s, "MyLogin123456780"s + kUUID, HashPassword("Qwerty123456"s)});
|
user_dao->Create({""s, "MyLogin123456780"s + kUUID, HashPassword("Qwerty123456"s)});
|
||||||
@@ -162,7 +100,4 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Login, AuthFixture)
|
|||||||
auto response_body = parse(response.body());
|
auto response_body = parse(response.body());
|
||||||
|
|
||||||
BOOST_CHECK(response_body.as_object().count("token"s) == 1);
|
BOOST_CHECK(response_body.as_object().count("token"s) == 1);
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,18 +34,6 @@ using Request = boost::beast::http::request<beast::http::string_body,
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Find_User_Token, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Find_User_Token, AuthFixture)
|
||||||
{
|
{
|
||||||
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;
|
value req_body;
|
||||||
|
|
||||||
req_body.emplace_object();
|
req_body.emplace_object();
|
||||||
@@ -59,25 +47,10 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Find_User_Token, AuthFixtu
|
|||||||
{
|
{
|
||||||
return e.code == beast::http::status::bad_request;
|
return e.code == beast::http::status::bad_request;
|
||||||
});
|
});
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Revoke_Token, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Revoke_Token, AuthFixture)
|
||||||
{
|
{
|
||||||
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;
|
value req_body;
|
||||||
|
|
||||||
req_body.emplace_object();
|
req_body.emplace_object();
|
||||||
@@ -91,25 +64,10 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cant_Revoke_Token, AuthFixture)
|
|||||||
{
|
{
|
||||||
return e.code == beast::http::status::bad_request;
|
return e.code == beast::http::status::bad_request;
|
||||||
});
|
});
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Auth, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Auth, AuthFixture)
|
||||||
{
|
{
|
||||||
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;
|
value req_body;
|
||||||
|
|
||||||
auth_dao->Login("SomethingUser", "1234567890");
|
auth_dao->Login("SomethingUser", "1234567890");
|
||||||
@@ -123,7 +81,4 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Auth, AuthFixture)
|
|||||||
auto response = executor(std::move(req));
|
auto response = executor(std::move(req));
|
||||||
|
|
||||||
BOOST_CHECK(response.result() == http::status::ok);
|
BOOST_CHECK(response.result() == http::status::ok);
|
||||||
|
|
||||||
mysql_session->close();
|
|
||||||
delete mysql_session;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user