test: add more tests

This commit is contained in:
nanov 2019-11-20 11:12:37 +02:00
parent ddd0933c0b
commit 67d74cfa00
11 changed files with 262 additions and 34 deletions

View File

@ -10,6 +10,9 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.xml]
insert_final_newline = false
[*.json]
indent_size = 2

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
# nyc test coverage
.nyc_output
coverage/
# Dependency directories
node_modules/

View File

@ -51,7 +51,6 @@ module.exports = (xml, keys) => ({
transactionKey() {
const keyNodeText = this.doc.getElementsByTagNameNS('urn:org:ebics:H004', 'TransactionKey')[0].textContent;
return Crypto.privateDecrypt(this.keys.e(), Buffer.from(keyNodeText, 'base64'));
},
@ -64,7 +63,7 @@ module.exports = (xml, keys) => ({
orderId() {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = select('//xmlns:header/xmlns:mutable/xmlns:OrderID', this.doc);
const node = select('.//xmlns:header/xmlns:mutable/xmlns:OrderID', this.doc);
return node.length ? node[0].textContent : '';
},

View File

@ -10,6 +10,7 @@
"scripts": {
"lint": "eslint .",
"test": "nyc mocha test/**/*.js",
"coverage": "nyc report --reporter=lcov",
"version": "auto-changelog -p -t changelog-template.hbs && git add CHANGELOG.md"
},
"repository": {

21
test/fixtures/HPB_response.xml vendored Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ebicsKeyManagementResponse xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Revision="1" Version="H004" xsi:schemaLocation="urn:org:ebics:H004 ebics_keymgmt_response_H004.xsd">
<header authenticate="true">
<static/>
<mutable>
<ReturnCode>000000</ReturnCode>
<ReportText>[EBICS_OK] OK</ReportText>
</mutable>
</header>
<body>
<DataTransfer>
<DataEncryptionInfo authenticate="true">
<EncryptionPubKeyDigest Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" Version="E002">nuZyAjQoIvH4MwnrCWB82TC/vcNqigpqPtMXwO1Xk9U=</EncryptionPubKeyDigest>
<TransactionKey>QgfTQqhocARTcpcgySGxn5a+uBuFsHCX0oBINQQIfsgMRR+wEZ3zlXQMUm5GUwwOci2wjkRHJ3PoO4Yd0KzDNWiXFuX/9n00bpnNN5MsTCRgDqJRzZrA1jDxWRBVY/sv3l1gS/ERwyWqub456VZ7DYlXlRA8yp5lormoxftpIt6/Cf0ShmhS8qlUkLYSn/8ugQRl1KRTID5ZSXPjDYAIVZ0izVxblaBYXgs6RH9VvP4uKSn4CFYiFp+alo6EcxFNgMVUnfzaEbsPH/aX9Y3tbdWhATBZSxTT8iMoi2ARhz9VB711aavB8vgzcD6jH3ZtIm+sCb3UC3A/KehEn9GjIA==</TransactionKey>
</DataEncryptionInfo>
<OrderData>xlQf5zxlUo4LwjkoDsh926OISQwn6PhpxF3CkZI34EO84tfK25zLbqriXiqwDycl2YjYrQxbj8B4k1auNe86a+JigQOoBBCL8gvsoxO+NlziPNzf8sP99dQSp436q7KOhVm4gz2ZZT3D3O5FSqpOKsQ0fJku7D76beoxqxUT+hD0UxgsGLsbGgNLzHPalnFJctuaZtqQmo24Uk6hOwLrFJoQwUbPEffU5GGARWrZVxGQr5Zw4zrtLlZzP1RXk9JZFnhx00KvKiaoxAQXxXUC0BeDM97tIMEiaRNbO3ne+mHtK8vXzc305X5yR0B6ocwbFAmzGQ/e6Fyy6XPIGsbXoLjJGod6ayIU1SJGx/JRyOU4cLkjJZLUQMyCdJ6bA5uYf1AePUDvUA3tAOd6W0cC7DPAlwcrWhSZkPLIawequyjO39LTkEcmINEigd4i3sCrG4e1k303gyIKUg79kApl46onW2vruN3DwswunI10JGXxqex7ccvd2JvD6Pc8cAH1RMg8FIucYd//Joh1XK+QkRdIZMWKg4/lkoWmgVN7ssMmrtsKE2pNFAsIRfgxd8bB64sHZ3XKSyZKTk4LnWdJHZopP/xTs9a+/G3Kd/sIsy4W4sIKZCWU8NL11YOaqfwxY/rYNMaQzhAmawFfWvt74iisFG81Wv+Ijja/dPFmbk3Mup2Dfnlfu26MDblC8+aiaPHypmPuzREqGjW/9d2vtLQz0IXX3X6H4pFXneSjKlwXlDk1WGuiOvXH4gmXEpfWTX9rq+rUyskwwL8ssW5eeeyJ5W2LhVKQllOi/bvrAL5kyrfDMxvOuFIBLxBf//xE</OrderData>
</DataTransfer>
<ReturnCode authenticate="true">000000</ReturnCode>
<TimestampBankParameter authenticate="true">2016-08-10T16:16:17.512Z</TimestampBankParameter>
</body>
</ebicsKeyManagementResponse>

22
test/fixtures/HPB_response_data.xml vendored Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<HPBResponseOrderData xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xsi:schemaLocation="urn:org:ebics:H004 ebics_orders_H004.xsd">
<AuthenticationPubKeyInfo>
<PubKeyValue>
<ds:RSAKeyValue>
<ds:Modulus>AJWVHQIfP0H1fr5Y7IjSlDmFksqQ+0E+CjzbEeE6r444LCuSXwbGKF6DJqguyX1qGYxjHRvVtdkNa+GNAtlZnmuPeLHPBUOs5Zx9J5JP4JZOcKd/wnRDIasTkg3NrtZ22tjOrWx26VuR6h7dUH2oJRnFDHmbXoCDMxkqJUNr/TM89p5slJ9Oj5+NAaOzm+7AlwbJ95EI/xc2jEfhp+GdF9CYdS/m2AZaAt79y6QDtBSDdAs0OHTgsOIjbjZkptBF/Gkip2sOordjsChRNLHLDcAOWbsg1NVMuhXs1b6+bCVLXQcGhFydYhqvrXB7pFS0++hlyzqGhbZK5cwEe/v8EJk=</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</PubKeyValue>
<AuthenticationVersion>X002</AuthenticationVersion>
</AuthenticationPubKeyInfo>
<EncryptionPubKeyInfo>
<PubKeyValue>
<ds:RSAKeyValue>
<ds:Modulus>AJWVHQIfP0H1fr5Y7IjSlDmFksqQ+0E+CjzbEeE6r444LCuSXwbGKF6DJqguyX1qGYxjHRvVtdkNa+GNAtlZnmuPeLHPBUOs5Zx9J5JP4JZOcKd/wnRDIasTkg3NrtZ22tjOrWx26VuR6h7dUH2oJRnFDHmbXoCDMxkqJUNr/TM89p5slJ9Oj5+NAaOzm+7AlwbJ95EI/xc2jEfhp+GdF9CYdS/m2AZaAt79y6QDtBSDdAs0OHTgsOIjbjZkptBF/Gkip2sOordjsChRNLHLDcAOWbsg1NVMuhXs1b6+bCVLXQcGhFydYhqvrXB7pFS0++hlyzqGhbZK5cwEe/v8EJk=</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</PubKeyValue>
<EncryptionVersion>E002</EncryptionVersion>
</EncryptionPubKeyInfo>
<HostID>CRSISOTB</HostID>
</HPBResponseOrderData>

13
test/fixtures/INI_reposne.xml vendored Normal file
View File

@ -0,0 +1,13 @@
<h004:ebicsKeyManagementResponse xmlns:h004="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:ebics:H004 ebics_H004.xsd" Version="H004" Revision="1">
<h004:header authenticate="true">
<h004:static />
<h004:mutable>
<h004:OrderID>B004</h004:OrderID>
<h004:ReturnCode>000000</h004:ReturnCode>
<h004:ReportText>[EBICS_OK] OK</h004:ReportText>
</h004:mutable>
</h004:header>
<h004:body>
<h004:ReturnCode authenticate="true">000000</h004:ReturnCode>
</h004:body>
</h004:ebicsKeyManagementResponse>

40
test/fixtures/STA_response_part1.xml vendored Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ebicsResponse xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:ebics:H004 http://www.ebics.org/H004/ebics_response_H004.xsd" Version="H004" Revision="1">
<header authenticate="true">
<static>
<TransactionID>ECD6F062AAEDFA77250526A68CBEC549</TransactionID>
<NumSegments>2</NumSegments>
</static>
<mutable>
<TransactionPhase>Initialisation</TransactionPhase>
<SegmentNumber lastSegment="false">1</SegmentNumber>
<ReturnCode>000000</ReturnCode>
<ReportText>[EBICS_OK] OK</ReportText>
</mutable>
</header>
<AuthSignature>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#xpointer(//*[@authenticate='true'])">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>OnY4VczV+1XfplpMS/SCKFWn+FDMge40X8TJ9pA6HEI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>Qiz8clr/Ym+wLpB8CzTuxKP5rgIR2P4SaX8O4gGZx0Di8Lzd4hsBO3koqIuX11NRZo0RYA5E/IKQCoYLepkcM4QHvLT37YidbrXsTZe6cml/yF8OdyRAcd/9U7AoA9GKENFk4lnBFfZYmM4ADK6wVOCE/ABaOk0NeCDDbxrKA75tfTxwxTvQBfUOHZ87LrZxuQf//L9pzmtI07/7GbsQX8ZceQq40SpBFZn/oRvT/Q38Qu2ZO59MZexJn+BTzlhpfv9fQGF/sgXkdhUkPTEW3nL4j7ehasq3CtySGO2RnEppohEvJ4m07RDtEY3OWyAAZoPFVpvnECM6pOLbIuR40w==</ds:SignatureValue>
</AuthSignature>
<body>
<DataTransfer>
<DataEncryptionInfo authenticate="true">
<EncryptionPubKeyDigest Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" Version="E002">IUW05JB5cuCzRYYa4kIAZ2ehYVrLI3lKvxZvo1uP+ug=</EncryptionPubKeyDigest>
<TransactionKey>CPdd6ODXrCxHWpYrwS/5a3NIZ1R2SDscHHJSONc2I7g8ara7qv5Ra7H03W+336DPQLZQxH+EBRWdE2FQ1vrVTcypK6fkFarmO1dEtQt6Ka89AozC7aQMyp4yGl+zlF+XvFkJXZbRXgoEOPsgcG0xM6nKLXnr1ThYRFOoAasigLDGwqxliyhoR94F9dL7YB8Le/uZeRj78mNp4smkE5ZKKyPhwVx+0IW78YuVCSC2c2qbsMmm4evAvycdpLfuuoG4KVlNMIlvkKeBfMZFELcmeKKm85D2zPYkZ7cqG2IfAAp5qdS6K8P7RY4gtjUhOtP5mi8bZt/ZcjioUmIR9dAMnA==</TransactionKey>
</DataEncryptionInfo>
<OrderData>lJ/v1HvOYAZKTPkxULH4mOcUy01+EaAsxLzCPhtieAo9m5AtU5URdyBVfmclHbtWe3ELb02lR37bChynq0Esqpljxx7CiB+kl/bVs7XkNQQmtGPlh08O7ApJ7AHdKPFFvE+SM2OWpSwUrqJGtmyaU6s+RM66o/3Q0wvKi4y3+Q2jm8nkiWZpPfNt52g4ReE9Ge86o+L+EBOBgZm634L5Z/i6pq908mXBAklPdk1ERdEgWONaOeYYmB70FToplR1gINJEF2CnfAtD/wV+DuQFPDth+EWHqhe3a4xO0d9eJ55ou2QCYOPUC2g/qz1sp7GR74W7P5IWJdmnUEuPFsKJ6OvM+1V8S06jZGDa/QhUGDK8F3G/TMP09W1MsrlQTRr3YQ5H43+pMY7I6Jysze+X9OKZZTTpv4GmYm1USjmraGyMuPF3j9hrlmpttK+1gg2WzytCJO44YsZp9ckls8JNK4bT5uwTuomKZoRgmiIOTcMh4VP7V28TWj2XdF+T6rBFILTvQyXMOzvbe1kLwg2O31JDBdJ8X1fHCYJxKsIrYCSDPz4sha8h7QmHrCSFmjoXb+LUElnbLXZVRkY5/Dc73EM6Es3wAgjwSJK2asRqdqU0PhbS5qpIlgYKsNcb+Wes</OrderData>
</DataTransfer>
<ReturnCode authenticate="true">000000</ReturnCode>
<TimestampBankParameter authenticate="true">2013-12-09T15:14:30.000Z</TimestampBankParameter>
</body>
</ebicsResponse>

40
test/fixtures/STA_response_part2.xml vendored Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ebicsResponse xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:ebics:H004 http://www.ebics.org/H004/ebics_response_H004.xsd" Version="H004" Revision="1">
<header authenticate="true">
<static>
<TransactionID>ECD6F062AAEDFA77250526A68CBEC549</TransactionID>
<NumSegments>1</NumSegments>
</static>
<mutable>
<TransactionPhase>Initialisation</TransactionPhase>
<SegmentNumber lastSegment="true">1</SegmentNumber>
<ReturnCode>000000</ReturnCode>
<ReportText>[EBICS_OK] OK</ReportText>
</mutable>
</header>
<AuthSignature>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#xpointer(//*[@authenticate='true'])">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>OnY4VczV+1XfplpMS/SCKFWn+FDMge40X8TJ9pA6HEI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>Qiz8clr/Ym+wLpB8CzTuxKP5rgIR2P4SaX8O4gGZx0Di8Lzd4hsBO3koqIuX11NRZo0RYA5E/IKQCoYLepkcM4QHvLT37YidbrXsTZe6cml/yF8OdyRAcd/9U7AoA9GKENFk4lnBFfZYmM4ADK6wVOCE/ABaOk0NeCDDbxrKA75tfTxwxTvQBfUOHZ87LrZxuQf//L9pzmtI07/7GbsQX8ZceQq40SpBFZn/oRvT/Q38Qu2ZO59MZexJn+BTzlhpfv9fQGF/sgXkdhUkPTEW3nL4j7ehasq3CtySGO2RnEppohEvJ4m07RDtEY3OWyAAZoPFVpvnECM6pOLbIuR40w==</ds:SignatureValue>
</AuthSignature>
<body>
<DataTransfer>
<DataEncryptionInfo authenticate="true">
<EncryptionPubKeyDigest Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" Version="E002">IUW05JB5cuCzRYYa4kIAZ2ehYVrLI3lKvxZvo1uP+ug=</EncryptionPubKeyDigest>
<TransactionKey>CPdd6ODXrCxHWpYrwS/5a3NIZ1R2SDscHHJSONc2I7g8ara7qv5Ra7H03W+336DPQLZQxH+EBRWdE2FQ1vrVTcypK6fkFarmO1dEtQt6Ka89AozC7aQMyp4yGl+zlF+XvFkJXZbRXgoEOPsgcG0xM6nKLXnr1ThYRFOoAasigLDGwqxliyhoR94F9dL7YB8Le/uZeRj78mNp4smkE5ZKKyPhwVx+0IW78YuVCSC2c2qbsMmm4evAvycdpLfuuoG4KVlNMIlvkKeBfMZFELcmeKKm85D2zPYkZ7cqG2IfAAp5qdS6K8P7RY4gtjUhOtP5mi8bZt/ZcjioUmIR9dAMnA==</TransactionKey>
</DataEncryptionInfo>
<OrderData>lJ/v1HvOYAZKTPkxULH4mOcUy01+EaAsxLzCPhtieAo9m5AtU5URdyBVfmclHbtWe3ELb02lR37bChynq0Esqpljxx7CiB+kl/bVs7XkNQQmtGPlh08O7ApJ7AHdKPFFvE+SM2OWpSwUrqJGtmyaU6s+RM66o/3Q0wvKi4y3+Q2jm8nkiWZpPfNt52g4ReE9Ge86o+L+EBOBgZm634L5Z/i6pq908mXBAklPdk1ERdEgWONaOeYYmB70FToplR1gINJEF2CnfAtD/wV+DuQFPDth+EWHqhe3a4xO0d9eJ55ou2QCYOPUC2g/qz1sp7GR74W7P5IWJdmnUEuPFsKJ6OvM+1V8S06jZGDa/QhUGDK8F3G/TMP09W1MsrlQTRr3YQ5H43+pMY7I6Jysze+X9OKZZTTpv4GmYm1USjmraGyMuPF3j9hrlmpttK+1gg2WzytCJO44YsZp9ckls8JNK4bT5uwTuomKZoRgmiIOTcMh4VP7V28TWj2XdF+T6rBFILTvQyXMOzvbe1kLwg2O31JDBdJ8X1fHCYJxKsIrYCSDPz4sha8h7QmHrCSFmjoXb+LUElnbLXZVRkY5/Dc73EM6Es3wAgjwSJK2asRqdqU0PhbS5qpIlgYKsNcb+Wes</OrderData>
</DataTransfer>
<ReturnCode authenticate="true">000000</ReturnCode>
<TimestampBankParameter authenticate="true">2013-12-09T15:14:30.000Z</TimestampBankParameter>
</body>
</ebicsResponse>

21
test/unit/middlewares.js Normal file
View File

@ -0,0 +1,21 @@
'use strict';
/* eslint-env node, mocha */
const { assert } = require('chai');
const response = require('../../lib/middleware/response');
const serializer = require('../../lib/middleware/serializer');
const signer = require('../../lib/middleware/signer');
describe('Middlewares', () => {
describe('Response Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => response('H003')));
});
describe('Signer Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => signer('H003')));
});
describe('Signer Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => serializer('H003')));
});
});

View File

@ -2,44 +2,111 @@
/* eslint-env node, mocha */
const { readFileSync } = require('fs');
const { join, resolve } = require('path');
const { assert } = require('chai');
const H004Response = require('../../lib/orders/H004/response');
const ebics = require('../../');
const client = new ebics.Client({
url: 'https://iso20022test.credit-suisse.com/ebicsweb/ebicsweb',
partnerId: 'CRS04381',
userId: 'CRS04381',
hostId: 'CRSISOTB',
passphrase: 'test',
keyStorage: ebics.fsKeysStorage(resolve(__dirname, '../support/TEST_KEYS.key')),
});
const buildResponse = (xmlPath) => {
const response = H004Response('<xml/>', {});
const xml = readFileSync(xmlPath, { encoding: 'utf8' });
response.orderData = () => xml;
return response;
};
const fixtures = {
HPB: async () => H004Response(readFileSync(join(__dirname, '../fixtures/HPB_response.xml'), { encoding: 'utf8' }), await client.keys()),
HPB_DATA: () => buildResponse(join(__dirname, '../fixtures/HPB_response_data.xml')),
INI: () => H004Response(readFileSync(join(__dirname, '../fixtures/INI_reposne.xml'), { encoding: 'utf8' }), client.keys()),
STA_1: () => H004Response(readFileSync(join(__dirname, '../fixtures/STA_response_part1.xml'), { encoding: 'utf8' }), client.keys()),
STA_2: () => H004Response(readFileSync(join(__dirname, '../fixtures/STA_response_part2.xml'), { encoding: 'utf8' }), client.keys()),
x002mod: 'AJWVHQIfP0H1fr5Y7IjSlDmFksqQ+0E+CjzbEeE6r444LCuSXwbGKF6DJqguyX1qGYxjHRvVtdkNa+GNAtlZnmuPeLHPBUOs5Zx9J5JP4JZOcKd/wnRDIasTkg3NrtZ22tjOrWx26VuR6h7dUH2oJRnFDHmbXoCDMxkqJUNr/TM89p5slJ9Oj5+NAaOzm+7AlwbJ95EI/xc2jEfhp+GdF9CYdS/m2AZaAt79y6QDtBSDdAs0OHTgsOIjbjZkptBF/Gkip2sOordjsChRNLHLDcAOWbsg1NVMuhXs1b6+bCVLXQcGhFydYhqvrXB7pFS0++hlyzqGhbZK5cwEe/v8EJk=',
e002mod: 'AJWVHQIfP0H1fr5Y7IjSlDmFksqQ+0E+CjzbEeE6r444LCuSXwbGKF6DJqguyX1qGYxjHRvVtdkNa+GNAtlZnmuPeLHPBUOs5Zx9J5JP4JZOcKd/wnRDIasTkg3NrtZ22tjOrWx26VuR6h7dUH2oJRnFDHmbXoCDMxkqJUNr/TM89p5slJ9Oj5+NAaOzm+7AlwbJ95EI/xc2jEfhp+GdF9CYdS/m2AZaAt79y6QDtBSDdAs0OHTgsOIjbjZkptBF/Gkip2sOordjsChRNLHLDcAOWbsg1NVMuhXs1b6+bCVLXQcGhFydYhqvrXB7pFS0++hlyzqGhbZK5cwEe/v8EJk=',
};
describe('H004 response parsing', () => {
it('parses bank keys', () => {
const response = H004Response('<xml/>', {});
const x002mod = 'ntbX6WFjAJP5RyH4ogDG/26wZGzEJXsTudyvcgXmUdk1AExCNqArXDiSlGXpVNq4BKddUMFUmVOyvkdNckPRV2mk3uHNCE5T3tFKQI3FlwHSJHvPSpb9gtHnsK03jByMigWjhTKvsjIdfLVay5m5Bctxq9+5JMHwlNk7MlVXBQcqaFiHFFS1lPfA3Wk1bptPeeGyYcP0+U798oQWnCABKwS8hmYcp5xBtozGoRj9L/NDE68pdP8o/wTKNwT4Jo5nQKYfDsgO4R+z9vVv37Htp6bWhK8Jw3tpkcd3JnkYWx+Ylg0XBpg8LfjFhY2Jc7FqLlx0Bn0Y3PRLI1apxgC85w==';
const e002mod = '4eOGrzcJHVzbEgZTmyPYUIq9kFoua8Ure1Mvyq6XlawFgCWskfu/xSKNLIMJ7H675wl/5y0Oy16P/b6pJEhWrzOw8omW46PBDTaXw9BDYBTuBblluz1yUnzpgfblP8gkRmxAo+QMIskmwdSzuZMiJcLNSzu/bkmLHK2RdrVYMAZLlB6QXTykdenPZtNmc2z4VU6TRmGljAwg2VUNF6iQoucbzDUuca+yUo3fiXZp69nfXv81X2ND+p1ir6zQpx7tbOdfauw0sEKI/Z/lC+E4fMrMlh/ZvOxSYUMA55J4liC3aUV3mTR3dPJHWu1aD1a7EfJnNw0eHLwlB+36qfgGuw==';
response.orderData = () => `<?xml version="1.0" encoding="UTF-8"?>
<HPBResponseOrderData xmlns="urn:org:ebics:H004" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<AuthenticationPubKeyInfo>
<PubKeyValue>
<ds:RSAKeyValue>
<ds:Modulus>${x002mod}</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
<TimeStamp>2015-02-25T08:01:13.061Z</TimeStamp>
</PubKeyValue>
<AuthenticationVersion>X002</AuthenticationVersion>
</AuthenticationPubKeyInfo>
<EncryptionPubKeyInfo>
<PubKeyValue>
<ds:RSAKeyValue>
<ds:Modulus>${e002mod}</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
<TimeStamp>2015-02-25T08:01:12.344Z</TimeStamp>
</PubKeyValue>
<EncryptionVersion>E002</EncryptionVersion>
</EncryptionPubKeyInfo>
<HostID>SBKPR01</HostID>
</HPBResponseOrderData>`;
const response = fixtures.HPB_DATA();
const bankKeys = response.bankKeys();
assert.equal(bankKeys.bankX002.mod.toString('base64'), x002mod);
assert.equal(bankKeys.bankE002.mod.toString('base64'), e002mod);
assert.equal(bankKeys.bankX002.mod.toString('base64'), fixtures.x002mod);
assert.equal(bankKeys.bankE002.mod.toString('base64'), fixtures.e002mod);
});
it('detects unsegmented response', () => {
const response = fixtures.HPB_DATA();
assert.equal(response.isSegmented(), false);
assert.equal(response.isLastSegment(), false);
});
it('detects segmented response', () => {
const responsePart1 = fixtures.STA_1();
const responsePart2 = fixtures.STA_2();
assert.equal(responsePart1.isSegmented(), true);
assert.equal(responsePart1.isLastSegment(), false);
assert.equal(responsePart2.isSegmented(), true);
assert.equal(responsePart2.isLastSegment(), true);
});
it('parses OrderID', () => {
const response = fixtures.INI();
assert.equal(response.orderId(), 'B004');
});
it('parses BuissnessCode', () => {
const response = fixtures.INI();
const code = response.businessCode();
assert.equal(code, '000000');
assert.equal(response.businessSymbol(code), 'EBICS_OK');
assert.equal(response.businessMeaning(code), 'No technical errors occurred during processing of the EBICS request');
assert.equal(response.businessShortText(code), 'OK');
});
it('parses TechnicalCode', () => {
const response = fixtures.INI();
const code = response.technicalCode();
assert.equal(code, '000000');
assert.equal(response.technicalSymbol(code), '[EBICS_OK] OK');
assert.equal(response.technicalMeaning(code), 'No technical errors occurred during processing of the EBICS request');
assert.equal(response.technicalShortText(code), 'OK');
});
it('parses TransactionID', () => {
const response = fixtures.STA_1();
const code = response.transactionId();
assert.equal(code, 'ECD6F062AAEDFA77250526A68CBEC549');
});
it('parses TransactionKey', async () => {
const response = await fixtures.HPB();
const code = response.transactionKey().toString('base64');
assert.equal(code, '2OTepxiy49uayuzZlYFf8Q==');
});
it('parses OrderData', async () => {
const response = await fixtures.HPB();
const orderBuffer = response.orderData();
assert.deepEqual(orderBuffer, readFileSync(join(__dirname, '../fixtures/HPB_response_data.xml')));
});
it('generates XML', async () => {
const response = await fixtures.HPB();
const xmlString = response.toXML().replace('\\n', '\n');
assert.deepEqual(xmlString, readFileSync(join(__dirname, '../fixtures/HPB_response.xml'), { encoding: 'utf8' }));
});
});