You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix(client): bring disableClientInfo option back (#2959)
* fix(client): bring disableClientInfo option back It disappeared in v5 fixes #2958
This commit is contained in:
committed by
GitHub
parent
f3d1d3352e
commit
4a5f879ec9
@@ -2,6 +2,7 @@ import { strict as assert } from 'node:assert';
|
||||
import CLIENT_INFO from './CLIENT_INFO';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { parseArgs } from './generic-transformers';
|
||||
import { version } from '../../package.json';
|
||||
|
||||
describe('CLIENT INFO', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
@@ -48,4 +49,89 @@ describe('CLIENT INFO', () => {
|
||||
}
|
||||
}
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithClient('client.clientInfo Redis < 7', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
if (!testUtils.isVersionGreaterThan([7])) {
|
||||
assert.strictEqual(reply.libName, undefined, 'LibName should be undefined for Redis < 7');
|
||||
assert.strictEqual(reply.libVer, undefined, 'LibVer should be undefined for Redis < 7');
|
||||
}
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 info disabled', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, '');
|
||||
assert.equal(reply.libVer, '');
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
disableClientInfo: true
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp unset, info enabled, tag set', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, 'node-redis(client1)');
|
||||
assert.equal(reply.libVer, version);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
clientInfoTag: 'client1'
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp unset, info enabled, tag unset', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, 'node-redis');
|
||||
assert.equal(reply.libVer, version);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp2 info enabled', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, 'node-redis(client1)');
|
||||
assert.equal(reply.libVer, version);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 2,
|
||||
clientInfoTag: 'client1'
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp2 info disabled', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, '');
|
||||
assert.equal(reply.libVer, '');
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
disableClientInfo: true,
|
||||
RESP: 2
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp3 info enabled', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, 'node-redis(client1)');
|
||||
assert.equal(reply.libVer, version);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3,
|
||||
clientInfoTag: 'client1'
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.testWithClientIfVersionWithinRange([[7], 'LATEST'], 'client.clientInfo Redis>=7 resp3 info disabled', async client => {
|
||||
const reply = await client.clientInfo();
|
||||
assert.equal(reply.libName, '');
|
||||
assert.equal(reply.libVer, '');
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
disableClientInfo: true,
|
||||
RESP: 3
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -52,6 +52,14 @@ export interface ClientInfoReply {
|
||||
* available since 7.0
|
||||
*/
|
||||
resp?: number;
|
||||
/**
|
||||
* available since 7.0
|
||||
*/
|
||||
libName?: string;
|
||||
/**
|
||||
* available since 7.0
|
||||
*/
|
||||
libVer?: string;
|
||||
}
|
||||
|
||||
const CLIENT_INFO_REGEX = /([^\s=]+)=([^\s]*)/g;
|
||||
@@ -67,7 +75,6 @@ export default {
|
||||
for (const item of rawReply.toString().matchAll(CLIENT_INFO_REGEX)) {
|
||||
map[item[1]] = item[2];
|
||||
}
|
||||
|
||||
const reply: ClientInfoReply = {
|
||||
id: Number(map.id),
|
||||
addr: map.addr,
|
||||
@@ -89,7 +96,9 @@ export default {
|
||||
totMem: Number(map['tot-mem']),
|
||||
events: map.events,
|
||||
cmd: map.cmd,
|
||||
user: map.user
|
||||
user: map.user,
|
||||
libName: map['lib-name'],
|
||||
libVer: map['lib-ver']
|
||||
};
|
||||
|
||||
if (map.laddr !== undefined) {
|
||||
|
Reference in New Issue
Block a user