Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,12 @@ class Config extends EventEmitter {
if (Array.isArray(config.kmip.transport)) {
this.kmip.transport = config.kmip.transport.map(t =>
this._parseKmipTransport(t));
if (config.kmip.retries) {
assert(typeof config.kmip.retries === 'number',
'bad config: KMIP Cluster retries must be a number');
if (config.kmip.retries !== undefined) {
assert(Number.isInteger(config.kmip.retries) && config.kmip.retries >= 0,
'bad config: KMIP Cluster retries must be a non-negative integer');
assert(config.kmip.retries <= this.kmip.transport.length - 1,
'bad config: KMIP Cluster retries must be lower or equal to the number of hosts - 1');
this.kmip.retries = config.kmip.retries;
} else {
this.kmip.retries = this.kmip.transport.length - 1;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenko/cloudserver",
"version": "9.2.43",
"version": "9.2.44",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js",
"engines": {
Expand Down
41 changes: 41 additions & 0 deletions tests/unit/testConfigs/parseKmsKmip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const assert = require('assert');

const { ConfigObject: Config } = require('../../../lib/Config');

function kmipCluster(retries) {
return {
providerName: 'thales',
transport: [{ tls: { host: 'kmip1' } }, { tls: { host: 'kmip2' } }, { tls: { host: 'kmip3' } }],
retries,
};
}

describe('parseKmsKmip Function', () => {
let configInstance;

beforeEach(() => {
configInstance = new Config();
});

it('should default cluster retries to the number of hosts - 1', () => {
configInstance._parseKmsKmip({ kmip: kmipCluster(undefined) });
assert.strictEqual(configInstance.kmip.retries, 2);
});

it('should use the configured cluster retries', () => {
configInstance._parseKmsKmip({ kmip: kmipCluster(1) });
assert.strictEqual(configInstance.kmip.retries, 1);
});

it('should use cluster retries configured to 0', () => {
configInstance._parseKmsKmip({ kmip: kmipCluster(0) });
assert.strictEqual(configInstance.kmip.retries, 0);
});

it('should reject cluster retries above the number of hosts - 1', () => {
assert.throws(
() => configInstance._parseKmsKmip({ kmip: kmipCluster(3) }),
/KMIP Cluster retries must be lower or equal to the number of hosts - 1/,
);
});
});
Loading