-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for mode changes correctly applying to users. (#1732)
* Add powerlevel e2e test * Log failures properly * Log when we don't know a mode value * Set sensible mode defaults * Remove mistaken log line * Remove consistent return lint rule * changelog * update changelog * Improve userPrefixes check * Catch failures to kill redis * Don't call quit twice * Remove duplicate test * Fix unit test * Disable passkey enc * sneaky fix to stop logging pong timeouts erronously * Remove comment * Drop console line * Review tweaks * Fix changelog * Add a loop to check all power levels * Add ability to check for the right PL * Don't wait for charlie's matrix membership
- Loading branch information
Showing
12 changed files
with
160 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixes cases where powerlevel changes may not be correctly applied upon mode change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import { TestIrcServer } from "matrix-org-irc"; | ||
import { IrcBridgeE2ETest } from "../util/e2e-test"; | ||
import { describe, expect, it } from "@jest/globals"; | ||
import { PowerLevelContent } from "matrix-appservice-bridge"; | ||
|
||
|
||
describe('Ensure powerlevels are appropriately applied', () => { | ||
let testEnv: IrcBridgeE2ETest; | ||
beforeEach(async () => { | ||
testEnv = await IrcBridgeE2ETest.createTestEnv({ | ||
matrixLocalparts: ['alice'], | ||
ircNicks: ['bob', 'charlie'], | ||
}); | ||
await testEnv.setUp(); | ||
}); | ||
afterEach(() => { | ||
return testEnv?.tearDown(); | ||
}); | ||
it('should update powerlevel of IRC user when OPed by an IRC user', async () => { | ||
const channel = `#${TestIrcServer.generateUniqueNick("test")}`; | ||
const { homeserver } = testEnv; | ||
const alice = homeserver.users[0].client; | ||
const { bob, charlie } = testEnv.ircTest.clients; | ||
const bobUserId = `@irc_${bob.nick}:${homeserver.domain}`; | ||
const charlieUserId = `@irc_${charlie.nick}:${homeserver.domain}`; | ||
|
||
// Create the channel | ||
await bob.join(channel); | ||
|
||
const cRoomId = await testEnv.joinChannelHelper(alice, await testEnv.createAdminRoomHelper(alice), channel); | ||
|
||
// Now have charlie join and be opped. | ||
await charlie.join(channel); | ||
const operatorPL = testEnv.ircBridge.config.ircService.servers.localhost.modePowerMap!.o; | ||
const plEvent = alice.waitForPowerLevel( | ||
cRoomId, { | ||
users: { | ||
[charlieUserId]: operatorPL, | ||
[testEnv.ircBridge.appServiceUserId]: 100, | ||
[bobUserId]: operatorPL, | ||
}, | ||
} | ||
); | ||
|
||
await bob.send('MODE', channel, '+o', charlie.nick); | ||
await plEvent; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.