mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Appservice tests weren't added to tsconfig.json properly. (#440)
Some minor fixes now that they have been.
This commit is contained in:
parent
f52f17e381
commit
38b18cda4f
@ -88,12 +88,13 @@ export class MjolnirAppService {
|
|||||||
* @param config The parsed configuration file.
|
* @param config The parsed configuration file.
|
||||||
* @param registrationFilePath A path to their homeserver registration file.
|
* @param registrationFilePath A path to their homeserver registration file.
|
||||||
*/
|
*/
|
||||||
public static async run(port: number, config: IConfig, registrationFilePath: string) {
|
public static async run(port: number, config: IConfig, registrationFilePath: string): Promise<MjolnirAppService> {
|
||||||
const dataStore = new PgDataStore(config.db.connectionString);
|
const dataStore = new PgDataStore(config.db.connectionString);
|
||||||
await dataStore.init();
|
await dataStore.init();
|
||||||
const service = await MjolnirAppService.makeMjolnirAppService(config, dataStore, registrationFilePath);
|
const service = await MjolnirAppService.makeMjolnirAppService(config, dataStore, registrationFilePath);
|
||||||
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
|
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
|
||||||
await service.start(port);
|
await service.start(port);
|
||||||
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onUserQuery (queriedUser: MatrixUser) {
|
public onUserQuery (queriedUser: MatrixUser) {
|
||||||
|
@ -16,6 +16,7 @@ describe("Test that the app service can provision a mjolnir on invite of the app
|
|||||||
return this.appservice.close();
|
return this.appservice.close();
|
||||||
} else {
|
} else {
|
||||||
console.warn("Missing Appservice in this context, so cannot stop it.")
|
console.warn("Missing Appservice in this context, so cannot stop it.")
|
||||||
|
return Promise.resolve(); // TS7030: Not all code paths return a value.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {
|
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {
|
||||||
|
@ -20,6 +20,7 @@ describe("Test that the app service can provision a mjolnir when requested from
|
|||||||
return this.appservice.close();
|
return this.appservice.close();
|
||||||
} else {
|
} else {
|
||||||
console.warn("Missing Appservice in this context, so cannot stop it.")
|
console.warn("Missing Appservice in this context, so cannot stop it.")
|
||||||
|
return Promise.resolve(); // TS7030: Not all code paths return a value.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {
|
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {
|
||||||
|
@ -2,7 +2,6 @@ import path from "path";
|
|||||||
import { MjolnirAppService } from "../../../src/appservice/AppService";
|
import { MjolnirAppService } from "../../../src/appservice/AppService";
|
||||||
import { ensureAliasedRoomExists } from "../../integration/mjolnirSetupUtils";
|
import { ensureAliasedRoomExists } from "../../integration/mjolnirSetupUtils";
|
||||||
import { read as configRead, IConfig } from "../../../src/appservice/config/config";
|
import { read as configRead, IConfig } from "../../../src/appservice/config/config";
|
||||||
import { PgDataStore } from "../../../src/appservice/datastore";
|
|
||||||
import { newTestUser } from "../../integration/clientHelper";
|
import { newTestUser } from "../../integration/clientHelper";
|
||||||
import PolicyList from "../../../src/models/PolicyList";
|
import PolicyList from "../../../src/models/PolicyList";
|
||||||
import { CreateEvent, MatrixClient } from "matrix-bot-sdk";
|
import { CreateEvent, MatrixClient } from "matrix-bot-sdk";
|
||||||
@ -15,11 +14,7 @@ export async function setupHarness(): Promise<MjolnirAppService> {
|
|||||||
const config = readTestConfig();
|
const config = readTestConfig();
|
||||||
const utilityUser = await newTestUser(config.homeserver.url, { name: { contains: "utility" }});
|
const utilityUser = await newTestUser(config.homeserver.url, { name: { contains: "utility" }});
|
||||||
await ensureAliasedRoomExists(utilityUser, config.accessControlList);
|
await ensureAliasedRoomExists(utilityUser, config.accessControlList);
|
||||||
const dataStore = new PgDataStore(config.db.connectionString);
|
return await MjolnirAppService.run(9000, config, "mjolnir-registration.yaml");
|
||||||
await dataStore.init();
|
|
||||||
const appservice = await MjolnirAppService.makeMjolnirAppService(config, dataStore, "mjolnir-registration.yaml");
|
|
||||||
await appservice.start(9000);
|
|
||||||
return appservice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> {
|
export async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> {
|
||||||
|
@ -21,7 +21,6 @@ export interface CreateMjolnirResponse {
|
|||||||
export class MjolnirWebAPIClient {
|
export class MjolnirWebAPIClient {
|
||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
private readonly matrixClient: MatrixClient,
|
|
||||||
private readonly openIDToken: string,
|
private readonly openIDToken: string,
|
||||||
private readonly baseURL: string,
|
private readonly baseURL: string,
|
||||||
) {
|
) {
|
||||||
@ -30,7 +29,7 @@ export class MjolnirWebAPIClient {
|
|||||||
|
|
||||||
public static async makeClient(client: MatrixClient, baseUrl: string): Promise<MjolnirWebAPIClient> {
|
public static async makeClient(client: MatrixClient, baseUrl: string): Promise<MjolnirWebAPIClient> {
|
||||||
const token = await getOpenIDToken(client);
|
const token = await getOpenIDToken(client);
|
||||||
return new MjolnirWebAPIClient(client, token, baseUrl);
|
return new MjolnirWebAPIClient(token, baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createMjolnir(roomToProtectId: string): Promise<CreateMjolnirResponse> {
|
public async createMjolnir(roomToProtectId: string): Promise<CreateMjolnirResponse> {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*",
|
"./src/**/*",
|
||||||
"./test/appservice/*",
|
"./test/appservice/**/*",
|
||||||
"./test/integration/manualLaunchScript.ts",
|
"./test/integration/manualLaunchScript.ts",
|
||||||
"./test/integration/roomMembersTest.ts",
|
"./test/integration/roomMembersTest.ts",
|
||||||
"./test/integration/banListTest.ts",
|
"./test/integration/banListTest.ts",
|
||||||
|
Loading…
Reference in New Issue
Block a user