Loading lib/kinetic.js +12 −7 Original line number Diff line number Diff line Loading @@ -894,7 +894,6 @@ class PutPDU extends PDU { InitPDU * @param {Buffer} keyArg - key of the item to put. * @param {number} chunkSize - size of the chunk to put. * @param {Buffer} tagArg - the hash of the value to put. * @param {Object} optionsArg - optional : * {String} [options.synchronization = WRITEBACK] - to * specify if the data must be written to disk immediately, Loading @@ -903,21 +902,27 @@ class PutPDU extends PDU { * true ignores potential version mismatches and carries out * the operation. * {string} [options.algorithm] - algorithm used for the tag * {Buffer} dbVersion - version of the item in the database * {Buffer} newVersion - new version of the item to put * {Buffer} [options.dbVersion] - version of the item in the * database * {Buffer} [options.newVersion] - new version of the item to * put * {Buffer} [options.tag] - the hash of the value to put. * @returns {Kinetic} - message structure following the kinetic protocol */ constructor(sequence, connectionID, clusterVersion, keyArg, chunkSize, tagArg, optionsArg) { optionsArg) { super(); const options = optionsArg || {}; let dbVersion = null; let newVersion = null; let tag = null; const key = validateBufferOrStringArgument(keyArg); const tag = validateVersionArgument(tagArg); if (options.tag) tag = validateVersionArgument(options.tag); if (options.dbVersion) dbVersion = validateVersionArgument(options.dbVersion); if (options.newVersion) Loading @@ -941,8 +946,8 @@ class PutPDU extends PDU { force: typeof options.force === "boolean" ? options.force : null, tag, algorithm: validateAlgo(options.algorithm) || algorithms.SHA1, algorithm: tag ? validateAlgo(options.algorithm) || algorithms.SHA1 : null, }, }, }); Loading tests/functional/simulTest.js +2 −3 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ const requestsArr = [ function requestsLauncher(request, client, optionsA) { let pdu; let tag; const options = optionsA || {}; Loading @@ -58,11 +57,11 @@ function requestsLauncher(request, client, optionsA) { pdu = new kinetic.NoOpPDU(sequence, connectionID, clusterVersion); break; case 'put': tag = crypto options.tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); pdu = new kinetic.PutPDU( sequence, connectionID, clusterVersion, options.key || key, chunk.length, tag, options); chunk.length, options); break; case 'get': pdu = new kinetic.GetPDU( Loading tests/unit/kinetic.js +15 −16 Original line number Diff line number Diff line Loading @@ -701,14 +701,13 @@ describe('kinetic.PDU encoding()', () => { const options = { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading @@ -731,14 +730,13 @@ describe('kinetic.PDU encoding()', () => { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), force: true, tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading @@ -761,14 +759,13 @@ describe('kinetic.PDU encoding()', () => { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), force: false, tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading Loading @@ -1190,9 +1187,10 @@ describe('kinetic.PutPDU()', () => { const tag = crypto .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, "string", 12, tag, 1, connectionID, clusterVersion, "string", 12, { dbVersion: { a: 1 }, newVersion: Buffer.from('3', 'utf8'), tag, }); k; done(new Error("constructor accepted object-typed key")); Loading @@ -1210,7 +1208,7 @@ describe('kinetic.PutPDU()', () => { .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, "string", 12, tag, { newVersion: 346 }); "string", 12, { newVersion: 346, tag }); k; done(); } catch (e) { Loading @@ -1223,9 +1221,10 @@ describe('kinetic.PutPDU()', () => { const tag = crypto .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', 12, tag, 1, connectionID, clusterVersion, 'string', 12, { dbVersion: Buffer.from('2', 'utf8'), newVersion: { s: 'abc' } newVersion: { s: 'abc' }, tag, }); k; done(new Error("constructor accepted string-typed key")); Loading Loading
lib/kinetic.js +12 −7 Original line number Diff line number Diff line Loading @@ -894,7 +894,6 @@ class PutPDU extends PDU { InitPDU * @param {Buffer} keyArg - key of the item to put. * @param {number} chunkSize - size of the chunk to put. * @param {Buffer} tagArg - the hash of the value to put. * @param {Object} optionsArg - optional : * {String} [options.synchronization = WRITEBACK] - to * specify if the data must be written to disk immediately, Loading @@ -903,21 +902,27 @@ class PutPDU extends PDU { * true ignores potential version mismatches and carries out * the operation. * {string} [options.algorithm] - algorithm used for the tag * {Buffer} dbVersion - version of the item in the database * {Buffer} newVersion - new version of the item to put * {Buffer} [options.dbVersion] - version of the item in the * database * {Buffer} [options.newVersion] - new version of the item to * put * {Buffer} [options.tag] - the hash of the value to put. * @returns {Kinetic} - message structure following the kinetic protocol */ constructor(sequence, connectionID, clusterVersion, keyArg, chunkSize, tagArg, optionsArg) { optionsArg) { super(); const options = optionsArg || {}; let dbVersion = null; let newVersion = null; let tag = null; const key = validateBufferOrStringArgument(keyArg); const tag = validateVersionArgument(tagArg); if (options.tag) tag = validateVersionArgument(options.tag); if (options.dbVersion) dbVersion = validateVersionArgument(options.dbVersion); if (options.newVersion) Loading @@ -941,8 +946,8 @@ class PutPDU extends PDU { force: typeof options.force === "boolean" ? options.force : null, tag, algorithm: validateAlgo(options.algorithm) || algorithms.SHA1, algorithm: tag ? validateAlgo(options.algorithm) || algorithms.SHA1 : null, }, }, }); Loading
tests/functional/simulTest.js +2 −3 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ const requestsArr = [ function requestsLauncher(request, client, optionsA) { let pdu; let tag; const options = optionsA || {}; Loading @@ -58,11 +57,11 @@ function requestsLauncher(request, client, optionsA) { pdu = new kinetic.NoOpPDU(sequence, connectionID, clusterVersion); break; case 'put': tag = crypto options.tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); pdu = new kinetic.PutPDU( sequence, connectionID, clusterVersion, options.key || key, chunk.length, tag, options); chunk.length, options); break; case 'get': pdu = new kinetic.GetPDU( Loading
tests/unit/kinetic.js +15 −16 Original line number Diff line number Diff line Loading @@ -701,14 +701,13 @@ describe('kinetic.PDU encoding()', () => { const options = { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading @@ -731,14 +730,13 @@ describe('kinetic.PDU encoding()', () => { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), force: true, tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading @@ -761,14 +759,13 @@ describe('kinetic.PDU encoding()', () => { dbVersion: Buffer.from('2', 'utf8'), newVersion: Buffer.from('3', 'utf8'), force: false, tag: crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(), }; const tag = crypto .createHmac('sha1', 'asdfasdf').update(chunk).digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', chunk.length, tag, options); 'string', chunk.length, options); const result = Buffer.concat([k.read(), chunk]); Loading Loading @@ -1190,9 +1187,10 @@ describe('kinetic.PutPDU()', () => { const tag = crypto .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, "string", 12, tag, 1, connectionID, clusterVersion, "string", 12, { dbVersion: { a: 1 }, newVersion: Buffer.from('3', 'utf8'), tag, }); k; done(new Error("constructor accepted object-typed key")); Loading @@ -1210,7 +1208,7 @@ describe('kinetic.PutPDU()', () => { .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, "string", 12, tag, { newVersion: 346 }); "string", 12, { newVersion: 346, tag }); k; done(); } catch (e) { Loading @@ -1223,9 +1221,10 @@ describe('kinetic.PutPDU()', () => { const tag = crypto .createHmac('sha1', 'asdfasdf').update('HelloWorld').digest(); const k = new kinetic.PutPDU( 1, connectionID, clusterVersion, 'string', 12, tag, 1, connectionID, clusterVersion, 'string', 12, { dbVersion: Buffer.from('2', 'utf8'), newVersion: { s: 'abc' } newVersion: { s: 'abc' }, tag, }); k; done(new Error("constructor accepted string-typed key")); Loading