Update references to a now non-existant IProtection in tests.

This commit is contained in:
gnuxie authored and Gnuxie committed 2023-03-24 18:57:25 +00:00
1 parent 81b0c9a20d
commit 492230d61d
17 files changed
+34 -31

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ import { CommandError, CommandResult } from "./interface-manager/Validation";
import { defineMatrixInterfaceAdaptor, MatrixContext, MatrixInterfaceAdaptor } from "./interface-manager/MatrixInterfaceAdaptor";
import { MatrixSendClient } from "../MatrixEmitter";
import { JSXFactory } from "./interface-manager/JSXFactory";
import { Protection } from "../protections/IProtection";
import { Protection } from "../protections/Protection";
import { tickCrossRenderer } from "./interface-manager/MatrixHelpRenderer";
import { renderMatrixAndSend } from "./interface-manager/DeadDocumentMatrix";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { Mjolnir } from "../Mjolnir";
import { LogService } from "matrix-bot-sdk";
import { JSXFactory } from "../commands/interface-manager/JSXFactory";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { NumberProtectionSetting } from "./ProtectionSettings";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, LogService } from "matrix-bot-sdk";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { DurationMSProtectionSetting, NumberProtectionSetting, StringSetProtectionSetting } from "./ProtectionSettings";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, UserID } from "matrix-bot-sdk";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, LogService } from "matrix-bot-sdk";
import { isTrueJoinEvent } from "../utils";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import {Protection} from "./IProtection";
import {Protection} from "./Protection";
import {Mjolnir} from "../Mjolnir";
import {NumberProtectionSetting} from "./ProtectionSettings";
import {LogLevel} from "matrix-bot-sdk";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, UserID } from "matrix-bot-sdk";
import { Permalinks } from "../commands/interface-manager/Permalinks";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, UserID } from "matrix-bot-sdk";
import { Permalinks } from "../commands/interface-manager/Permalinks";
File renamed without changes.
+1 -1
View File
@@ -26,7 +26,7 @@ limitations under the License.
*/
import { FirstMessageIsImage } from "./FirstMessageIsImage";
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { BasicFlooding } from "./BasicFlooding";
import { DetectFederationLag } from "./DetectFederationLag";
import { WordList } from "./WordList";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { MXIDListProtectionSetting, NumberProtectionSetting } from "./ProtectionSettings";
import { Mjolnir } from "../Mjolnir";
+1 -1
View File
@@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/
import { Protection } from "./IProtection";
import { Protection } from "./Protection";
import { ConsequenceBan, ConsequenceRedact } from "./consequence";
import { Mjolnir } from "../Mjolnir";
import { LogLevel, LogService } from "matrix-bot-sdk";
@@ -9,7 +9,7 @@ describe("Test: Accept Invites From Space", function() {
await client.start();
})
this.afterEach(async function () {
await client.stop();
await client?.stop();
})
it("Mjolnir should accept an invite from a user in a nominated Space", async function() {
this.timeout(20000);
@@ -17,7 +17,7 @@ describe("Test: Accept Invites From Space", function() {
const mjolnir: Mjolnir = this.mjolnir!;
const mjolnirUserId = await mjolnir.client.getUserId();
const space = await client.createSpace({
const space = await client!.createSpace({
name: "mjolnir space invite test",
invites: [mjolnirUserId],
isPublic: false
@@ -30,8 +30,8 @@ describe("Test: Accept Invites From Space", function() {
mjolnir.config.acceptInvitesFromSpace = space.roomId;
const promise = new Promise(async resolve => {
const newRoomId = await client.createRoom({ invite: [mjolnirUserId] });
client.on("room.event", (roomId, event) => {
const newRoomId = await client!.createRoom({ invite: [mjolnirUserId] });
client!.on("room.event", (roomId, event) => {
if (
roomId === newRoomId
&& event.type === "m.room.member"
+11 -6
View File
@@ -1,17 +1,18 @@
import { strict as assert } from "assert";
import { Protection } from "../../src/protections/IProtection";
import { MatrixClient } from "matrix-bot-sdk";
import { Protection } from "../../src/protections/Protection";
import { ProtectionSettingValidationError } from "../../src/protections/ProtectionSettings";
import { NumberProtectionSetting, StringProtectionSetting, StringListProtectionSetting } from "../../src/protections/ProtectionSettings";
import { newTestUser, noticeListener } from "./clientHelper";
describe("Test: Protection settings", function() {
let client;
let syncingUser: MatrixClient|undefined;
this.beforeEach(async function () {
client = await newTestUser(this.config.homeserverUrl, { name: { contains: "protection-settings" }});
await client.start();
syncingUser = await newTestUser(this.config.homeserverUrl, { name: { contains: "protection-settings" }});
await syncingUser.start();
})
this.afterEach(async function () {
await client.stop();
await syncingUser?.stop();
})
it("Mjolnir refuses to save invalid protection setting values", async function() {
this.timeout(20000);
@@ -55,6 +56,7 @@ describe("Test: Protection settings", function() {
});
it("Mjolnir responds to !set correctly", async function() {
this.timeout(20000);
const client = (assert.notEqual(undefined, syncingUser), syncingUser!);
await client.joinRoom(this.config.managementRoom);
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
@@ -80,6 +82,7 @@ describe("Test: Protection settings", function() {
});
it("Mjolnir adds a value to a list setting", async function() {
this.timeout(20000);
const client = (assert.notEqual(undefined, syncingUser), syncingUser!);
await client.joinRoom(this.config.managementRoom);
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
@@ -104,6 +107,7 @@ describe("Test: Protection settings", function() {
});
it("Mjolnir removes a value from a list setting", async function() {
this.timeout(20000);
const client = (assert.notEqual(undefined, syncingUser), syncingUser!);
await client.joinRoom(this.config.managementRoom);
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
@@ -129,6 +133,7 @@ describe("Test: Protection settings", function() {
});
it("Mjolnir will change a protection setting in-place", async function() {
this.timeout(20000);
const client = (assert.notEqual(undefined, syncingUser), syncingUser!);
await client.joinRoom(this.config.managementRoom);
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
@@ -141,7 +146,7 @@ describe("Test: Protection settings", function() {
let i = 0;
client.on('room.message', noticeListener(this.mjolnir.managementRoomId, (event) => {
if (event.content.body.includes("Changed d0sNrt.test ")) {
if (++i == 2) {
if (++i === 2) {
resolve(event);
}
}
+3 -3
View File
@@ -1,5 +1,5 @@
import { Mjolnir } from "../../src/Mjolnir";
import { IProtection } from "../../src/protections/IProtection";
import { Protection } from "../../src/protections/Protection";
import { newTestUser } from "./clientHelper";
describe("Test: Report polling", function() {
@@ -16,12 +16,12 @@ describe("Test: Report polling", function() {
const eventId = await client.sendMessage(protectedRoomId, {msgtype: "m.text", body: "uwNd3q"});
await new Promise(async resolve => {
await this.mjolnir.protectionManager.registerProtection(new class implements IProtection {
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
name = "jYvufI";
description = "A test protection";
settings = { };
handleEvent = async (mjolnir: Mjolnir, roomId: string, event: any) => { };
handleReport = (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
handleReport = async (mjolnir: Mjolnir, roomId: string, reporterId: string, event: any, reason?: string) => {
if (reason === "x5h1Je") {
resolve(null);
}
+4 -7
View File
@@ -1,9 +1,6 @@
import { strict as assert } from "assert";
import { Mjolnir } from "../../src/Mjolnir";
import { IProtection } from "../../src/protections/IProtection";
import { Protection } from "../../src/protections/Protection";
import { newTestUser, noticeListener } from "./clientHelper";
import { matrixClient, mjolnir } from "./mjolnirSetupUtils";
import { ConsequenceBan, ConsequenceRedact } from "../../src/protections/consequence";
describe("Test: standard consequences", function() {
@@ -27,7 +24,7 @@ describe("Test: standard consequences", function() {
await badUser.joinRoom(protectedRoomId);
await this.mjolnir.addProtectedRoom(protectedRoomId);
await this.mjolnir.protectionManager.registerProtection(new class implements IProtection {
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
name = "JY2TPN";
description = "A test protection";
settings = { };
@@ -71,7 +68,7 @@ describe("Test: standard consequences", function() {
await badUser.joinRoom(protectedRoomId);
await this.mjolnir.addProtectedRoom(protectedRoomId);
await this.mjolnir.protectionManager.registerProtection(new class implements IProtection {
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
name = "0LxMTy";
description = "A test protection";
settings = { };
@@ -118,7 +115,7 @@ describe("Test: standard consequences", function() {
await goodUser.joinRoom(protectedRoomId);
await this.mjolnir.addProtectedRoom(protectedRoomId);
await this.mjolnir.protectionManager.registerProtection(new class implements IProtection {
await this.mjolnir.protectionManager.registerProtection(new class extends Protection {
name = "95B1Cr";
description = "A test protection";
settings = { };
+1
View File
@@ -30,5 +30,6 @@
"./test/integration/banListTest.ts",
"./test/integration/reportPollingTest",
"./test/integration/policyConsumptionTest.ts",
"./test/integration/protectionSettingsTest.ts"
]
}