diff --git a/BE/package-lock.json b/BE/package-lock.json index dc208c9c..58c19817 100644 --- a/BE/package-lock.json +++ b/BE/package-lock.json @@ -18,6 +18,7 @@ "axios": "^1.7.7", "bcrypt": "^5.1.1", "class-transformer": "^0.5.1", + "class-validator": "^0.14.1", "cross-env": "^7.0.3", "docker": "^1.0.0", "dotenv": "^16.4.5", @@ -37,7 +38,6 @@ "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/supertest": "^6.0.0", - "class-validator": "^0.14.1", "eslint": "^8.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^18.0.0", @@ -2150,7 +2150,6 @@ "version": "13.12.2", "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.2.tgz", "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==", - "devOptional": true, "license": "MIT" }, "node_modules/@types/yargs": { @@ -3592,7 +3591,6 @@ "version": "0.14.1", "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.1.tgz", "integrity": "sha512-2VEG9JICxIqTpoK1eMzZqaV+u/EiwEJkMGzTrZf6sU/fwsnOITVgYJ8yojSy6CaXtO9V0Cc6ZQZ8h8m4UBuLwQ==", - "devOptional": true, "license": "MIT", "dependencies": { "@types/validator": "^13.11.8", @@ -8129,7 +8127,6 @@ "version": "1.11.12", "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.11.12.tgz", "integrity": "sha512-QkJn9/D7zZ1ucvT++TQSvZuSA2xAWeUytU+DiEQwbPKLyrDpvbul2AFs1CGbRAPpSCCk47aRAb5DX5mmcayp4g==", - "devOptional": true, "license": "MIT" }, "node_modules/lines-and-columns": { @@ -11725,7 +11722,6 @@ "version": "13.12.0", "resolved": "https://registry.npmjs.org/validator/-/validator-13.12.0.tgz", "integrity": "sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==", - "devOptional": true, "license": "MIT", "engines": { "node": ">= 0.10" @@ -13675,8 +13671,7 @@ "@types/validator": { "version": "13.12.2", "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.2.tgz", - "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==", - "devOptional": true + "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==" }, "@types/yargs": { "version": "17.0.33", @@ -14697,7 +14692,6 @@ "version": "0.14.1", "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.1.tgz", "integrity": "sha512-2VEG9JICxIqTpoK1eMzZqaV+u/EiwEJkMGzTrZf6sU/fwsnOITVgYJ8yojSy6CaXtO9V0Cc6ZQZ8h8m4UBuLwQ==", - "devOptional": true, "requires": { "@types/validator": "^13.11.8", "libphonenumber-js": "^1.10.53", @@ -17965,8 +17959,7 @@ "libphonenumber-js": { "version": "1.11.12", "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.11.12.tgz", - "integrity": "sha512-QkJn9/D7zZ1ucvT++TQSvZuSA2xAWeUytU+DiEQwbPKLyrDpvbul2AFs1CGbRAPpSCCk47aRAb5DX5mmcayp4g==", - "devOptional": true + "integrity": "sha512-QkJn9/D7zZ1ucvT++TQSvZuSA2xAWeUytU+DiEQwbPKLyrDpvbul2AFs1CGbRAPpSCCk47aRAb5DX5mmcayp4g==" }, "lines-and-columns": { "version": "1.2.4", @@ -20437,8 +20430,7 @@ "validator": { "version": "13.12.0", "resolved": "https://registry.npmjs.org/validator/-/validator-13.12.0.tgz", - "integrity": "sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==", - "devOptional": true + "integrity": "sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==" }, "vary": { "version": "1.1.2", diff --git a/BE/package.json b/BE/package.json index 4bcb6550..569138b9 100644 --- a/BE/package.json +++ b/BE/package.json @@ -29,6 +29,7 @@ "axios": "^1.7.7", "bcrypt": "^5.1.1", "class-transformer": "^0.5.1", + "class-validator": "^0.14.1", "cross-env": "^7.0.3", "docker": "^1.0.0", "dotenv": "^16.4.5", @@ -48,7 +49,6 @@ "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/supertest": "^6.0.0", - "class-validator": "^0.14.1", "eslint": "^8.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^18.0.0", diff --git a/BE/src/auth/auth.controller.spec.ts b/BE/src/auth/auth.controller.spec.ts index 27a31e61..8791f7dc 100644 --- a/BE/src/auth/auth.controller.spec.ts +++ b/BE/src/auth/auth.controller.spec.ts @@ -1,5 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { AuthController } from './auth.controller'; +import { AuthService } from './auth.service'; +import { UserRepository } from './user.repository'; describe('AuthController', () => { let controller: AuthController; @@ -7,6 +9,17 @@ describe('AuthController', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [AuthController], + providers: [ + AuthService, + { + provide: UserRepository, + useValue: { + find: jest.fn(), + findOne: jest.fn(), + save: jest.fn(), + }, + }, + ], }).compile(); controller = module.get(AuthController); diff --git a/BE/src/auth/auth.service.spec.ts b/BE/src/auth/auth.service.spec.ts index 800ab662..cc1425f3 100644 --- a/BE/src/auth/auth.service.spec.ts +++ b/BE/src/auth/auth.service.spec.ts @@ -1,12 +1,25 @@ import { Test, TestingModule } from '@nestjs/testing'; import { AuthService } from './auth.service'; +import { AuthController } from './auth.controller'; +import { UserRepository } from './user.repository'; describe('AuthService', () => { let service: AuthService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [AuthService], + controllers: [AuthController], + providers: [ + AuthService, + { + provide: UserRepository, + useValue: { + find: jest.fn(), + findOne: jest.fn(), + save: jest.fn(), + }, + }, + ], }).compile(); service = module.get(AuthService); diff --git a/BE/src/auth/dto/authCredentials.dto.ts b/BE/src/auth/dto/authCredentials.dto.ts index d8e67287..1ca2cf30 100644 --- a/BE/src/auth/dto/authCredentials.dto.ts +++ b/BE/src/auth/dto/authCredentials.dto.ts @@ -1,4 +1,5 @@ import { IsString, Matches, MaxLength, MinLength } from 'class-validator'; + export class AuthCredentialsDto { @IsString() @MinLength(4)