mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Add Admin command from listing and disconnecting connections (Only lists Github for now). * Require connectionManager permissions to manipulate connections Gives connection management its own config section and switches AdminRoom categories to be enums. * Fail more descriptively if connectionManager is not up in time for adminRoom * Fix Github API URLs (#366) * Fix Github API URLs * Add changelog entry * Fixes * Tidyup Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> * Fix URLs *again* * Block private repos from being publically bridged * Ensure check looks at service type * Finish up deleting connections impl Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> Co-authored-by: Will Hunt <will@half-shot.uk>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 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/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();
|
|
if (!data.admin_user) {
|
|
data.admin_user = "@admin:bar";
|
|
}
|
|
const tokenStore = new UserTokenStore("notapath", intent, DefaultConfig);
|
|
return [new AdminRoom(ROOM_ID, data, NotifFilter.getDefaultContent(), intent, tokenStore, 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"]),
|
|
});
|
|
});
|
|
}) |