test: add additional tests

This commit is contained in:
nanov 2019-11-20 14:42:22 +02:00
parent a10a3a8d63
commit 6d73ef77d4
5 changed files with 401 additions and 5 deletions

164
.test_tmp/test_letter.html Normal file
View File

@ -0,0 +1,164 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="UTF-8" />
<title>EBICS ini</title>
</head>
<body>
<div>
<h2>EBICS-Initialisierungsbrief (INI)</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:37:51</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
<p>Öffentlicher Schlüssel für die elektronische Unterschrift (A006)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>AB E6 54 CA EF B8 AD 81 C2 79 74 9C 42 39 82 A7 A4 1C 76 C8 00 69 68 90 79 59 22 DA 6F 1B C6 12 DA B1 32 8F 97 57 D0 71 2F 09 90 63 96 CA 80 00 8B D3 B8 1A D9 D2 91 14 08 84 BA F7 CF 78 6D E6 40 74 7B FF 48 44 9D D6 DE 1D 9A F3 07 F4 48 AC A2 3C E2 2C 79 34 98 59 E3 48 64 EF 9E E2 C4 9C BC CE DA 1E 31 EC 4D 51 85 62 05 6B FC CB 8D B1 09 DF 17 3C 2C 68 D4 C7 3F 15 BF 4C A6 65 E4 D9 A3 CD 3E 3F 1F 20 16 5E A2 27 93 35 86 DE D7 A8 5D 8F E1 0C A5 02 AF C7 7B 51 9C D0 00 5C 2D 46 E8 42 D3 2F 8A 8C 31 C2 ED 61 01 4F B5 B2 E7 3E 11 18 8C D7 83 23 1E D5 24 BE A9 A4 5C 56 8C CC 52 75 E1 15 63 39 90 AB 36 CE 30 1D 3B 50 85 7D CE 7A 72 77 67 77 4C 5E 37 BE 95 31 91 A7 51 A7 BC C6 C6 BD 2B 85 3D 08 29 90 B1 F6 77 2F 23 9F FD 2A 03 03 04 E1 CB F6 66 6A D9 EC B5 66 60 89</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>85 F0 4F 8B 97 6A F0 E2 FD 9F 21 2B 0B B3 A2 7A 97 B3 BB 57 B3 1B 55 14 F7 ED B5 CB CD E4 FE 79</code>
</p>
<p>Ich bestätige hiermit den obigen öffentlichen Schlüssel für meine elektronische Unterschrift.</p>
<br/>
<br/>
<br/>
<br/>
<table>
<tr>
<td>_________________________</td>
<td>_________________________</td>
<td>_________________________</td>
</tr>
<tr>
<td>Ort/Datum</td>
<td>Name/Firma</td>
<td>Unterschrift</td>
</tr>
</table>
</div>
<div style="page-break-after:always"></div>
<h2>EBICS-Initialisierungsbrief (HIA) - Seite 1/2</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:37:51</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
<div>
<p>Öffentlicher Authentifikationsschlüssel (X002)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>8A ED FC 0F 2C 86 EA E3 07 D9 0D 75 DD E6 25 4F 20 40 41 43 D6 22 C0 59 A9 38 F6 54 42 74 ED 5C 38 C4 6C 63 F2 0F A2 65 85 D9 58 1A 1E F5 1E C4 9E E3 66 5B 67 6B 37 B0 FA BD 8C FE 12 D3 F0 3A C8 23 22 56 3F 30 B0 FB 70 C5 7B 17 41 15 A8 EE 54 F3 1F AF DE 13 7E 96 38 AF 9B 69 28 22 1F 9A 7C C4 C6 1D 35 59 66 40 81 7F D7 48 DA B9 51 EF A9 0C 96 C5 7A 55 25 66 A5 63 B6 4A 45 F0 97 0F 56 60 18 5B CE 08 A2 7D 87 64 18 A2 4A E1 B3 8E 75 24 3F FC AC 23 A5 33 BF 0C 41 E3 96 B5 D2 54 CA 37 07 40 A9 E3 2B 01 17 A6 21 AE 07 1E 52 0A 00 E1 95 F3 BE BC 19 EA E9 90 48 17 38 60 DE 68 BD 85 36 37 59 14 E0 BC 07 C5 B8 50 0A 87 87 90 13 91 6C 4F 03 2B 40 27 14 2B 7F A9 D7 71 12 57 E5 A9 72 CE 16 B7 7B 5E 7D A2 52 D6 CE 9D 39 DA 44 C0 41 EF 02 37 7B 93 98 CC 35 D8 06 D1 79 57</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>F8 3B D7 EB 6F 2B 48 4B 2B 0A BD CA C7 EF F8 56 11 D1 90 32 D6 CC 67 3B 8A 3E 74 F5 F8 B4 E1 AA</code>
</p>
<p> Fortsetzung auf Seite 2 ...</p>
<div style="page-break-after:always"></div>
<h2>EBICS-Initialisierungsbrief (HIA) - Seite 2/2</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:37:51</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
</div>
<div>
<p>Öffentlicher Verschlüsselungsschlüssel (E002)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>93 10 E9 40 2A B1 77 DB 31 C7 EB 13 5A E6 21 FD 6B 18 2B 74 40 67 B1 C9 6D B6 09 4A 1D CD F0 A7 DC 51 A4 53 EF AE 14 0D 9E A0 FB E4 EE D0 2E CF 6C 4C 5E 99 83 F3 A3 8E C3 FE F5 C1 DA E2 E6 52 96 A1 5B 9C 10 2D D1 F1 A2 0F 8E 3E 5D 81 55 DF 19 11 5B 5E 62 DB 95 56 0E 19 4C EF F3 87 50 EB 5F B7 42 3C 5D CB 47 51 81 E7 3F 39 6A 4A CA 6E 29 55 2B 22 14 FE 24 DA 5D DB 0C 99 D2 61 7A FB 40 B7 61 B8 82 89 BE 59 4C 64 92 9A F2 5E 82 62 3A 98 11 61 A3 77 0F 13 38 5D FD 13 BD 9C 4A 96 F9 34 8A 3B 99 4D 25 7B 1B A8 3F 90 F7 6F 9D 09 74 DB 4C B7 27 A3 0B EC 7C 05 E5 F3 1C F7 C2 59 0D 3A 57 86 D5 AD AF 1E CC 84 9F B8 4C DF 8A 35 22 CF D5 B8 12 2B 44 E4 12 BE 26 F7 D7 31 31 31 BB 3D 3C 49 7E C6 AF 44 4D 00 1F FC 04 84 2F 10 8B 2C 78 15 0F 22 46 70 78 2B 25 56 16 36 FB 9F</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>9E E6 72 02 34 28 22 F1 F8 33 09 EB 09 60 7C D9 30 BF BD C3 6A 8A 0A 6A 3E D3 17 C0 ED 57 93 D5</code>
</p>
<p>Ich bestätige hiermit die obigen öffentlichen Schlüssel für meinen EBICS-Zugang.</p>
<br/>
<br/>
<br/>
<br/>
<table>
<tr>
<td>_________________________</td>
<td>_________________________</td>
<td>_________________________</td>
</tr>
<tr>
<td>Ort/Datum</td>
<td>Name/Firma</td>
<td>Unterschrift</td>
</tr>
</table>
</div>
</body>
</html>

164
test/fixtures/Letter_DE.html vendored Normal file
View File

@ -0,0 +1,164 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta charset="UTF-8" />
<title>EBICS ini</title>
</head>
<body>
<div>
<h2>EBICS-Initialisierungsbrief (INI)</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:14:03</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
<p>Öffentlicher Schlüssel für die elektronische Unterschrift (A006)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>AB E6 54 CA EF B8 AD 81 C2 79 74 9C 42 39 82 A7 A4 1C 76 C8 00 69 68 90 79 59 22 DA 6F 1B C6 12 DA B1 32 8F 97 57 D0 71 2F 09 90 63 96 CA 80 00 8B D3 B8 1A D9 D2 91 14 08 84 BA F7 CF 78 6D E6 40 74 7B FF 48 44 9D D6 DE 1D 9A F3 07 F4 48 AC A2 3C E2 2C 79 34 98 59 E3 48 64 EF 9E E2 C4 9C BC CE DA 1E 31 EC 4D 51 85 62 05 6B FC CB 8D B1 09 DF 17 3C 2C 68 D4 C7 3F 15 BF 4C A6 65 E4 D9 A3 CD 3E 3F 1F 20 16 5E A2 27 93 35 86 DE D7 A8 5D 8F E1 0C A5 02 AF C7 7B 51 9C D0 00 5C 2D 46 E8 42 D3 2F 8A 8C 31 C2 ED 61 01 4F B5 B2 E7 3E 11 18 8C D7 83 23 1E D5 24 BE A9 A4 5C 56 8C CC 52 75 E1 15 63 39 90 AB 36 CE 30 1D 3B 50 85 7D CE 7A 72 77 67 77 4C 5E 37 BE 95 31 91 A7 51 A7 BC C6 C6 BD 2B 85 3D 08 29 90 B1 F6 77 2F 23 9F FD 2A 03 03 04 E1 CB F6 66 6A D9 EC B5 66 60 89</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>85 F0 4F 8B 97 6A F0 E2 FD 9F 21 2B 0B B3 A2 7A 97 B3 BB 57 B3 1B 55 14 F7 ED B5 CB CD E4 FE 79</code>
</p>
<p>Ich bestätige hiermit den obigen öffentlichen Schlüssel für meine elektronische Unterschrift.</p>
<br/>
<br/>
<br/>
<br/>
<table>
<tr>
<td>_________________________</td>
<td>_________________________</td>
<td>_________________________</td>
</tr>
<tr>
<td>Ort/Datum</td>
<td>Name/Firma</td>
<td>Unterschrift</td>
</tr>
</table>
</div>
<div style="page-break-after:always"></div>
<h2>EBICS-Initialisierungsbrief (HIA) - Seite 1/2</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:14:03</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
<div>
<p>Öffentlicher Authentifikationsschlüssel (X002)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>8A ED FC 0F 2C 86 EA E3 07 D9 0D 75 DD E6 25 4F 20 40 41 43 D6 22 C0 59 A9 38 F6 54 42 74 ED 5C 38 C4 6C 63 F2 0F A2 65 85 D9 58 1A 1E F5 1E C4 9E E3 66 5B 67 6B 37 B0 FA BD 8C FE 12 D3 F0 3A C8 23 22 56 3F 30 B0 FB 70 C5 7B 17 41 15 A8 EE 54 F3 1F AF DE 13 7E 96 38 AF 9B 69 28 22 1F 9A 7C C4 C6 1D 35 59 66 40 81 7F D7 48 DA B9 51 EF A9 0C 96 C5 7A 55 25 66 A5 63 B6 4A 45 F0 97 0F 56 60 18 5B CE 08 A2 7D 87 64 18 A2 4A E1 B3 8E 75 24 3F FC AC 23 A5 33 BF 0C 41 E3 96 B5 D2 54 CA 37 07 40 A9 E3 2B 01 17 A6 21 AE 07 1E 52 0A 00 E1 95 F3 BE BC 19 EA E9 90 48 17 38 60 DE 68 BD 85 36 37 59 14 E0 BC 07 C5 B8 50 0A 87 87 90 13 91 6C 4F 03 2B 40 27 14 2B 7F A9 D7 71 12 57 E5 A9 72 CE 16 B7 7B 5E 7D A2 52 D6 CE 9D 39 DA 44 C0 41 EF 02 37 7B 93 98 CC 35 D8 06 D1 79 57</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>F8 3B D7 EB 6F 2B 48 4B 2B 0A BD CA C7 EF F8 56 11 D1 90 32 D6 CC 67 3B 8A 3E 74 F5 F8 B4 E1 AA</code>
</p>
<p> Fortsetzung auf Seite 2 ...</p>
<div style="page-break-after:always"></div>
<h2>EBICS-Initialisierungsbrief (HIA) - Seite 2/2</h2>
<table>
<tr>
<td>Datum</td>
<td>2019-11-20</td>
</tr>
<tr>
<td>Uhrzeit</td>
<td>14:14:03</td>
</tr>
<tr>
<td>Empfänger</td>
<td>Credit Suisse AG</td>
</tr>
<tr>
<td>User-ID</td>
<td>CRS04381</td>
</tr>
<tr>
<td>Kunden-ID</td>
<td>CRS04381</td>
</tr>
</table>
</div>
<div>
<p>Öffentlicher Verschlüsselungsschlüssel (E002)</p>
<p>Exponent (24 Bit):</p>
<p>
<code>010001</code>
</p>
<p>Modulus (2048 Bit):</p>
<p>
<code>93 10 E9 40 2A B1 77 DB 31 C7 EB 13 5A E6 21 FD 6B 18 2B 74 40 67 B1 C9 6D B6 09 4A 1D CD F0 A7 DC 51 A4 53 EF AE 14 0D 9E A0 FB E4 EE D0 2E CF 6C 4C 5E 99 83 F3 A3 8E C3 FE F5 C1 DA E2 E6 52 96 A1 5B 9C 10 2D D1 F1 A2 0F 8E 3E 5D 81 55 DF 19 11 5B 5E 62 DB 95 56 0E 19 4C EF F3 87 50 EB 5F B7 42 3C 5D CB 47 51 81 E7 3F 39 6A 4A CA 6E 29 55 2B 22 14 FE 24 DA 5D DB 0C 99 D2 61 7A FB 40 B7 61 B8 82 89 BE 59 4C 64 92 9A F2 5E 82 62 3A 98 11 61 A3 77 0F 13 38 5D FD 13 BD 9C 4A 96 F9 34 8A 3B 99 4D 25 7B 1B A8 3F 90 F7 6F 9D 09 74 DB 4C B7 27 A3 0B EC 7C 05 E5 F3 1C F7 C2 59 0D 3A 57 86 D5 AD AF 1E CC 84 9F B8 4C DF 8A 35 22 CF D5 B8 12 2B 44 E4 12 BE 26 F7 D7 31 31 31 BB 3D 3C 49 7E C6 AF 44 4D 00 1F FC 04 84 2F 10 8B 2C 78 15 0F 22 46 70 78 2B 25 56 16 36 FB 9F</code>
</p>
<p>Hash (SHA-256):</p>
<p>
<code>9E E6 72 02 34 28 22 F1 F8 33 09 EB 09 60 7C D9 30 BF BD C3 6A 8A 0A 6A 3E D3 17 C0 ED 57 93 D5</code>
</p>
<p>Ich bestätige hiermit die obigen öffentlichen Schlüssel für meinen EBICS-Zugang.</p>
<br/>
<br/>
<br/>
<br/>
<table>
<tr>
<td>_________________________</td>
<td>_________________________</td>
<td>_________________________</td>
</tr>
<tr>
<td>Ort/Datum</td>
<td>Name/Firma</td>
<td>Unterschrift</td>
</tr>
</table>
</div>
</body>
</html>

View File

@ -0,0 +1,49 @@
'use strict';
/* eslint-env node, mocha */
const { assert } = require('chai');
const { join, resolve } = require('path');
const { readFileSync, mkdirSync, existsSync } = require('fs');
const BankLetter = require('../../lib/BankLetter');
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 createDir = (where) => {
try {
mkdirSync(where);
} catch (e) {
if (e.code !== 'EEXIST')
throw e;
}
};
describe('BankLetter', () => {
let bankLetterGenerator = null;
it('creates an instance', () => assert.doesNotThrow(() => {
bankLetterGenerator = new BankLetter({
client,
bankName: 'Credit Suisse AG',
template: readFileSync(join(__dirname, '../../templates/ini_de.hbs'), { encoding: 'utf8' }),
});
}));
it('genrates a letter', async () => assert.doesNotThrow(async () => bankLetterGenerator.generate()));
it('throws with invalid serliazitaion path', async () => bankLetterGenerator.serialize('').catch(e => assert.instanceOf(e, Error)));
it('serliaziers a letter to disk', async () => {
createDir('.test_tmp');
await bankLetterGenerator.serialize('.test_tmp/test_letter.html').then(t => assert.equal(t, true));
assert.equal(existsSync('.test_tmp/test_letter.html'), true);
});
});

View File

@ -3,19 +3,39 @@
/* eslint-env node, mocha */
const { assert } = require('chai');
const { resolve } = require('path');
const response = require('../../lib/middleware/response');
const serializer = require('../../lib/middleware/serializer');
const signer = require('../../lib/middleware/signer');
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')),
});
describe('Middlewares', () => {
describe('Response Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => response('H003')));
it('should not throw with supported protocol version', () => assert.doesNotThrow(() => response.version('H004')));
it('should throw with no unsupported protocol version', () => assert.throws(() => response.version('H003')));
});
describe('Signer Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => signer('H003')));
it('should not throw with supported protocol version', () => assert.doesNotThrow(() => signer.version('H004')));
it('should throw with no unsupported protocol version', () => assert.throws(() => signer.version('H003')));
});
describe('Signer Middleware', () => {
it('should throw with no unspported protocol version', () => assert.throws(() => serializer('H003')));
describe('Serializer Middleware', () => {
it('should not throw with supported protocol version and ini operation', () => assert.doesNotThrow(() => serializer.use(ebics.Orders.INI, client)));
it('should not throw with supported protocol version and download operation', () => assert.doesNotThrow(() => serializer.use(ebics.Orders.STA('2018-01-01', '2018-02-01'), client)));
it('should not throw with supported protocol version and upload operation', () => assert.doesNotThrow(() => serializer.use(ebics.Orders.AZV('<xml />'), client)));
it('should throw with no supported protocol version and ', () => assert.throws(() => serializer.use({ version: 'H004', operation: 'unspported' }, client)));
it('should throw with no unuspported protocol version', () => assert.throws(() => serializer.use({ version: 'H003' }, client)));
});
});

View File

@ -108,5 +108,4 @@ describe('H004 response parsing', () => {
const xmlString = response.toXML().replace('\\n', '\n');
assert.deepEqual(xmlString, readFileSync(join(__dirname, '../fixtures/HPB_response.xml'), { encoding: 'utf8' }));
});
});