diff --git a/apps/server/src/modules/tldraw/controller/api-test/tldraw.ws.api.spec.ts b/apps/server/src/modules/tldraw/controller/api-test/tldraw.ws.api.spec.ts index ea54077f815..2b3e57918c6 100644 --- a/apps/server/src/modules/tldraw/controller/api-test/tldraw.ws.api.spec.ts +++ b/apps/server/src/modules/tldraw/controller/api-test/tldraw.ws.api.spec.ts @@ -1,26 +1,26 @@ -import { WsAdapter } from '@nestjs/platform-ws'; -import { Test } from '@nestjs/testing'; -import WebSocket from 'ws'; -import { TextEncoder } from 'util'; -import { INestApplication, NotAcceptableException } from '@nestjs/common'; -import { MongoMemoryDatabaseModule } from '@infra/database'; -import { createConfigModuleOptions } from '@src/config'; -import { of, throwError } from 'rxjs'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { ConfigModule, ConfigService } from '@nestjs/config'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { HttpService } from '@nestjs/axios'; -import { AxiosError, AxiosHeaders, AxiosResponse } from 'axios'; +import { INestApplication, NotAcceptableException } from '@nestjs/common'; +import { ConfigModule, ConfigService } from '@nestjs/config'; +import { WsAdapter } from '@nestjs/platform-ws'; +import { Test } from '@nestjs/testing'; import { axiosResponseFactory } from '@shared/testing'; +import { createConfigModuleOptions } from '@src/config'; import { CoreModule } from '@src/core'; -import { TldrawRedisFactory, TldrawRedisService } from '../../redis'; +import { AxiosError, AxiosHeaders, AxiosResponse } from 'axios'; +import { of, throwError } from 'rxjs'; +import { TextEncoder } from 'util'; +import WebSocket from 'ws'; +import { TldrawWs } from '..'; +import { TldrawConfig } from '../../config'; import { TldrawDrawing } from '../../entities'; -import { TldrawWsService } from '../../service'; +import { MetricsService } from '../../metrics'; +import { TldrawRedisFactory, TldrawRedisService } from '../../redis'; import { TldrawBoardRepo, TldrawRepo, YMongodb } from '../../repo'; +import { TldrawWsService } from '../../service'; import { TestConnection, tldrawTestConfig } from '../../testing'; -import { MetricsService } from '../../metrics'; -import { TldrawWs } from '..'; import { WsCloseCode, WsCloseMessage } from '../../types'; -import { TldrawConfig } from '../../config'; // This is a unit test, no api test...need to be refactored describe('WebSocketController (WsAdapter)', () => { @@ -170,7 +170,13 @@ describe('WebSocketController (WsAdapter)', () => { it(`should refuse connection if jwt is wrong`, async () => { const { wsCloseSpy, httpGetCallSpy } = setup(); - const error = new Error('unknown error'); + const error = new AxiosError('unknown error', '401', undefined, undefined, { + config: { headers: new AxiosHeaders() }, + data: undefined, + headers: {}, + statusText: '401', + status: 401, + }); httpGetCallSpy.mockReturnValueOnce(throwError(() => error)); ws = await TestConnection.setupWs(wsUrl, 'TEST', { cookie: 'jwt=jwt-mocked' }); diff --git a/package-lock.json b/package-lock.json index 0d4bcc30648..4761760a394 100644 --- a/package-lock.json +++ b/package-lock.json @@ -142,7 +142,7 @@ "urlsafe-base64": "^1.0.0", "uuid": "^8.3.0", "winston": "^3.8.2", - "ws": "^8.16.0", + "ws": "^8.17.1", "y-protocols": "^1.0.6", "yjs": "^13.6.11" }, @@ -4918,6 +4918,26 @@ "rxjs": "^7.1.0" } }, + "node_modules/@nestjs/platform-ws/node_modules/ws": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", + "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/@nestjs/schematics": { "version": "10.0.2", "dev": true, @@ -23791,9 +23811,9 @@ } }, "node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 2b67a87f720..27246bf3ed5 100644 --- a/package.json +++ b/package.json @@ -258,7 +258,7 @@ "urlsafe-base64": "^1.0.0", "uuid": "^8.3.0", "winston": "^3.8.2", - "ws": "^8.16.0", + "ws": "^8.17.1", "y-protocols": "^1.0.6", "yjs": "^13.6.11" },