Skip to content

Commit

Permalink
BC-8693 - Dependency updates (#5430)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP authored Jan 21, 2025
1 parent aaed97f commit 8dc8d5f
Show file tree
Hide file tree
Showing 33 changed files with 8,811 additions and 10,307 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,21 @@ jobs:
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
with:
allow-licenses: AGPL-3.0-only, LGPL-3.0, MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, X11, 0BSD, GPL-3.0, Unlicense, CC0-1.0
allow-licenses: >
AGPL-3.0-only,
LGPL-3.0,
MIT,
MIT-0,
BlueOak-1.0.0,
Apache-2.0,
BSD-2-Clause,
BSD-3-Clause,
ISC,
X11,
0BSD,
GPL-3.0,
Unlicense,
CC0-1.0
allow-ghsas: 'GHSA-vxvm-qww3-2fh7'
# https://github.com/actions/dependency-review-action/issues/868
allow-dependencies-licenses: pkg:npm/%40apidevtools/[email protected]
3 changes: 2 additions & 1 deletion apps/server/src/apps/helpers/swagger.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ServerTestModule } from '@modules/server';
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import type { Server } from 'node:net';
import request from 'supertest';
import { enableOpenApiDocs } from './swagger';

describe('swagger setup', () => {
describe('when adding swagger to an app', () => {
let app: INestApplication;
let app: INestApplication<Server>;

beforeAll(async () => {
app = await NestFactory.create(ServerTestModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConfigService } from '@nestjs/config';
import { Algorithm } from 'jsonwebtoken';
import { JwtFromRequestFunction, StrategyOptions } from 'passport-jwt';
import { JwtAuthGuardConfig } from '../config';

Expand All @@ -8,7 +9,7 @@ export class JwtStrategyOptionsFactory {
configService: ConfigService<JwtAuthGuardConfig>
): StrategyOptions {
const publicKey = configService.getOrThrow<string>('JWT_PUBLIC_KEY');
const algorithm = configService.getOrThrow<string>('JWT_SIGNING_ALGORITHM');
const algorithm = configService.getOrThrow<string>('JWT_SIGNING_ALGORITHM') as Algorithm;

const options = {
jwtFromRequest: jwtFromRequestFunction,
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/infra/file-system/file-system.adapter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common';
import { promises as fsp, existsSync } from 'fs';
import { existsSync, promises as fsp } from 'fs';
import os from 'os';
import path from 'path';

import rimraf = require('rimraf');
import { rimrafSync } from 'rimraf';

const { mkdir, readdir, writeFile, readFile, mkdtemp } = fsp;

Expand Down Expand Up @@ -77,7 +77,7 @@ export class FileSystemAdapter {
*/
async removeDirRecursive(folderPath: string): Promise<void> {
// fs.rm changed in node 14.14, use rimraf instead
rimraf.sync(folderPath);
rimrafSync(folderPath);
return Promise.resolve();
}

Expand Down
13 changes: 7 additions & 6 deletions apps/server/src/infra/s3-client/s3-client.adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,22 @@ describe('S3ClientAdapter', () => {
const setup = () => {
const { file } = createFile();
const { pathToFile } = createParameter();
const error = new InternalServerErrorException('S3ClientAdapter:create');
const error = new Error('Connection Error');
const expectedError = new InternalServerErrorException('S3ClientAdapter:create', { cause: error });

const uploadDoneMock = jest.spyOn(Upload.prototype, 'done').mockRejectedValueOnce(error);

const restoreMocks = () => {
uploadDoneMock.mockRestore();
};

return { file, pathToFile, error, restoreMocks };
return { file, pathToFile, expectedError, restoreMocks };
};

it('should throw error from client', async () => {
const { file, pathToFile, error, restoreMocks } = setup();
const { file, pathToFile, expectedError, restoreMocks } = setup();

await expect(service.create(pathToFile, file)).rejects.toThrow(error);
await expect(service.create(pathToFile, file)).rejects.toThrow(expectedError);

restoreMocks();
});
Expand Down Expand Up @@ -451,13 +452,13 @@ describe('S3ClientAdapter', () => {
const setup = () => {
const { pathToFile } = createParameter();
const filePath = 'directory/test.txt';
const error = new Error('testError');
const error = new Error('S3ClientAdapter:delete');
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
client.send.mockResolvedValueOnce({ Contents: [{ Key: filePath }] });
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
client.send.mockRejectedValueOnce(error);
client.send.mockRejectedValueOnce();

const expectedError = new InternalServerErrorException(
'S3ClientAdapter:deleteDirectory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,12 @@ describe('AccountDbService', () => {
};

it('should update account', async () => {
const { mockStudentUser, mockTeacherAccount } = setup();
const { mockTeacherAccount } = setup();

const ret = await accountService.save(mockTeacherAccount);

expect(ret).toBeDefined();
expect(ret).toMatchObject({
id: mockTeacherAccount.id,
username: mockTeacherAccount.username,
activated: mockTeacherAccount.activated,
systemId: mockTeacherAccount.systemId,
userId: new ObjectId(mockStudentUser.id),
});
expect(ret).toEqual(mockTeacherAccount);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountEntityToDoMapper } from './account-entity-to-do.mapper';
import { AccountEntity } from '../../../domain/entity/account.entity';
import { accountFactory } from '../../../testing';
import { AccountEntityToDoMapper } from './account-entity-to-do.mapper';

describe('AccountEntityToDoMapper', () => {
beforeEach(() => {
Expand All @@ -16,7 +16,7 @@ describe('AccountEntityToDoMapper', () => {
describe('mapToDo', () => {
describe('When mapping AccountEntity to Account', () => {
const setup = () => {
const accountEntity = accountFactory.withAllProperties().buildWithId({}, '000000000000000000000001');
const accountEntity = accountFactory.withAllProperties().buildWithId();

const missingSystemUserIdEntity: AccountEntity = accountFactory.withoutSystemAndUserId().build();

Expand All @@ -28,7 +28,21 @@ describe('AccountEntityToDoMapper', () => {

const ret = AccountEntityToDoMapper.mapToDo(accountEntity);

expect({ ...ret.getProps(), _id: accountEntity._id }).toMatchObject(accountEntity);
expect({ ...ret.getProps(), _id: accountEntity._id }).toMatchObject({
id: accountEntity.id,
createdAt: accountEntity.createdAt,
updatedAt: accountEntity.updatedAt,
userId: accountEntity.userId?.toHexString(),
systemId: accountEntity.systemId?.toHexString(),
username: accountEntity.username,
password: accountEntity.password,
token: accountEntity.token,
credentialHash: accountEntity.credentialHash,
lastLogin: accountEntity.lastLogin,
expiresAt: accountEntity.expiresAt,
activated: accountEntity.activated,
deactivatedAt: accountEntity.deactivatedAt,
});
});

it('should ignore missing ids', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { SchulcloudTheme } from '@shared/domain/types';
import { axiosResponseFactory } from '@testing/factory/axios-response.factory';
import type { Server } from 'node:net';
import { of } from 'rxjs';
import request from 'supertest';
import { serverConfig, ServerTestModule } from '../../../server';
Expand All @@ -21,7 +22,7 @@ describe('Alert Controller api', () => {
const component1 = createComponent(1, 1);
const component2 = createComponent(2, 2);

let app: INestApplication;
let app: INestApplication<Server>;
let httpService: DeepMocked<HttpService>;

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import jwt from 'jsonwebtoken';
import moment from 'moment';
import type { Server } from 'node:net';
import request, { Response } from 'supertest';
import { LdapAuthorizationBodyParams, LocalAuthorizationBodyParams, OauthLoginResponse } from '../dto';

Expand Down Expand Up @@ -71,7 +72,7 @@ jest.mock('jwks-rsa', () => () => {
describe('Login Controller (api)', () => {
const basePath = '/authentication';

let app: INestApplication;
let app: INestApplication<Server>;
let em: EntityManager;

const defaultPassword = 'DummyPasswd!1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { IdentityManagementOauthService } from '@infra/identity-management';
import { Account } from '@modules/account';
import { accountDoFactory } from '@modules/account/testing';
import { ServerConfig } from '@modules/server';
import { UnauthorizedException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { User } from '@shared/domain/entity';
Expand Down Expand Up @@ -30,7 +29,7 @@ describe('LocalStrategy', () => {
await setupEntities();
authenticationServiceMock = createMock<AuthenticationService>();
idmOauthServiceMock = createMock<IdentityManagementOauthService>();
configServiceMock = createMock<ConfigService<ServerConfig, true>>();
configServiceMock = createMock<ConfigService>();
userRepoMock = createMock<UserRepo>();
strategy = new LocalStrategy(authenticationServiceMock, idmOauthServiceMock, configServiceMock, userRepoMock);
mockUser = userFactory.withRoleByName(RoleName.STUDENT).buildWithId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FileContentBody {
}

export class FileElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.FILE })
@ApiProperty({ type: () => ContentElementType.FILE })
type!: ContentElementType.FILE;

@ValidateNested()
Expand Down Expand Up @@ -60,7 +60,7 @@ export class LinkContentBody {
}

export class LinkElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.LINK })
@ApiProperty({ type: () => ContentElementType.LINK })
type!: ContentElementType.LINK;

@ValidateNested()
Expand All @@ -75,7 +75,7 @@ export class DrawingContentBody {
}

export class DrawingElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.DRAWING })
@ApiProperty({ type: () => ContentElementType.DRAWING })
type!: ContentElementType.DRAWING;

@ValidateNested()
Expand All @@ -94,7 +94,7 @@ export class RichTextContentBody {
}

export class RichTextElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.RICH_TEXT })
@ApiProperty({ type: () => ContentElementType.RICH_TEXT })
type!: ContentElementType.RICH_TEXT;

@ValidateNested()
Expand All @@ -112,7 +112,7 @@ export class SubmissionContainerContentBody {
}

export class SubmissionContainerElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.SUBMISSION_CONTAINER })
@ApiProperty({ type: () => ContentElementType.SUBMISSION_CONTAINER })
type!: ContentElementType.SUBMISSION_CONTAINER;

@ValidateNested()
Expand All @@ -128,7 +128,7 @@ export class ExternalToolContentBody {
}

export class ExternalToolElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.EXTERNAL_TOOL })
@ApiProperty({ type: () => ContentElementType.EXTERNAL_TOOL })
type!: ContentElementType.EXTERNAL_TOOL;

@ValidateNested()
Expand All @@ -143,7 +143,7 @@ export class VideoConferenceContentBody {
}

export class VideoConferenceElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.VIDEO_CONFERENCE })
@ApiProperty({ type: () => ContentElementType.VIDEO_CONFERENCE })
type!: ContentElementType.VIDEO_CONFERENCE;

@ValidateNested()
Expand Down Expand Up @@ -188,7 +188,7 @@ export class UpdateElementContentBodyParams {
{ $ref: getSchemaPath(VideoConferenceElementContentBody) },
],
})
data!:
public data!:
| FileElementContentBody
| LinkElementContentBody
| RichTextElementContentBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('Collaborative Storage Service', () => {

describe('Update TeamPermissions For Role', () => {
it('should call the adapter', async () => {
mockId = 'mockId';
jest.spyOn(service, 'findTeamById').mockResolvedValue({
id: 'testId',
name: 'testTeam',
Expand All @@ -108,6 +109,7 @@ describe('Collaborative Storage Service', () => {
});

it('should throw a forbidden exception', async () => {
mockId = 'mockId';
authService.checkPermission.mockImplementation(() => {
throw new ForbiddenException();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { INestApplication } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { axiosResponseFactory } from '@testing/factory/axios-response.factory';
import type { Server } from 'node:net';
import supertest from 'supertest';
import { CommonCartridgeApiModule } from '../common-cartridge-api.app.module';
import { CommonCartridgeFileBuilder } from '../export/builders/common-cartridge-file-builder';
Expand All @@ -29,7 +30,7 @@ jest.mock('../../../infra/auth-guard/decorator/jwt-auth.decorator', () => {

describe('CommonCartridgeController (API)', () => {
let module: TestingModule;
let app: INestApplication;
let app: INestApplication<Server>;

beforeAll(async () => {
module = await Test.createTestingModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { fileRecordFactory } from '@testing/factory/filerecord.factory';
import { schoolEntityFactory } from '@testing/factory/school-entity.factory';
import { UserAndAccountTestFactory } from '@testing/factory/user-and-account.test.factory';
import NodeClam from 'clamscan';
import type { Server } from 'node:net';
import request from 'supertest';
import { FileRecord } from '../../entity';
import { FilesStorageTestModule } from '../../files-storage-test.module';
Expand All @@ -18,9 +19,9 @@ const baseRouteName = '/file-security';
const scanResult: ScanResultParams = { virus_detected: false };

class API {
app: INestApplication;
app: INestApplication<Server>;

constructor(app: INestApplication) {
constructor(app: INestApplication<Server>) {
this.app = app;
}

Expand All @@ -39,7 +40,7 @@ class API {
}

describe(`${baseRouteName} (api)`, () => {
let app: INestApplication;
let app: INestApplication<Server>;
let em: EntityManager;
let api: API;
let validId: string;
Expand Down
Loading

0 comments on commit 8dc8d5f

Please sign in to comment.