Changeset View
Changeset View
Standalone View
Standalone View
src/tests/client/login-test.cpp
- This file was added.
| /* | |||||
| * This file is part of libkazv. | |||||
| * SPDX-FileCopyrightText: 2026 tusooa <tusooa@kazv.moe> | |||||
| * SPDX-License-Identifier: AGPL-3.0-or-later | |||||
| */ | |||||
| #include <libkazv-config.hpp> | |||||
| #include "client.hpp" | |||||
| #include "action-mock-utils.hpp" | |||||
| #include "client-test-util.hpp" | |||||
| #include "actions/auth.hpp" | |||||
| #include <catch2/catch_test_macros.hpp> | |||||
| using namespace Kazv; | |||||
| TEST_CASE("MLoginTokenLoginAction", "[client][login]") | |||||
| { | |||||
| auto [next, _] = updateClient(ClientModel{}, MLoginTokenLoginAction{"https://m.example.com", "some-token", std::nullopt}); | |||||
| assert1Job(next); | |||||
| for1stJob(next, [](const BaseJob &j) { | |||||
| auto url = j.url(); | |||||
| REQUIRE(url.find("/_matrix/client/v3/login") != std::string::npos); | |||||
| auto b = json::parse(std::get<BytesBody>(j.requestBody())); | |||||
| REQUIRE(b.at("type").template get<std::string>() == "m.login.token"); | |||||
| REQUIRE(b.at("token").template get<std::string>() == "some-token"); | |||||
| REQUIRE(!b.contains("identifier")); | |||||
| REQUIRE(!b.contains("password")); | |||||
| }); | |||||
| } | |||||