upgrade packages; handle throttle failure with message broker handler

This commit is contained in:
Sylvain Briat
2024-01-16 17:30:51 +01:00
parent 1026ca7eb9
commit 3f0bef812e
7 changed files with 947 additions and 988 deletions

View File

@@ -1,7 +1,4 @@
import {
ConfigurationDomainGet,
ConfigurationType,
} from '@mobicoop/configuration-module';
import { KeyType, Type } from '@mobicoop/configuration-module';
import { IsStrongPasswordOptions } from 'class-validator';
export const STRONG_PASSWORD_OPTIONS: IsStrongPasswordOptions = {
@@ -13,9 +10,9 @@ export const STRONG_PASSWORD_OPTIONS: IsStrongPasswordOptions = {
};
export const AUTH_CONFIG_ENCRYPTION_ALGORITHM = 'encryptionAlgorithm';
export const AuthConfig: ConfigurationDomainGet[] = [
export const AuthKeyTypes: KeyType[] = [
{
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
type: ConfigurationType.STRING,
type: Type.STRING,
},
];

View File

@@ -17,13 +17,13 @@ import {
UsernameAlreadyExistsException,
} from '@modules/authentication/core/domain/authentication.errors';
import {
ConfigurationDomain,
Configurator,
Domain,
GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module';
import {
AUTH_CONFIG_ENCRYPTION_ALGORITHM,
AuthConfig,
AuthKeyTypes,
} from '@modules/authentication/authentication.constants';
import { EncryptionAlgorithm } from '@modules/authentication/core/domain/username.types';
import { PasswordEncrypter } from '@modules/authentication/infrastructure/password-encrypter';
@@ -40,10 +40,7 @@ export class CreateAuthenticationService implements ICommandHandler {
async execute(command: CreateAuthenticationCommand): Promise<AggregateID> {
const authConfigurator: Configurator =
await this.configurationRepository.mget(
ConfigurationDomain.AUTH,
AuthConfig,
);
await this.configurationRepository.mget(Domain.AUTH, AuthKeyTypes);
const passwordEncrypter: PasswordEncrypterPort = new PasswordEncrypter(
authConfigurator.get<EncryptionAlgorithm>(
AUTH_CONFIG_ENCRYPTION_ALGORITHM,

View File

@@ -9,13 +9,13 @@ import { UpdatePasswordCommand } from './update-password.command';
import { AuthenticationRepositoryPort } from '../../ports/authentication.repository.port';
import { AuthenticationEntity } from '@modules/authentication/core/domain/authentication.entity';
import {
ConfigurationDomain,
Domain,
Configurator,
GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module';
import {
AUTH_CONFIG_ENCRYPTION_ALGORITHM,
AuthConfig,
AuthKeyTypes,
} from '@modules/authentication/authentication.constants';
import { EncryptionAlgorithm } from '@modules/authentication/core/domain/username.types';
import { PasswordEncrypterPort } from '../../ports/password-encrypter.port';
@@ -32,10 +32,7 @@ export class UpdatePasswordService implements ICommandHandler {
async execute(command: UpdatePasswordCommand): Promise<AggregateID> {
const authConfigurator: Configurator =
await this.configurationRepository.mget(
ConfigurationDomain.AUTH,
AuthConfig,
);
await this.configurationRepository.mget(Domain.AUTH, AuthKeyTypes);
const encryptionAlgorithm: EncryptionAlgorithm =
authConfigurator.get<EncryptionAlgorithm>(
AUTH_CONFIG_ENCRYPTION_ALGORITHM,

View File

@@ -1,8 +1,8 @@
import {
ConfigurationDomain,
ConfigurationDomainGet,
Domain,
Configurator,
GetConfigurationRepositoryPort,
KeyType,
} from '@mobicoop/configuration-module';
import {
AggregateID,
@@ -58,12 +58,12 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(),
mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => {
(domain: Domain, keyTypes: KeyType[]) => {
switch (domain) {
case ConfigurationDomain.AUTH:
return new Configurator(ConfigurationDomain.AUTH, [
case Domain.AUTH:
return new Configurator(Domain.AUTH, [
{
domain: ConfigurationDomain.AUTH,
domain: Domain.AUTH,
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
value: 'BCRYPT',
},

View File

@@ -9,10 +9,10 @@ import { UpdatePasswordRequestDto } from '@modules/authentication/interface/grpc
import { Test, TestingModule } from '@nestjs/testing';
import { UpdatePasswordCommand } from '@modules/authentication/core/application/commands/update-password/update-password.command';
import {
ConfigurationDomain,
ConfigurationDomainGet,
Domain,
Configurator,
GetConfigurationRepositoryPort,
KeyType,
} from '@mobicoop/configuration-module';
import { AUTH_CONFIG_ENCRYPTION_ALGORITHM } from '@modules/authentication/authentication.constants';
@@ -38,12 +38,12 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(),
mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => {
(domain: Domain, keyTypes: KeyType[]) => {
switch (domain) {
case ConfigurationDomain.AUTH:
return new Configurator(ConfigurationDomain.AUTH, [
case Domain.AUTH:
return new Configurator(Domain.AUTH, [
{
domain: ConfigurationDomain.AUTH,
domain: Domain.AUTH,
key: AUTH_CONFIG_ENCRYPTION_ALGORITHM,
value: 'BCRYPT',
},