Wire up basics of dendriteHomeserver
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/28860/head
parent
fd447324b5
commit
0410574b20
|
@ -6,39 +6,32 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
|||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
// export const dendriteHomeserver: Fixtures<BaseFixtures, {}, BaseFixtures> & Fixtures<Services, {}, Services> = {
|
||||
// _homeserver: async ({ request }, use) => {
|
||||
// const container = new SynapseContainer(request);
|
||||
// await use(container);
|
||||
//
|
||||
// container.withConfig({
|
||||
// oidc_providers: [
|
||||
// {
|
||||
// idp_id: "test",
|
||||
// idp_name: "OAuth test",
|
||||
// issuer: `http://localhost:${port}/oauth`,
|
||||
// authorization_endpoint: `http://localhost:${port}/oauth/auth.html`,
|
||||
// // the token endpoint receives requests from synapse,
|
||||
// // rather than the webapp, so needs to escape the docker container.
|
||||
// token_endpoint: `http://host.testcontainers.internal:${port}/oauth/token`,
|
||||
// userinfo_endpoint: `http://host.testcontainers.internal:${port}/oauth/userinfo`,
|
||||
// client_id: "synapse",
|
||||
// discover: false,
|
||||
// scopes: ["profile"],
|
||||
// skip_verification: true,
|
||||
// client_auth_method: "none",
|
||||
// user_mapping_provider: {
|
||||
// config: {
|
||||
// display_name_template: "{{ user.name }}",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
// await use(container);
|
||||
// server.stop();
|
||||
// },
|
||||
// };
|
||||
import { Fixtures, PlaywrightTestArgs } from "@playwright/test";
|
||||
|
||||
import { Fixtures as BaseFixtures } from "../../../element-web-test.ts";
|
||||
import { DendriteContainer, PineconeContainer } from "../../../testcontainers/dendrite.ts";
|
||||
import { Services } from "../../../services.ts";
|
||||
|
||||
type Fixture = PlaywrightTestArgs & Services & BaseFixtures;
|
||||
export const dendriteHomeserver: Fixtures<Fixture, {}, Fixture> = {
|
||||
_homeserver: async ({ request }, use) => {
|
||||
const container =
|
||||
process.env["PLAYWRIGHT_HOMESERVER"] === "dendrite"
|
||||
? new DendriteContainer(request)
|
||||
: new PineconeContainer(request);
|
||||
await use(container);
|
||||
},
|
||||
homeserver: async ({ logger, network, _homeserver: homeserver }, use) => {
|
||||
const container = await homeserver
|
||||
.withNetwork(network)
|
||||
.withNetworkAliases("homeserver")
|
||||
.withLogConsumer(logger.getConsumer("dendrite"))
|
||||
.start();
|
||||
|
||||
await use(container);
|
||||
await container.stop();
|
||||
},
|
||||
};
|
||||
|
||||
export function isDendrite(): boolean {
|
||||
return process.env["PLAYWRIGHT_HOMESERVER"] === "dendrite" || process.env["PLAYWRIGHT_HOMESERVER"] === "pinecone";
|
||||
|
|
|
@ -10,9 +10,10 @@ import mailhog from "mailhog";
|
|||
import { GenericContainer, Network, StartedNetwork, StartedTestContainer, Wait } from "testcontainers";
|
||||
import { PostgreSqlContainer, StartedPostgreSqlContainer } from "@testcontainers/postgresql";
|
||||
|
||||
import { StartedSynapseContainer, SynapseConfigOptions, SynapseContainer } from "./testcontainers/synapse.ts";
|
||||
import { SynapseConfigOptions, SynapseContainer } from "./testcontainers/synapse.ts";
|
||||
import { ContainerLogger } from "./testcontainers/utils.ts";
|
||||
import { StartedMatrixAuthenticationServiceContainer } from "./testcontainers/mas.ts";
|
||||
import { HomeserverContainer, StartedHomeserverContainer } from "./testcontainers/HomeserverContainer.ts";
|
||||
|
||||
export interface Services {
|
||||
logger: ContainerLogger;
|
||||
|
@ -24,8 +25,8 @@ export interface Services {
|
|||
mailhogClient: mailhog.API;
|
||||
|
||||
synapseConfigOptions: SynapseConfigOptions;
|
||||
_homeserver: SynapseContainer;
|
||||
homeserver: StartedSynapseContainer;
|
||||
_homeserver: HomeserverContainer<any>;
|
||||
homeserver: StartedHomeserverContainer;
|
||||
mas?: StartedMatrixAuthenticationServiceContainer;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { AbstractStartedContainer, GenericContainer } from "testcontainers";
|
||||
|
||||
import { StartedSynapseContainer } from "./synapse.ts";
|
||||
import { HomeserverInstance } from "../plugins/homeserver";
|
||||
|
||||
export interface HomeserverContainer<Config> extends GenericContainer {
|
||||
withConfigField(key: string, value: any): this;
|
||||
withConfig(config: Partial<Config>): this;
|
||||
start(): Promise<StartedSynapseContainer>;
|
||||
}
|
||||
|
||||
export interface StartedHomeserverContainer extends AbstractStartedContainer, HomeserverInstance {}
|
|
@ -13,6 +13,7 @@ import { set } from "lodash";
|
|||
import { randB64Bytes } from "../plugins/utils/rand.ts";
|
||||
import { StartedSynapseContainer } from "./synapse.ts";
|
||||
import { deepCopy } from "../plugins/utils/object.ts";
|
||||
import { HomeserverContainer } from "./HomeserverContainer.ts";
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
version: 2,
|
||||
|
@ -204,7 +205,7 @@ const DEFAULT_CONFIG = {
|
|||
],
|
||||
};
|
||||
|
||||
export class DendriteContainer extends GenericContainer {
|
||||
export class DendriteContainer extends GenericContainer implements HomeserverContainer<typeof DEFAULT_CONFIG> {
|
||||
private config: typeof DEFAULT_CONFIG;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -13,8 +13,9 @@ import { set } from "lodash";
|
|||
|
||||
import { getFreePort } from "../plugins/utils/port.ts";
|
||||
import { randB64Bytes } from "../plugins/utils/rand.ts";
|
||||
import { Credentials, HomeserverInstance } from "../plugins/homeserver";
|
||||
import { Credentials } from "../plugins/homeserver";
|
||||
import { deepCopy } from "../plugins/utils/object.ts";
|
||||
import { HomeserverContainer, StartedHomeserverContainer } from "./HomeserverContainer.ts";
|
||||
|
||||
const TAG = "develop@sha256:17cc0a301447430624afb860276e5c13270ddeb99a3f6d1c6d519a20b1a8f650";
|
||||
|
||||
|
@ -137,7 +138,7 @@ const DEFAULT_CONFIG = {
|
|||
|
||||
export type SynapseConfigOptions = Partial<typeof DEFAULT_CONFIG>;
|
||||
|
||||
export class SynapseContainer extends GenericContainer {
|
||||
export class SynapseContainer extends GenericContainer implements HomeserverContainer<typeof DEFAULT_CONFIG> {
|
||||
private config: typeof DEFAULT_CONFIG;
|
||||
|
||||
constructor(private readonly request: APIRequestContext) {
|
||||
|
@ -225,7 +226,7 @@ export class SynapseContainer extends GenericContainer {
|
|||
}
|
||||
}
|
||||
|
||||
export class StartedSynapseContainer extends AbstractStartedContainer implements HomeserverInstance {
|
||||
export class StartedSynapseContainer extends AbstractStartedContainer implements StartedHomeserverContainer {
|
||||
private adminToken?: string;
|
||||
|
||||
constructor(
|
||||
|
|
Loading…
Reference in New Issue