-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
matrix: Add room retention policy (#2040)
- Loading branch information
Showing
7 changed files
with
191 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { | ||
synapseStart, | ||
synapseStop, | ||
type SynapseInstance, | ||
registerUser, | ||
getJoinedRooms, | ||
getRoomMembers, | ||
getRoomRetentionPolicy, | ||
} from '../docker/synapse'; | ||
import { smtpStart, smtpStop } from '../docker/smtp4dev'; | ||
import { login, registerRealmUsers, setupUserSubscribed } from '../helpers'; | ||
|
||
import { | ||
appURL, | ||
startServer as startRealmServer, | ||
type IsolatedRealmServer, | ||
} from '../helpers/isolated-realm-server'; | ||
|
||
test.describe('Auth rooms', () => { | ||
let synapse: SynapseInstance; | ||
let realmServer: IsolatedRealmServer; | ||
let user: { accessToken: string }; | ||
|
||
test.beforeEach(async () => { | ||
// synapse defaults to 30s for beforeEach to finish, we need a bit more time | ||
// to safely start the realm | ||
test.setTimeout(120_000); | ||
synapse = await synapseStart({ | ||
template: 'test', | ||
}); | ||
await smtpStart(); | ||
|
||
await registerRealmUsers(synapse); | ||
realmServer = await startRealmServer(); | ||
|
||
user = await registerUser(synapse, 'user1', 'pass'); | ||
await setupUserSubscribed('@user1:localhost', realmServer); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await synapseStop(synapse.synapseId); | ||
await smtpStop(); | ||
await realmServer.stop(); | ||
}); | ||
|
||
test('auth rooms have a retention policy', async ({ page }) => { | ||
await login(page, 'user1', 'pass', { url: appURL }); | ||
|
||
let roomIds = await getJoinedRooms(user.accessToken); | ||
|
||
let roomIdToMembers = new Map<string, any>(); | ||
|
||
for (let room of roomIds) { | ||
let members = await getRoomMembers(room, user.accessToken); | ||
roomIdToMembers.set(room, members); | ||
} | ||
|
||
let realmUsers = ['@base_realm:localhost', '@test_realm:localhost']; | ||
|
||
let realmRoomIds = roomIds.filter((room) => | ||
realmUsers.some((user) => roomIdToMembers.get(room)?.joined[user]), | ||
); | ||
|
||
expect(realmRoomIds.length).toBe(realmUsers.length); | ||
|
||
for (let room of realmRoomIds) { | ||
let retentionPolicy = await getRoomRetentionPolicy( | ||
user.accessToken, | ||
room, | ||
); | ||
|
||
expect(retentionPolicy).toMatchObject({ | ||
max_lifetime: 60 * 60 * 1000, | ||
}); | ||
} | ||
}); | ||
}); |
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