Skip to content

Commit c8c9105

Browse files
committed
refactor(server): reorganize test structure and fix test failures
- Reorganize tests into unit/ and integration/ folders - Add SocketIOClientFixture and JWTTestHelper utilities - Fix JWKS verifier test to use manual fetch mock (bun-fetch-mock incompatible) - Fix SocketIO auth test for DATA_ISOLATION=false case - Add PostgreSQL detection to migrations (skip on SQLite) - Rename bootstrap-autoload.test.ts → plugin-auto-injection.test.ts - Rename middleware-chain.test.ts → auth-middleware-chain.test.ts - Remove jobs-message-flow.test.ts (merged into other integration tests)
1 parent 7fd9e79 commit c8c9105

31 files changed

+1604
-1846
lines changed

bun.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,17 +418,21 @@
418418
"@types/express": "^5.0.2",
419419
"@types/helmet": "^4.0.0",
420420
"@types/multer": "^2.0.0",
421+
"bcrypt": "^6.0.0",
421422
"dotenv": "^17.2.3",
422423
"express": "^5.1.0",
423424
"express-rate-limit": "^8.1.0",
424425
"helmet": "^8.1.0",
426+
"jose": "^6.1.2",
425427
"multer": "^2.0.1",
426428
"path-to-regexp": "^8.2.0",
427429
"socket.io": "^4.8.1",
428430
},
429431
"devDependencies": {
430432
"@elizaos/client": "workspace:*",
433+
"@types/bcrypt": "^6.0.0",
431434
"@types/node": "^24.0.1",
435+
"bun-fetch-mock": "^1.0.0",
432436
"prettier": "3.6.2",
433437
"tsx": "4.20.6",
434438
"typescript": "^5.5.4",
@@ -1385,6 +1389,8 @@
13851389

13861390
"@types/babel__traverse": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
13871391

1392+
"@types/bcrypt": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-/oJGukuH3D2+D+3H4JWLaAsJ/ji86dhRidzZ/Od7H/i8g+aCmvkeCc6Ni/f9uxGLSQVCRZkX2/lqEFG2BvWtlQ=="],
1393+
13881394
"@types/body-parser": ["@types/[email protected]", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g=="],
13891395

13901396
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="],
@@ -1787,6 +1793,8 @@
17871793

17881794
"bats-support": ["[email protected]", "", { "peerDependencies": { "bats": "0.4 || ^1" } }, "sha512-z+2WzXbI4OZgLnynydqH8GpI3+DcOtepO66PlK47SfEzTkiuV9hxn9eIQX+uLVFbt2Oqoc7Ky3TJ/N83lqD+cg=="],
17891795

1796+
"bcrypt": ["[email protected]", "", { "dependencies": { "node-addon-api": "^8.3.0", "node-gyp-build": "^4.8.4" } }, "sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg=="],
1797+
17901798
"bcrypt-pbkdf": ["[email protected]", "", { "dependencies": { "tweetnacl": "^0.14.3" } }, "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w=="],
17911799

17921800
"before-after-hook": ["[email protected]", "", {}, "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="],
@@ -1845,6 +1853,8 @@
18451853

18461854
"bun": ["[email protected]", "", { "optionalDependencies": { "@oven/bun-darwin-aarch64": "1.3.2", "@oven/bun-darwin-x64": "1.3.2", "@oven/bun-darwin-x64-baseline": "1.3.2", "@oven/bun-linux-aarch64": "1.3.2", "@oven/bun-linux-aarch64-musl": "1.3.2", "@oven/bun-linux-x64": "1.3.2", "@oven/bun-linux-x64-baseline": "1.3.2", "@oven/bun-linux-x64-musl": "1.3.2", "@oven/bun-linux-x64-musl-baseline": "1.3.2", "@oven/bun-windows-x64": "1.3.2", "@oven/bun-windows-x64-baseline": "1.3.2" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "bun": "bin/bun.exe", "bunx": "bin/bunx.exe" } }, "sha512-x75mPJiEfhO1j4Tfc65+PtW6ZyrAB6yTZInydnjDZXF9u9PRAnr6OK3v0Q9dpDl0dxRHkXlYvJ8tteJxc8t4Sw=="],
18471855

1856+
"bun-fetch-mock": ["[email protected]", "", {}, "sha512-5YVYK7R7NhJ//iNQBasnuG19cZLb4qDCp/gTQqdBnC6RINr2bwOmtBN3hrg5/qY3gp97bH2jjqjqjNRwVIN50Q=="],
1857+
18481858
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="],
18491859

18501860
"bundle-require": ["[email protected]", "", { "dependencies": { "load-tsconfig": "^0.2.3" }, "peerDependencies": { "esbuild": ">=0.18" } }, "sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA=="],
@@ -2779,6 +2789,8 @@
27792789

27802790
"joi": ["[email protected]", "", { "dependencies": { "@hapi/address": "^5.1.1", "@hapi/formula": "^3.0.2", "@hapi/hoek": "^11.0.7", "@hapi/pinpoint": "^2.0.1", "@hapi/tlds": "^1.1.1", "@hapi/topo": "^6.0.2", "@standard-schema/spec": "^1.0.0" } }, "sha512-RuCOQMIt78LWnktPoeBL0GErkNaJPTBGcYuyaBvUOQSpcpcLfWrHPPihYdOGbV5pam9VTWbeoF7TsGiHugcjGA=="],
27812791

2792+
"jose": ["[email protected]", "", {}, "sha512-MpcPtHLE5EmztuFIqB0vzHAWJPpmN1E6L4oo+kze56LIs3MyXIj9ZHMDxqOvkP38gBR7K1v3jqd4WU2+nrfONQ=="],
2793+
27822794
"joycon": ["[email protected]", "", {}, "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw=="],
27832795

27842796
"js-tiktoken": ["[email protected]", "", { "dependencies": { "base64-js": "^1.5.1" } }, "sha512-biOj/6M5qdgx5TKjDnFT1ymSpM5tbd3ylwDtrQvFQSu0Z7bBYko2dF+W/aUkXUPuk6IVpRxk/3Q2sHOzGlS36g=="],
@@ -3161,6 +3173,8 @@
31613173

31623174
"nipplejs": ["[email protected]", "", {}, "sha512-XGxFY8C2DOtobf1fK+MXINTzkkXJLjZDDpfQhOUZf4TSytbc9s4bmA0lB9eKKM8iDivdr9NQkO7DpIQfsST+9g=="],
31633175

3176+
"node-addon-api": ["[email protected]", "", {}, "sha512-/bRZty2mXUIFY/xU5HLvveNHlswNJej+RnxBjOMkidWfwZzgTbPG1E3K5TOxRLOR+5hX7bSofy8yf1hZevMS8A=="],
3177+
31643178
"node-domexception": ["[email protected]", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
31653179

31663180
"node-fetch": ["[email protected]", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="],

packages/plugin-sql/src/migrations.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ import { sql } from 'drizzle-orm';
1717
export async function migrateToEntityRLS(adapter: IDatabaseAdapter): Promise<void> {
1818
const db = adapter.db;
1919

20+
// Detect database type - skip PostgreSQL-specific migrations for SQLite
21+
try {
22+
await db.execute(sql`SELECT 1 FROM pg_tables LIMIT 1`);
23+
} catch {
24+
// Not PostgreSQL (likely SQLite)
25+
logger.debug('[Migration] ⊘ Not PostgreSQL, skipping PostgreSQL-specific migrations');
26+
return;
27+
}
28+
2029
logger.info('[Migration] Starting develop → feat/entity-rls migration...');
2130

2231
try {

packages/plugin-sql/src/schema/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const channelTable = pgTable('channels', {
1313
sourceId: text('source_id'),
1414
topic: text('topic'),
1515
metadata: jsonb('metadata'),
16-
server_id: uuid('server_id'),
16+
// Note: server_id is added dynamically by RLS setup, not defined in schema
1717
createdAt: timestamp('created_at', { mode: 'date' })
1818
.default(sql`CURRENT_TIMESTAMP`)
1919
.notNull(),

0 commit comments

Comments
 (0)