Skip to content
Snippets Groups Projects

Add hard logout

Merged April Simone requested to merge logout into servant
+ 50
0
/*
* This file is part of libkazv.
* SPDX-FileCopyrightText: 2024 April Simone <apr3vau@outlook.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <libkazv-config.hpp>
#include <catch2/catch_all.hpp>
#include <boost/asio.hpp>
#include <asio-promise-handler.hpp>
#include <cursorutil.hpp>
#include <sdk-model.hpp>
#include <client/client.hpp>
#include "client-test-util.hpp"
#include "factory.hpp"
using namespace Kazv::Factory;
TEST_CASE("Send logout job", "[client][auth]")
{
ClientModel loggedInModel = makeClient({});
auto [resModel, dontCareEffect] = ClientModel::update(
loggedInModel, HardLogoutAction{});
assert1Job(resModel);
for1stJob(resModel, [] (const auto &job) {
REQUIRE(job.jobId() == "Logout");
REQUIRE(job.url() == "example.com/_matrix/client/v3/logout");
});
}
TEST_CASE("Process logout response", "[client][auth]")
{
boost::asio::io_context io;
AsioPromiseHandler ph{io.get_executor()};
auto store = createTestClientStore(ph);
WHEN("Success response")
{
auto succResponse = makeResponse("Logout");
store.dispatch(ProcessResponseAction{succResponse})
.then([&] (auto stat) {
REQUIRE(stat.success());
REQUIRE(store.reader().get().token == "");
});
}
io.run();
}
Loading