Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/contrail-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@atmo-dev/contrail": "workspace:*",
"@atmo-dev/contrail-community": "workspace:*",
"pg": "^8.20.0"
},
"devDependencies": {
Expand Down
12 changes: 4 additions & 8 deletions apps/contrail-e2e/tests/community-delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import { describe, it, expect, beforeAll, afterAll } from "vitest";
import pg from "pg";
import type { Client } from "@atcute/client";
import "@atcute/atproto";
import { Contrail } from "@atmo-dev/contrail";
import { createHandler } from "@atmo-dev/contrail/server";
import { createPostgresDatabase } from "@atmo-dev/contrail/postgres";
import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
setupCommunityContrail,
createCaller,
login,
jsonOr,
Expand Down Expand Up @@ -66,14 +66,10 @@ describe("community.delete e2e (soft-delete + cascade, real DB)", () => {
cleanupSchema = iso.cleanup;
const db = createPostgresDatabase(pool);

const contrail = new Contrail({
...baseConfig,
const contrail = await setupCommunityContrail({
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
baseConfig,
spaceType: SPACE_TYPE,
community: {
serviceDid: CONTRAIL_SERVICE_DID,
masterKey: TEST_MASTER_KEY,
Expand Down
12 changes: 4 additions & 8 deletions apps/contrail-e2e/tests/community-invites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { describe, it, expect, beforeAll, afterAll } from "vitest";
import pg from "pg";
import type { Client } from "@atcute/client";
import "@atcute/atproto";
import { Contrail } from "@atmo-dev/contrail";
import { createHandler } from "@atmo-dev/contrail/server";
import { createPostgresDatabase } from "@atmo-dev/contrail/postgres";
import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
setupCommunityContrail,
createCaller,
login,
jsonOr,
Expand Down Expand Up @@ -80,14 +80,10 @@ describe("invite e2e (community + user-owned, real JWT)", () => {
cleanupSchema = iso.cleanup;
const db = createPostgresDatabase(pool);

const contrail = new Contrail({
...baseConfig,
const contrail = await setupCommunityContrail({
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
baseConfig,
spaceType: SPACE_TYPE,
community: {
serviceDid: CONTRAIL_SERVICE_DID,
masterKey: TEST_MASTER_KEY,
Expand Down
12 changes: 4 additions & 8 deletions apps/contrail-e2e/tests/community-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import { describe, it, expect, beforeAll, afterAll } from "vitest";
import pg from "pg";
import type { Client } from "@atcute/client";
import "@atcute/atproto";
import { Contrail } from "@atmo-dev/contrail";
import { createHandler } from "@atmo-dev/contrail/server";
import { createPostgresDatabase } from "@atmo-dev/contrail/postgres";
import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
setupCommunityContrail,
createCaller,
login,
jsonOr,
Expand Down Expand Up @@ -78,14 +78,10 @@ describe("community lifecycle (mint → grant → list → revoke, + gap probes)
cleanupSchema = iso.cleanup;
const db = createPostgresDatabase(pool);

const contrail = new Contrail({
...baseConfig,
const contrail = await setupCommunityContrail({
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
baseConfig,
spaceType: SPACE_TYPE,
community: {
serviceDid: CONTRAIL_SERVICE_DID,
masterKey: TEST_MASTER_KEY,
Expand Down
13 changes: 5 additions & 8 deletions apps/contrail-e2e/tests/community-publishing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import { describe, it, expect, beforeAll, afterAll } from "vitest";
import pg from "pg";
import type { Client } from "@atcute/client";
import "@atcute/atproto";
import { Contrail, runPersistent } from "@atmo-dev/contrail";
import { runPersistent } from "@atmo-dev/contrail";
import { createHandler } from "@atmo-dev/contrail/server";
import { createPostgresDatabase } from "@atmo-dev/contrail/postgres";
import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
setupCommunityContrail,
createCaller,
createAppPasswordFor,
devnetRewriteFetch,
Expand Down Expand Up @@ -85,14 +86,10 @@ describe("community publishing (proxy → PDS → Jetstream → index)", () => {
cleanupSchema = iso.cleanup;
const db = createPostgresDatabase(pool);

const contrail = new Contrail({
...baseConfig,
const contrail = await setupCommunityContrail({
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
baseConfig,
spaceType: SPACE_TYPE,
community: {
serviceDid: CONTRAIL_SERVICE_DID,
masterKey: TEST_MASTER_KEY,
Expand Down
58 changes: 58 additions & 0 deletions apps/contrail-e2e/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
PlcDidDocumentResolver,
} from "@atcute/identity-resolver";
import type { Did as AtDid, Nsid } from "@atcute/lexicons";
import { Contrail, generateAuthoritySigningKey, resolveConfig } from "@atmo-dev/contrail";
import type { ContrailConfig, Database, SpacesConfig } from "@atmo-dev/contrail";
import { createCommunityIntegration } from "@atmo-dev/contrail-community";

export type Did = `did:${string}:${string}`;

Expand Down Expand Up @@ -46,6 +49,61 @@ export function createDevnetResolver() {
});
}

/**
* Build a `spaces` config block in the post-PR30 split shape: authority owns
* ACL + credential signing, recordHost owns storage. Tests that previously
* passed the flat `{ type, serviceDid, resolver }` shape now get this — the
* config validator enforces the split, and `community` requires `authority`.
*
* Pass the `type` NSID for the kind of space (e.g. "rsvp.atmo.event.space").
* A fresh signing key is generated per call so credential issuance works in
* the auth tests without leaking key material across suites.
*/
export async function makeSpacesConfig(type: string): Promise<SpacesConfig> {
return {
authority: {
type,
serviceDid: CONTRAIL_SERVICE_DID,
signing: await generateAuthoritySigningKey(),
resolver: createDevnetResolver(),
},
recordHost: {},
};
}

/**
* Build a Contrail wired with a community integration. Post-PR30, community
* routes are not registered by passing a `community` config block alone — the
* caller must construct a `CommunityIntegration` from the resolved config and
* pass it as `communityIntegration` to the `Contrail` constructor (the same
* pattern `createApp({ community })` uses in the contrail-community unit
* tests).
*
* `community` is forwarded into the Contrail config so the integration can
* read `masterKey`, `fetch`, etc. through `config.community`.
*/
export async function setupCommunityContrail(opts: {
db: Database;
baseConfig: ContrailConfig;
spaceType: string;
community: Record<string, unknown>;
}): Promise<Contrail> {
const fullConfig: ContrailConfig = {
...opts.baseConfig,
spaces: await makeSpacesConfig(opts.spaceType),
community: opts.community,
};
const integration = createCommunityIntegration({
db: opts.db,
config: resolveConfig(fullConfig),
});
return new Contrail({
...fullConfig,
db: opts.db,
communityIntegration: integration,
});
}

/**
* Mint an atproto service-auth JWT via the PDS's getServiceAuth endpoint.
* Requires the client to already be authed for a user. Returns the raw JWT
Expand Down
8 changes: 2 additions & 6 deletions apps/contrail-e2e/tests/spaces-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
makeSpacesConfig,
mintServiceAuthJwt,
CONTRAIL_SERVICE_DID,
PDS_URL,
Expand Down Expand Up @@ -51,11 +51,7 @@ describe("spaces auth (devnet PDS JWT → Contrail verifier)", () => {
const contrail = new Contrail({
...baseConfig,
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
spaces: await makeSpacesConfig(SPACE_TYPE),
});
await contrail.init();
handle = createHandler(contrail);
Expand Down
8 changes: 2 additions & 6 deletions apps/contrail-e2e/tests/spaces-firehose-invisibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
makeSpacesConfig,
mintServiceAuthJwt,
CONTRAIL_SERVICE_DID,
PDS_URL,
Expand Down Expand Up @@ -57,11 +57,7 @@ describe("spaces firehose invisibility", () => {
const contrail = new Contrail({
...baseConfig,
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
spaces: await makeSpacesConfig(SPACE_TYPE),
});
await contrail.init();
handle = createHandler(contrail);
Expand Down
8 changes: 2 additions & 6 deletions apps/contrail-e2e/tests/spaces-table-isolation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { config as baseConfig } from "../config";
import {
createTestAccount,
createIsolatedSchema,
createDevnetResolver,
makeSpacesConfig,
mintServiceAuthJwt,
CONTRAIL_SERVICE_DID,
PDS_URL,
Expand Down Expand Up @@ -52,11 +52,7 @@ describe("spaces table isolation", () => {
const contrail = new Contrail({
...baseConfig,
db,
spaces: {
type: SPACE_TYPE,
serviceDid: CONTRAIL_SERVICE_DID,
resolver: createDevnetResolver(),
},
spaces: await makeSpacesConfig(SPACE_TYPE),
});
await contrail.init();
handle = createHandler(contrail);
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading