Commit 81861e4a authored by Antonin Coulibaly's avatar Antonin Coulibaly Committed by Antonin Coulibaly
Browse files

FIX(protocol): make tag optional for getresponse

    * Update associated tests
parent 8ae78dc4
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -1034,18 +1034,25 @@ class GetResponsePDU extends PDU {
     * @param {Buffer} keyArg - key of the item to gotten item.
     * @param {number} chunkSize - size of the got chunk.
     * @param {Buffer} dbVersionArg - The version of the item in the database.
     * @param {Buffer} tagArg - the hash of the value to put.
     * @param {string} algorithm - algorithm used for the tag.
     * @param {Object} optionsArg - optional :
     *                  {string} [options.algorithm] - algorithm used for the
     *                                                 tag
     *                  {Buffer} [options.tag] - the hash of the value to put.
     * @returns {Kinetic} - message structure following the kinetic protocol
     */
    constructor(ackSequence, code, errorMessageArg, keyArg,
                chunkSize, dbVersionArg, tagArg, algorithm) {
                chunkSize, dbVersionArg, optionsArg) {
        super();

        const options = optionsArg || {};
        let tag = null;

        if (options.tag)
            tag = validateVersionArgument(options.tag);

        const detailedMessage = validateBufferOrStringArgument(errorMessageArg);
        const key = validateBufferOrStringArgument(keyArg);
        const dbVersion = validateVersionArgument(dbVersionArg);
        const tag = validateVersionArgument(tagArg);

        this._chunkSize = chunkSize;
        this.setCommand({
@@ -1058,8 +1065,8 @@ class GetResponsePDU extends PDU {
                    key,
                    dbVersion,
                    tag,
                    algorithm: validateAlgo(algorithm) ||
                        algorithms.SHA1,
                    algorithm: tag ? validateAlgo(options.algorithm) ||
                        algorithms.SHA1 : null,
                },
            },
            status: {
+1 −1
Original line number Diff line number Diff line
@@ -851,7 +851,7 @@ describe('kinetic.PDU encoding()', () => {

        const pdu = new kinetic.GetResponsePDU(
                1, 1, Buffer.alloc(0), Buffer.from('qwer', 'utf8'),
            chunk.length, Buffer.from('1', 'utf8'), tag);
            chunk.length, Buffer.from('1', 'utf8'), { tag });

        const result = Buffer.concat([pdu.read(), chunk]);