Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

/*
Copyright 2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import { type APIRequestContext } from "@playwright/test";
2025-02-05 13:25:06 +00:00
import { type KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
import { ClientServerApi } from "@element-hq/element-web-playwright-common/lib/utils/api.js";
2025-02-05 13:25:06 +00:00
import { type HomeserverInstance } from "../plugins/homeserver";
/**
* A small subset of the Client-Server API used to manipulate the state of the
* account on the homeserver independently of the client under test.
*/
2025-01-14 11:37:39 +00:00
export class TestClientServerAPI extends ClientServerApi {
public constructor(
2025-01-14 11:37:39 +00:00
request: APIRequestContext,
homeserver: HomeserverInstance,
private accessToken: string,
2025-01-14 11:37:39 +00:00
) {
super(homeserver.baseUrl);
this.setRequest(request);
}
public async getCurrentBackupInfo(): Promise<KeyBackupInfo | null> {
2025-01-14 11:37:39 +00:00
return this.request("GET", `/v3/room_keys/version`, this.accessToken);
}
/**
* Calls the API directly to delete the given backup version
* @param version The version to delete
*/
public async deleteBackupVersion(version: string): Promise<void> {
2025-01-14 11:37:39 +00:00
await this.request("DELETE", `/v3/room_keys/version/${version}`, this.accessToken);
}
}