summaryrefslogtreecommitdiff
path: root/packages/backend/test/e2e/streaming.ts
diff options
context:
space:
mode:
authorChocolate Pie <106949016+chocolate-pie@users.noreply.github.com>2023-12-27 15:08:59 +0900
committerGitHub <noreply@github.com>2023-12-27 15:08:59 +0900
commitc96bc36fedc804dc840ea791a9355d7df0748e64 (patch)
tree127f0cc1478cb0248aa03b39e07f051423244c6c /packages/backend/test/e2e/streaming.ts
parentchore(frontend): update team members (diff)
downloadmisskey-c96bc36fedc804dc840ea791a9355d7df0748e64.tar.gz
misskey-c96bc36fedc804dc840ea791a9355d7df0748e64.tar.bz2
misskey-c96bc36fedc804dc840ea791a9355d7df0748e64.zip
Merge pull request from GHSA-7pxq-6xx9-xpgm
* fix: fix improper authorization when accessing with third-party application * refactor: refactor type definitions * fix: get rid of unnecessary access limitation * enhance: サードパーティアプリケーションがWebsocket APIを使えるように * fix: add missing parentheses * Revert "fix(backend): add missing kind definition for admin endpoints to improve security" This reverts commit 5150053275594278e9eb23e72d98b16593c4c230. * frontend: 翻訳の抜けを訂正, read:adminとwrite:adminはアクセス発行トークンのデフォルトでは非表示にする * enhance(test): misskey-ghsa-7pxq-6xx9-xpgmに関するテストを追加 * enhance(test): Websocket APIに対するテストも追加 * enhance(refactor): `@/misc/api-permissions.ts`を`misskey-js/permissions`に統合 * fix(frontend): アクセストークン発行UIで全ての権限を有効にした際、管理者用APIへのアクセスも許可してしまう問題を修正 * enhance(backend): Websocketの接続に最低限必要な権限を変更 * fix(backend): `/api/admin/meta`をサードパーティアプリケーションからはアクセスできないように * fix(backend): エンドポイントにアクセスするために必要な権限を変更 * fix(frontend/locale): Add missing type declaration * chore: update `misskey-js/src/autogen` --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Diffstat (limited to 'packages/backend/test/e2e/streaming.ts')
-rw-r--r--packages/backend/test/e2e/streaming.ts25
1 files changed, 24 insertions, 1 deletions
diff --git a/packages/backend/test/e2e/streaming.ts b/packages/backend/test/e2e/streaming.ts
index c4824f50ce..288c54bdbc 100644
--- a/packages/backend/test/e2e/streaming.ts
+++ b/packages/backend/test/e2e/streaming.ts
@@ -6,8 +6,9 @@
process.env.NODE_ENV = 'test';
import * as assert from 'assert';
+import { WebSocket } from 'ws';
import { MiFollowing } from '@/models/Following.js';
-import { signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
+import { signup, api, post, startServer, initTestDb, waitFire, createAppToken, port } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
@@ -560,6 +561,28 @@ describe('Streaming', () => {
});
});
+ test('Authentication', async () => {
+ const application = await createAppToken(ayano, []);
+ const application2 = await createAppToken(ayano, ['read:account']);
+ const socket = new WebSocket(`ws://127.0.0.1:${port}/streaming?i=${application}`);
+ const established = await new Promise<boolean>((resolve, reject) => {
+ socket.on('error', () => resolve(false));
+ socket.on('unexpected-response', () => resolve(false));
+ setTimeout(() => resolve(true), 3000);
+ });
+
+ socket.close();
+ assert.strictEqual(established, false);
+
+ const fired = await waitFire(
+ { token: application2 }, 'hybridTimeline',
+ () => api('notes/create', { text: 'Hello, world!' }, ayano),
+ msg => msg.type === 'note' && msg.body.userId === ayano.id,
+ );
+
+ assert.strictEqual(fired, true);
+ });
+
// XXX: QueryFailedError: duplicate key value violates unique constraint "IDX_347fec870eafea7b26c8a73bac"
/*
describe('Hashtag Timeline', () => {