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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
}

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
writer: ['read', 'write'],
reader: ['read'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module(`realm-endpoints/${basename(__filename)}`, function (hooks) {
});

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
'*': ['read'],
},
Expand Down
16 changes: 4 additions & 12 deletions packages/realm-server/tests/realm-endpoints/directory-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { module, test } from 'qunit';
import type { Test, SuperTest } from 'supertest';
import { join, basename } from 'path';
import { dirSync, type DirResult } from 'tmp';
import { copySync } from 'fs-extra';
import { basename } from 'path';
import type { Realm } from '@cardstack/runtime-common';
import {
setupPermissionedRealmCached,
Expand All @@ -12,28 +10,21 @@ import {
import '@cardstack/runtime-common/helpers/code-equality-assertion';

module(`realm-endpoints/${basename(__filename)}`, function () {
module('Realm-specific Endpoints | GET directory path', function (hooks) {
module('Realm-specific Endpoints | GET directory path', function () {
let testRealm: Realm;
let request: SuperTest<Test>;
let dir: DirResult;

hooks.beforeEach(async function () {
dir = dirSync();
copySync(join(__dirname, '..', 'cards'), dir.name);
});

function onRealmSetup(args: {
testRealm: Realm;
request: SuperTest<Test>;
dir: DirResult;
}) {
testRealm = args.testRealm;
request = args.request;
dir = args.dir;
}

module('public readable realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
'*': ['read'],
},
Expand Down Expand Up @@ -102,6 +93,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('permissioned realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
john: ['read'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down
16 changes: 5 additions & 11 deletions packages/realm-server/tests/realm-endpoints/info-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { module, test } from 'qunit';
import type { Test, SuperTest } from 'supertest';
import { join, basename } from 'path';
import { basename } from 'path';
import type { Server } from 'http';
import { dirSync, type DirResult } from 'tmp';
import { copySync } from 'fs-extra';
import type { Realm } from '@cardstack/runtime-common';
import {
setupPermissionedRealmCached,
Expand All @@ -21,32 +19,25 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
let testRealm: Realm;
let testRealmHttpServer: Server;
let request: SuperTest<Test>;
let dir: DirResult;

function onRealmSetup(args: {
testRealm: Realm;
testRealmHttpServer: Server;
request: SuperTest<Test>;
dir: DirResult;
}) {
testRealm = args.testRealm;
testRealmHttpServer = args.testRealmHttpServer;
request = args.request;
dir = args.dir;
}

hooks.beforeEach(async function () {
dir = dirSync();
copySync(join(__dirname, '..', 'cards'), dir.name);
});

hooks.afterEach(async function () {
await closeServer(testRealmHttpServer);
resetCatalogRealms();
});

module('public readable realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
'*': ['read'],
},
Expand Down Expand Up @@ -91,6 +82,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('permissioned realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
'@node-test_realm:localhost': ['read', 'realm-owner'],
},
Expand Down Expand Up @@ -163,6 +155,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
'shared realm because there is `users` permission',
function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
users: ['read'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down Expand Up @@ -204,6 +197,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('shared realm because there are multiple users', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
bob: ['read'],
jane: ['read'],
Expand Down
1 change: 1 addition & 0 deletions packages/realm-server/tests/realm-endpoints/lint-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
}

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
john: ['read', 'write'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down
1 change: 1 addition & 0 deletions packages/realm-server/tests/realm-endpoints/mtimes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
}

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
mary: ['read'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down
16 changes: 3 additions & 13 deletions packages/realm-server/tests/realm-endpoints/permissions-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { module, test } from 'qunit';
import type { Test, SuperTest } from 'supertest';
import { join, basename } from 'path';
import { dirSync, type DirResult } from 'tmp';
import { copySync } from 'fs-extra';
import { basename } from 'path';
import type { Realm } from '@cardstack/runtime-common';
import { fetchRealmPermissions } from '@cardstack/runtime-common';
import {
Expand All @@ -15,32 +13,24 @@ import '@cardstack/runtime-common/helpers/code-equality-assertion';
import type { PgAdapter } from '@cardstack/postgres';

module(`realm-endpoints/${basename(__filename)}`, function () {
module('Realm-specific Endpoints | _permissions', function (hooks) {
module('Realm-specific Endpoints | _permissions', function () {
let testRealm: Realm;
let request: SuperTest<Test>;
let dir: DirResult;
let dbAdapter: PgAdapter;

function onRealmSetup(args: {
testRealm: Realm;
request: SuperTest<Test>;
dbAdapter: PgAdapter;
dir: DirResult;
}) {
testRealm = args.testRealm;
request = args.request;
dbAdapter = args.dbAdapter;
dir = args.dir;
}

hooks.beforeEach(async function () {
dir = dirSync();
copySync(join(__dirname, '..', 'cards'), dir.name);
});

module('permissions requests', function (hooks) {
setupPermissionedRealmCached(hooks, {
fileSystem: {},
fixture: 'blank',
permissions: {
mary: ['read', 'write', 'realm-owner'],
bob: ['read', 'write'],
Expand Down
9 changes: 9 additions & 0 deletions packages/realm-server/tests/realm-endpoints/search-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
let query = () => buildPersonQuery('Mango');

module('public readable realm', function (hooks) {
// Uses `realistic` because tests in this module depend on
// multiple Person instances (pagination), FileDef instances
// beyond person.gts (file-meta queries), and the kitchen-sink
// content variety (sparse-fieldsets backward-compat). Sibling
// modules below only ever query for Mango and stay on `simple`.
setupPermissionedRealmCached(hooks, {
fixture: 'realistic',
permissions: {
'*': ['read'],
},
Expand Down Expand Up @@ -753,6 +759,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('public readable realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'simple',
permissions: {
'*': ['read'],
},
Expand Down Expand Up @@ -829,6 +836,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('permissioned realm', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'simple',
permissions: {
john: ['read'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down Expand Up @@ -886,6 +894,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {

module('search query validation', function (hooks) {
setupPermissionedRealmCached(hooks, {
fixture: 'simple',
permissions: {
'*': ['read'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down
16 changes: 3 additions & 13 deletions packages/realm-server/tests/realm-endpoints/user-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { module, test } from 'qunit';
import type { Test, SuperTest } from 'supertest';
import { join, basename } from 'path';
import { basename } from 'path';
import type { Server } from 'http';
import { dirSync, type DirResult } from 'tmp';
import { copySync } from 'fs-extra';
import type { Realm } from '@cardstack/runtime-common';
import {
setupPermissionedRealmCached,
Expand All @@ -28,7 +26,6 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
let testRealm: Realm;
let testRealmHttpServer: Server;
let request: SuperTest<Test>;
let dir: DirResult;
let dbAdapter: PgAdapter;
let originalLowCreditThreshold: string | undefined;

Expand All @@ -37,20 +34,16 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
testRealmHttpServer: Server;
request: SuperTest<Test>;
dbAdapter: PgAdapter;
dir: DirResult;
}) {
testRealm = args.testRealm;
testRealmHttpServer = args.testRealmHttpServer;
request = args.request;
dbAdapter = args.dbAdapter;
dir = args.dir;
}

hooks.beforeEach(async function () {
originalLowCreditThreshold = process.env.LOW_CREDIT_THRESHOLD;
process.env.LOW_CREDIT_THRESHOLD = '2000';
dir = dirSync();
copySync(join(__dirname, '..', 'cards'), dir.name);
});

hooks.afterEach(async function () {
Expand All @@ -64,6 +57,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
});

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
john: ['read', 'write'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down Expand Up @@ -450,7 +444,6 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
let testRealm: Realm;
let testRealmHttpServer: Server;
let request: SuperTest<Test>;
let dir: DirResult;
let dbAdapter: PgAdapter;
let originalLowCreditThreshold: string | undefined;

Expand All @@ -459,20 +452,16 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
testRealmHttpServer: Server;
request: SuperTest<Test>;
dbAdapter: PgAdapter;
dir: DirResult;
}) {
testRealm = args.testRealm;
testRealmHttpServer = args.testRealmHttpServer;
request = args.request;
dbAdapter = args.dbAdapter;
dir = args.dir;
}

hooks.beforeEach(async function () {
originalLowCreditThreshold = process.env.LOW_CREDIT_THRESHOLD;
process.env.LOW_CREDIT_THRESHOLD = '2000';
dir = dirSync();
copySync(join(__dirname, '..', 'cards'), dir.name);
});

hooks.afterEach(async function () {
Expand All @@ -486,6 +475,7 @@ module(`realm-endpoints/${basename(__filename)}`, function () {
});

setupPermissionedRealmCached(hooks, {
fixture: 'blank',
permissions: {
john: ['read', 'write'],
'@node-test_realm:localhost': ['read', 'realm-owner'],
Expand Down
Loading