Files
ThreadNet-Web/modules/restricted-guests/e2e/services.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-08-12 14:12:57 +01:00
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import {
2026-07-10 10:47:41 +01:00
type StartedSynapseContainer,
2025-08-12 14:12:57 +01:00
SynapseContainer,
} from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
2026-06-09 18:17:37 +01:00
import { Readable } from "node:stream";
import { GenericContainer, Wait } from "testcontainers";
2025-08-12 14:12:57 +01:00
// We use the SynapseContainer as a base to have all of its utilities for config setting
export class RestrictedGuestsSynapseContainer extends SynapseContainer {
protected getModuleConfig(): Record<string, unknown> {
return {};
}
2025-08-12 14:12:57 +01:00
public override async start(): Promise<StartedSynapseContainer> {
2026-06-09 18:17:37 +01:00
// Download the synapse module
const initContainer = await new GenericContainer("ghcr.io/element-hq/synapse-guest-module:861f7ee")
.withWaitStrategy(Wait.forOneShotStartup())
.start();
const tarStream = await initContainer.copyArchiveFromContainer(`/src/synapse_guest_module`);
await initContainer.stop();
this.withCopyArchivesToContainer([
2025-08-12 14:12:57 +01:00
{
2026-06-09 18:17:37 +01:00
tar: Readable.from(tarStream),
target: "/",
2025-08-12 14:12:57 +01:00
},
]).withEnvironment({
PYTHONPATH: "/modules",
});
2026-06-09 18:17:37 +01:00
2025-08-12 14:12:57 +01:00
this.config.modules.push({
module: "synapse_guest_module.GuestModule",
config: this.getModuleConfig(),
2025-08-12 14:12:57 +01:00
});
return super.start();
}
}
2026-03-02 13:08:52 +00:00
interface RestrictedGuestsMasModuleConfig {
adminApiBaseUrl: string;
oauthBaseUrl?: string;
clientId: string;
clientSecret: string;
}
export class RestrictedGuestsSynapseWithMasContainer extends RestrictedGuestsSynapseContainer {
public constructor(private readonly masConfig: RestrictedGuestsMasModuleConfig) {
super();
}
protected override getModuleConfig(): Record<string, unknown> {
return {
mas: {
admin_api_base_url: this.masConfig.adminApiBaseUrl,
oauth_base_url: this.masConfig.oauthBaseUrl ?? this.masConfig.adminApiBaseUrl,
client_id: this.masConfig.clientId,
client_secret: this.masConfig.clientSecret,
},
};
}
}