node-ebics-client/test/unit/middlewares.js

42 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-11-20 09:12:37 +00:00
'use strict';
/* eslint-env node, mocha */
const { assert } = require('chai');
2019-11-20 12:42:22 +00:00
const { resolve } = require('path');
2019-11-20 09:12:37 +00:00
const response = require('../../lib/middleware/response');
const serializer = require('../../lib/middleware/serializer');
const signer = require('../../lib/middleware/signer');
2019-11-20 12:42:22 +00:00
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')),
});
2019-11-20 09:12:37 +00:00
describe('Middlewares', () => {
describe('Response Middleware', () => {
2019-11-20 12:42:22 +00:00
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')));
2019-11-20 09:12:37 +00:00
});
describe('Signer Middleware', () => {
2019-11-20 12:42:22 +00:00
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')));
2019-11-20 09:12:37 +00:00
});
2019-11-20 12:42:22 +00:00
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)));
2019-11-20 09:12:37 +00:00
});
});