test authorization module
This commit is contained in:
parent
1e5e0f2fbd
commit
50742fc53a
|
@ -3,12 +3,14 @@ import { AutomapperModule } from '@automapper/nestjs';
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { AuthenticationModule } from './modules/authentication/authentication.module';
|
||||
import { AuthorizationModule } from './modules/authorization/authorization.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
AutomapperModule.forRoot({ strategyInitializer: classes() }),
|
||||
AuthenticationModule,
|
||||
AuthorizationModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { ValidateAuthenticationUseCase } from '../authentication/domain/usecases/validate-authentication.usecase';
|
||||
import { DatabaseModule } from '../database/database.module';
|
||||
|
||||
@Module({
|
||||
imports: [DatabaseModule, CqrsModule],
|
||||
exports: [],
|
||||
providers: [ValidateAuthenticationUseCase],
|
||||
})
|
||||
export class AuthorizationModule {}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class ValidateAuthorizationRequest {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
action: string;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { classes } from '@automapper/classes';
|
||||
import { AutomapperModule } from '@automapper/nestjs';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ValidateAuthorizationRequest } from '../../domain/dtos/validate-authorization.request';
|
||||
import { ValidateAuthorizationUseCase } from '../../domain/usecases/validate-authorization.usecase';
|
||||
|
||||
describe('ValidateAuthorizationUseCase', () => {
|
||||
|
@ -20,4 +21,18 @@ describe('ValidateAuthorizationUseCase', () => {
|
|||
it('should be defined', () => {
|
||||
expect(validateAuthorizationUseCase).toBeDefined();
|
||||
});
|
||||
|
||||
describe('execute', () => {
|
||||
it('should validate an authorization', async () => {
|
||||
const validateAuthorizationRequest: ValidateAuthorizationRequest =
|
||||
new ValidateAuthorizationRequest();
|
||||
validateAuthorizationRequest.uuid =
|
||||
'bb281075-1b98-4456-89d6-c643d3044a91';
|
||||
validateAuthorizationRequest.action = 'authorized';
|
||||
|
||||
expect(
|
||||
validateAuthorizationUseCase.execute(validateAuthorizationRequest),
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue