Skip to content

Commit

Permalink
Merge branch 'main' into EW-793
Browse files Browse the repository at this point in the history
  • Loading branch information
psachmann authored Jun 21, 2024
2 parents cdba08c + 4e1293f commit ef8bdcc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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)', () => {
Expand Down Expand Up @@ -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' });
Expand Down
28 changes: 24 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit ef8bdcc

Please sign in to comment.