@@ -2,7 +2,7 @@ import HmacValidator from "../utils/hmacValidator";
2
2
import { NotificationItem , NotificationRequestItem } from "../typings/notification/models" ;
3
3
import { ApiConstants } from "../constants/apiConstants" ;
4
4
import NotificationRequestService from "../notification/notificationRequest" ;
5
- const fs = require ( 'fs' ) ;
5
+ import { readFileSync } from "fs" ;
6
6
7
7
const key = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00" ;
8
8
const expectedSign = "ZNBPtI+oDyyRrLyD1XirkKnQgIAlFc07Vj27TeHsDRE=" ;
@@ -130,19 +130,19 @@ describe("HMAC Validator", function (): void {
130
130
} ) ;
131
131
132
132
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" ) ;
134
134
const encrypted = hmacValidator . calculateHmac ( data , "11223344D785FBAE710E7F943F307971BB61B21281C98C9129B3D4018A57B2EB" ) ;
135
135
136
136
expect ( encrypted ) . toEqual ( "UVBzHbDayhfT1XgaRGAkuKvxwoxrLoVCBdfi3WZU8lI=" ) ;
137
137
} ) ;
138
138
139
139
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" ) ;
143
143
const isValid = hmacValidator . validateHMACSignature ( hmacKey , hmacSignature , data ) ;
144
144
145
- expect ( isValid ) . toBeTruthy
145
+ expect ( isValid ) . toBeTruthy ;
146
146
} ) ;
147
147
148
148
} ) ;
0 commit comments