diff --git a/deploy/helmfiles/prd.yaml b/deploy/helmfiles/prd.yaml index e712071..855b0ea 100644 --- a/deploy/helmfiles/prd.yaml +++ b/deploy/helmfiles/prd.yaml @@ -50,4 +50,4 @@ charts: - name: replicaCount value: 1 - name: maestro.restricted_ip - value: "177.52.172.0/24,57.151.113.140/30" + value: "177.52.172.0/24,189.84.160.157/32,186.237.171.146/32,57.151.113.140/30" diff --git a/src/@types/express-session.d.ts b/src/@types/express-session.d.ts deleted file mode 100644 index 6531c85..0000000 --- a/src/@types/express-session.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import 'express-session'; - -declare module 'express-session' { - interface SessionData { - state: string | undefined; - code_verifier: string | undefined; - } -} \ No newline at end of file diff --git a/src/authentication/authentication.guard.spec.ts b/src/authentication/authentication.guard.spec.ts index 6ee4f36..e34d41c 100644 --- a/src/authentication/authentication.guard.spec.ts +++ b/src/authentication/authentication.guard.spec.ts @@ -99,6 +99,7 @@ describe('authentication.guard', () => { customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11', customer_name: 'dadosfera', customer_tier: 'BASIC', + customer_modules: [] }; beforeAll(async () => { diff --git a/src/authentication/authentication.guard.ts b/src/authentication/authentication.guard.ts index 9543362..f30ce09 100644 --- a/src/authentication/authentication.guard.ts +++ b/src/authentication/authentication.guard.ts @@ -143,10 +143,10 @@ export class AuthenticationGuard } // Bloquear o customer de acesso o maestro publico - // const hasNetworkPolicyModule = accessTokenPayload.customer_modules.includes('network-policy'); - // if (hasNetworkPolicyModule && DEDICATED_PROXY === '') { - // throw new ForbiddenException(); - // } + const hasNetworkPolicyModule = accessTokenPayload.customer_modules.includes('network-policy'); + if (hasNetworkPolicyModule && DEDICATED_PROXY === '') { + throw new ForbiddenException(ErrorCodes.AUTH.FORBIDDEN); + } request.accessTokenPayload = accessTokenPayload; request.user = { diff --git a/src/decorators/user.decorator.spec.ts b/src/decorators/user.decorator.spec.ts index 2f9b0eb..9daee29 100644 --- a/src/decorators/user.decorator.spec.ts +++ b/src/decorators/user.decorator.spec.ts @@ -52,6 +52,7 @@ describe('user.decorator', () => { customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11', customer_name: 'dadosfera', customer_tier: 'BASIC', + customer_modules: [], access_token: '', }; diff --git a/src/main.ts b/src/main.ts index 06152d2..4065312 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ import { AppModule } from './app.module'; import { writeFileSync } from 'fs'; import { execSync } from 'child_process'; import { INestApplication } from '@nestjs/common'; -import session from 'express-session'; + async function bootstrap() { DadosferaLogger.setupLogger({ serviceName: 'maestro', @@ -28,7 +28,7 @@ async function bootstrap() { }); app.use(helmet()); - if (process.env.ENV !== 'local') { + if (process.env.ENV === 'prd') { app.use('/catalog/register-dataset', json({ limit: '10mb' })); app.use('/catalog/register-dataset', urlencoded({ extended: true, limit: '10mb' })); } diff --git a/src/modules/users/users.controller.spec.ts b/src/modules/users/users.controller.spec.ts index 3bba70b..7b43898 100644 --- a/src/modules/users/users.controller.spec.ts +++ b/src/modules/users/users.controller.spec.ts @@ -8,6 +8,17 @@ import { RolesModule } from '../roles/roles.module'; import { PermissionsModule } from '../permissions/permissions.module'; // const client = new DucClient(); +jest.mock('puppeteer', () => ({ + launch: jest.fn().mockResolvedValue({ + newPage: jest.fn().mockResolvedValue({ + goto: jest.fn(), + evaluate: jest.fn(), + close: jest.fn() + }), + close: jest.fn() + }) +})); + const logger = { info: (...args) => args, diff --git a/src/modules/users/users.service.spec.ts b/src/modules/users/users.service.spec.ts index 788c2e9..b7cfc60 100644 --- a/src/modules/users/users.service.spec.ts +++ b/src/modules/users/users.service.spec.ts @@ -9,6 +9,17 @@ import { PermissionsModule } from '../permissions/permissions.module'; // const client = new DucClient(); +jest.mock('puppeteer', () => ({ + launch: jest.fn().mockResolvedValue({ + newPage: jest.fn().mockResolvedValue({ + goto: jest.fn(), + evaluate: jest.fn(), + close: jest.fn() + }), + close: jest.fn() + }) +})); + const logger = { info: (...args) => args, error: (...args) => args,