generated from Sithas/conan_template
AuthLogoutTest - 4 ok 0 fail
This commit is contained in:
@@ -28,20 +28,24 @@ using RouteAuthLoginExecutor = AuthLoginExecutor<beast::http::string_body,
|
|||||||
std::allocator<char>,
|
std::allocator<char>,
|
||||||
beast::http::string_body>;
|
beast::http::string_body>;
|
||||||
|
|
||||||
// BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Cannot_Serialize_JSON, AuthFixture)
|
||||||
// {
|
|
||||||
// req.body() = "{ \"login\": ABS3 }"s;
|
|
||||||
// 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::bad_request;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture<RouteAuthLoginExecutor>)
|
|
||||||
{
|
{
|
||||||
|
RouteAuthLoginExecutor executor(GetMySqlSession(), user_dao, auth_dao);
|
||||||
|
|
||||||
|
req.body() = "{ \"login\": ABS3 }"s;
|
||||||
|
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::bad_request;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture)
|
||||||
|
{
|
||||||
|
RouteAuthLoginExecutor executor(GetMySqlSession(), user_dao, auth_dao);
|
||||||
|
|
||||||
value req_body;
|
value req_body;
|
||||||
|
|
||||||
req_body.emplace_object();
|
req_body.emplace_object();
|
||||||
@@ -57,43 +61,47 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthFixture
|
|||||||
return e.code == beast::http::status::forbidden;
|
return e.code == beast::http::status::forbidden;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields, AuthFixture)
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Fields, AuthFixture)
|
||||||
// {
|
{
|
||||||
// value req_body;
|
RouteAuthLoginExecutor executor(GetMySqlSession(), user_dao, auth_dao);
|
||||||
//
|
|
||||||
// req_body.emplace_object();
|
value req_body;
|
||||||
//
|
|
||||||
// req_body.as_object().emplace("login"s, ""s);
|
req_body.emplace_object();
|
||||||
// req_body.as_object().emplace("password"s, ""s);
|
|
||||||
//
|
req_body.as_object().emplace("login"s, ""s);
|
||||||
// req.body() = serialize(req_body);
|
req_body.as_object().emplace("password"s, ""s);
|
||||||
//
|
|
||||||
// BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception,
|
req.body() = serialize(req_body);
|
||||||
// [](const session_exception& e) -> bool
|
|
||||||
// {
|
BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception,
|
||||||
// return e.code == beast::http::status::unprocessable_entity;
|
[](const session_exception& e) -> bool
|
||||||
// });
|
{
|
||||||
// }
|
return e.code == beast::http::status::unprocessable_entity;
|
||||||
//
|
});
|
||||||
// BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Login, AuthFixture)
|
}
|
||||||
// {
|
|
||||||
// value req_body;
|
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesful_Login, AuthFixture)
|
||||||
//
|
{
|
||||||
// user_dao->Create({""s, "MyLogin123456780"s + uuid, HashPassword("Qwerty123456"s)});
|
RouteAuthLoginExecutor executor(GetMySqlSession(), user_dao, auth_dao);
|
||||||
//
|
|
||||||
// req_body.emplace_object();
|
value req_body;
|
||||||
//
|
|
||||||
// req_body.as_object().emplace("login"s, "MyLogin123456780"s + uuid);
|
user_dao->Create({""s, "MyLogin123456780"s + uuid, HashPassword("Qwerty123456"s)});
|
||||||
// req_body.as_object().emplace("password"s, "Qwerty123456"s);
|
|
||||||
//
|
req_body.emplace_object();
|
||||||
// req.body() = serialize(req_body);
|
|
||||||
//
|
req_body.as_object().emplace("login"s, "MyLogin123456780"s + uuid);
|
||||||
// auto response = executor(std::move(req));
|
req_body.as_object().emplace("password"s, "Qwerty123456"s);
|
||||||
//
|
|
||||||
// BOOST_CHECK(response.result() == http::status::ok);
|
req.body() = serialize(req_body);
|
||||||
//
|
|
||||||
// auto response_body = parse(response.body());
|
auto response = executor(std::move(req));
|
||||||
//
|
|
||||||
// BOOST_CHECK(response_body.as_object().count("token"s) == 1);
|
BOOST_CHECK(response.result() == http::status::ok);
|
||||||
// }
|
|
||||||
|
auto response_body = parse(response.body());
|
||||||
|
|
||||||
|
BOOST_CHECK(response_body.as_object().count("token"s) == 1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user