hookshot/tests/AdminRoomTest.ts
Will Hunt 6482c7ed55
Handle RSA token handling in Rust (#915)
* Split out queue and cache config

* Update usages of cache config,

* Update default

* Cleanup

* Make queue optional.

* config updates.

* changelog

* update spec config

* Update tests

* tweak import

* Update default config.

* fixup test

* Update config.sample.yml

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* Update encryption.md

Signed-off-by: Will Hunt <will@half-shot.uk>

* Clear up worker config

Signed-off-by: Will Hunt <will@half-shot.uk>

* Update src/config/Config.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* update helm config

* move UserTokenStore.ts

* Port all the imports to new path.

* Port RSA handling to rust.

* Add tests.

* linting

* lint rust

* Remove unwraps / panics

* fix build script

* Ensure we store and check with algorithm and key was used.

* quieten false deadcode warnings

* changelog

* fix test imports

* lazy mock out UTS

* Refactor so that UserTokenStore is initiated by the time Bridge is created.

* update defaults

* replace if with match

* Use the magic of ?

* fmt

---------

Signed-off-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2024-04-08 15:22:57 +01:00

31 lines
1.2 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
import { expect } from "chai";
import { AdminRoom } from "../src/AdminRoom";
import { DefaultConfig } from "../src/config/Defaults";
import { ConnectionManager } from "../src/ConnectionManager";
import { NotifFilter } from "../src/NotificationFilters";
import { UserTokenStore } from "../src/tokens/UserTokenStore";
import { IntentMock } from "./utils/IntentMock";
const ROOM_ID = "!foo:bar";
function createAdminRoom(data: any = {admin_user: "@admin:bar"}): [AdminRoom, IntentMock] {
const intent = IntentMock.create("@admin:bar");
if (!data.admin_user) {
data.admin_user = "@admin:bar";
}
return [new AdminRoom(ROOM_ID, data, NotifFilter.getDefaultContent(), intent, {} as UserTokenStore, DefaultConfig, {} as ConnectionManager), intent];
}
describe("AdminRoom", () => {
it("will present help text", async () => {
const [adminRoom, intent] = createAdminRoom();
await adminRoom.handleCommand("$foo:bar", "help");
expect(intent.sentEvents).to.have.lengthOf(1);
expect(intent.sentEvents[0]).to.deep.equal({
roomId: ROOM_ID,
content: AdminRoom.helpMessage(undefined, ["Github", "Gitlab", "Jira"]),
});
});
})