feat: add test controller for integartion

This commit is contained in:
Abdalhamid Alhamad
2025-06-04 10:04:45 +03:00
parent 1ea1f42169
commit d1a6d3e715
4 changed files with 18 additions and 1 deletions

2
.gitignore vendored
View File

@ -53,3 +53,5 @@ pids
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
zod-certs

View File

@ -11,6 +11,7 @@
"exclude": "**/*.md"
},
{ "include": "common/modules/**/templates/**/*", "watchAssets": true },
{ "include": "common/modules/neoleap/zod-certs" },
"i18n",
"files"
]

View File

@ -11,7 +11,7 @@ export class NeoTestController {
@Get('inquire-application')
async inquireApplication() {
return this.neoleapService.inquireApplication('1234567890');
return this.neoleapService.inquireApplication('1');
}
@Get('create-application')

View File

@ -2,7 +2,10 @@ import { HttpService } from '@nestjs/axios';
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ClassConstructor, plainToInstance } from 'class-transformer';
import { readFileSync } from 'fs';
import { Agent } from 'https';
import moment from 'moment';
import path from 'path';
import { v4 as uuid } from 'uuid';
import { CountriesNumericISO } from '~/common/constants';
import { Customer } from '~/customer/entities';
@ -16,10 +19,12 @@ export class NeoLeapService {
private readonly apiKey: string;
private readonly useMock: boolean;
private readonly institutionCode = '1100';
useLocalCert: boolean;
constructor(private readonly httpService: HttpService, private readonly configService: ConfigService) {
this.baseUrl = this.configService.getOrThrow<string>('NEOLEAP_BASE_URL');
this.apiKey = this.configService.getOrThrow<string>('NEOLEAP_API_KEY');
this.useMock = [true, 'true'].includes(this.configService.get<boolean>('USE_MOCK', false));
this.useLocalCert = this.configService.get<boolean>('USE_LOCAL_CERT', false);
}
async createApplication(customer: Customer) {
@ -148,7 +153,16 @@ export class NeoLeapService {
headers: {
'Content-Type': 'application/json',
Authorization: `${this.apiKey}`,
Host: 'apigw-uat.neoleap.com.sa',
},
httpsAgent: new Agent({
rejectUnauthorized: false, // Disable SSL verification for development purposes
ca: this.useLocalCert ? readFileSync(path.join(__dirname, '../zod-certs/My_CA_Bundle.ca-bundle')) : undefined,
cert: this.useLocalCert
? readFileSync(path.join(__dirname, '../zod-certs/gw-dev_zodwallet_com.crt'))
: undefined,
key: this.useLocalCert ? readFileSync(path.join(__dirname, '../zod-certs/server.key')) : undefined,
}),
});
if (response.data?.ResponseHeader.ResponseCode !== '000' || !response.data[responseKey]) {