mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-10 15:17:44 +00:00
feat: add test controller for integartion
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -53,3 +53,5 @@ pids
|
|||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
|
||||||
|
zod-certs
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"exclude": "**/*.md"
|
"exclude": "**/*.md"
|
||||||
},
|
},
|
||||||
{ "include": "common/modules/**/templates/**/*", "watchAssets": true },
|
{ "include": "common/modules/**/templates/**/*", "watchAssets": true },
|
||||||
|
{ "include": "common/modules/neoleap/zod-certs" },
|
||||||
"i18n",
|
"i18n",
|
||||||
"files"
|
"files"
|
||||||
]
|
]
|
||||||
|
@ -11,7 +11,7 @@ export class NeoTestController {
|
|||||||
|
|
||||||
@Get('inquire-application')
|
@Get('inquire-application')
|
||||||
async inquireApplication() {
|
async inquireApplication() {
|
||||||
return this.neoleapService.inquireApplication('1234567890');
|
return this.neoleapService.inquireApplication('1');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('create-application')
|
@Get('create-application')
|
||||||
|
@ -2,7 +2,10 @@ import { HttpService } from '@nestjs/axios';
|
|||||||
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';
|
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { ClassConstructor, plainToInstance } from 'class-transformer';
|
import { ClassConstructor, plainToInstance } from 'class-transformer';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
import { Agent } from 'https';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import path from 'path';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { CountriesNumericISO } from '~/common/constants';
|
import { CountriesNumericISO } from '~/common/constants';
|
||||||
import { Customer } from '~/customer/entities';
|
import { Customer } from '~/customer/entities';
|
||||||
@ -16,10 +19,12 @@ export class NeoLeapService {
|
|||||||
private readonly apiKey: string;
|
private readonly apiKey: string;
|
||||||
private readonly useMock: boolean;
|
private readonly useMock: boolean;
|
||||||
private readonly institutionCode = '1100';
|
private readonly institutionCode = '1100';
|
||||||
|
useLocalCert: boolean;
|
||||||
constructor(private readonly httpService: HttpService, private readonly configService: ConfigService) {
|
constructor(private readonly httpService: HttpService, private readonly configService: ConfigService) {
|
||||||
this.baseUrl = this.configService.getOrThrow<string>('NEOLEAP_BASE_URL');
|
this.baseUrl = this.configService.getOrThrow<string>('NEOLEAP_BASE_URL');
|
||||||
this.apiKey = this.configService.getOrThrow<string>('NEOLEAP_API_KEY');
|
this.apiKey = this.configService.getOrThrow<string>('NEOLEAP_API_KEY');
|
||||||
this.useMock = [true, 'true'].includes(this.configService.get<boolean>('USE_MOCK', false));
|
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) {
|
async createApplication(customer: Customer) {
|
||||||
@ -148,7 +153,16 @@ export class NeoLeapService {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: `${this.apiKey}`,
|
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]) {
|
if (response.data?.ResponseHeader.ResponseCode !== '000' || !response.data[responseKey]) {
|
||||||
|
Reference in New Issue
Block a user