Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
add test case for null xt response
Browse files Browse the repository at this point in the history
  • Loading branch information
norkator committed Jun 14, 2024
1 parent 0d5298c commit 0641f88
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/bank_statement/XTApplicationResponse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,43 @@ describe('XTApplicationResponse', async () => {
const xtResponse = new XTApplicationResponse(xt, xtApplicationResponseMessage);
const parsed = await xtResponse.parseBody();

expect(parsed.FileReference).to.equal('1536794526');
expect(parsed.TargetId).to.equal('NONE');
expect(parsed.UserFilename).to.equal('STOL001.OLTCX60H.CAMT053.PS');
expect(parsed.FileType).to.equal('XT');
expect(parsed.FileTimestamp).to.equal('2023-06-30T21:23:44.678+03:00');
expect(parsed.Status).to.equal('NEW');
expect(parsed.ForwardedTimestamp).to.equal('2023-06-30T21:23:44.678+03:00');
expect(parsed.Deletable).to.equal('false');
expect(parsed!).is.not.null;
expect(parsed!.FileReference).to.equal('1536794526');
expect(parsed!.TargetId).to.equal('NONE');
expect(parsed!.UserFilename).to.equal('STOL001.OLTCX60H.CAMT053.PS');
expect(parsed!.FileType).to.equal('XT');
expect(parsed!.FileTimestamp).to.equal('2023-06-30T21:23:44.678+03:00');
expect(parsed!.Status).to.equal('NEW');
expect(parsed!.ForwardedTimestamp).to.equal('2023-06-30T21:23:44.678+03:00');
expect(parsed!.Deletable).to.equal('false');
});

it('should return expected empty bank statement file when there is no descriptor details', async () => {
const xtApplicationResponseMessage = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><soapenv:Envelope xmlns:cor="http://bxd.fi/CorporateFileService" xmlns:mod="http://model.bxd.fi" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-48addc8c-c297-45e3-b15a-91f9d1660ec4"><cor:downloadFileListout><mod:ResponseHeader><mod:SenderId>97357407</mod:SenderId><mod:RequestId>123456</mod:RequestId><mod:Timestamp>2023-08-28T09:43:37.829</mod:Timestamp><mod:ResponseCode>00</mod:ResponseCode><mod:ResponseText>OK</mod:ResponseText><mod:ReceiverId></mod:ReceiverId></mod:ResponseHeader><mod:ApplicationResponse>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PEFwcGxpY2F0aW9uUmVzcG9uc2UgeG1sbnM9Imh0dHA6Ly9ieGQuZmkveG1sZGF0YS8iIHhtbG5zOm5zMj0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI+PEN1c3RvbWVySWQ+OTczNTc0MDc8L0N1c3RvbWVySWQ+PFRpbWVzdGFtcD4yMDIzLTA4LTI4VDA5OjQzOjM3LjcwMyswMzowMDwvVGltZXN0YW1wPjxSZXNwb25zZUNvZGU+MDA8L1Jlc3BvbnNlQ29kZT48UmVzcG9uc2VUZXh0Pk9LPC9SZXNwb25zZVRleHQ+PEV4ZWN1dGlvblNlcmlhbD4xMjM0NTY8L0V4ZWN1dGlvblNlcmlhbD48RW5jcnlwdGVkPmZhbHNlPC9FbmNyeXB0ZWQ+PENvbXByZXNzZWQ+ZmFsc2U8L0NvbXByZXNzZWQ+PEZpbGVUeXBlIHhtbG5zOnhzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeHNpOnR5cGU9InhzOnN0cmluZyI+WFQ8L0ZpbGVUeXBlPjwvQXBwbGljYXRpb25SZXNwb25zZT4K</mod:ApplicationResponse></cor:downloadFileListout></soapenv:Body></soapenv:Envelope>';

const xt: XTInterface = {
userParams: {
bank: 'Samlink',
environment: 'PRODUCTION',
customerId: '97357407',
Base64EncodedRootCA: '',
rejectUnauthorized: true,
},
verifyResponseSignature: false,
Base64EncodedBankCsr: '',
requestUrl: '',
Timestamp: '2021-08-06T01:01:48+03:00',
SoftwareId: {name: 'TEST', version: '0.0.0'} as SoftwareIdInterface,
ExecutionSerial: '',
Base64EncodedClientCsr: '',
RequestId: '123456',
language: 'FI',
};

const xtResponse = new XTApplicationResponse(xt, xtApplicationResponseMessage);
const parsed = await xtResponse.parseBody();

expect(parsed!).to.be.null;
});

});
Expand Down

0 comments on commit 0641f88

Please sign in to comment.