@@ -2,7 +2,7 @@ import HmacValidator from "../utils/hmacValidator";
22import { NotificationItem , NotificationRequestItem } from "../typings/notification/models" ;
33import { ApiConstants } from "../constants/apiConstants" ;
44import NotificationRequestService from "../notification/notificationRequest" ;
5- const fs = require ( 'fs' ) ;
5+ import { readFileSync } from "fs" ;
66
77const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00" ;
88const expectedSign = "ZNBPtI+oDyyRrLyD1XirkKnQgIAlFc07Vj27TeHsDRE=" ;
@@ -130,19 +130,19 @@ describe("HMAC Validator", function (): void {
130130 } ) ;
131131
132132 it ( "should calculate Banking webhook correctly" , function ( ) : void {
133- const data = fs . readFileSync ( ' ./src/__mocks__/notification/accountHolderCreated.json' , ' utf8' ) ;
133+ const data = readFileSync ( " ./src/__mocks__/notification/accountHolderCreated.json" , " utf8" ) ;
134134 const encrypted = hmacValidator . calculateHmac ( data , "11223344D785FBAE710E7F943F307971BB61B21281C98C9129B3D4018A57B2EB" ) ;
135135
136136 expect ( encrypted ) . toEqual ( "UVBzHbDayhfT1XgaRGAkuKvxwoxrLoVCBdfi3WZU8lI=" ) ;
137137 } ) ;
138138
139139 it ( "should validate Banking webhook correctly" , function ( ) : void {
140- const hmacKey = "11223344D785FBAE710E7F943F307971BB61B21281C98C9129B3D4018A57B2EB"
141- const hmacSignature = "UVBzHbDayhfT1XgaRGAkuKvxwoxrLoVCBdfi3WZU8lI="
142- const data = fs . readFileSync ( ' ./src/__mocks__/notification/accountHolderCreated.json' , ' utf8' ) ;
140+ const hmacKey = "11223344D785FBAE710E7F943F307971BB61B21281C98C9129B3D4018A57B2EB" ;
141+ const hmacSignature = "UVBzHbDayhfT1XgaRGAkuKvxwoxrLoVCBdfi3WZU8lI=" ;
142+ const data = readFileSync ( " ./src/__mocks__/notification/accountHolderCreated.json" , " utf8" ) ;
143143 const isValid = hmacValidator . validateHMACSignature ( hmacKey , hmacSignature , data ) ;
144144
145- expect ( isValid ) . toBeTruthy
145+ expect ( isValid ) . toBeTruthy ;
146146 } ) ;
147147
148148} ) ;
0 commit comments