Skip to content

Commit b586ccb

Browse files
authored
fix #1904 - ACL DRYRUN (#2102)
* fix #1904 - ACL DRYRUN * clean code * fix test
1 parent 1e51680 commit b586ccb

28 files changed

+68
-26
lines changed

packages/client/lib/client/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import CLUSTER_COMMANDS from '../cluster/commands';
22
import * as ACL_CAT from '../commands/ACL_CAT';
33
import * as ACL_DELUSER from '../commands/ACL_DELUSER';
4+
import * as ACL_DRYRUN from '../commands/ACL_DRYRUN';
45
import * as ACL_GENPASS from '../commands/ACL_GENPASS';
56
import * as ACL_GETUSER from '../commands/ACL_GETUSER';
67
import * as ACL_LIST from '../commands/ACL_LIST';
@@ -115,6 +116,8 @@ export default {
115116
aclCat: ACL_CAT,
116117
ACL_DELUSER,
117118
aclDelUser: ACL_DELUSER,
119+
ACL_DRYRUN,
120+
aclDryRun: ACL_DRYRUN,
118121
ACL_GENPASS,
119122
aclGenPass: ACL_GENPASS,
120123
ACL_GETUSER,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './ACL_DRYRUN';
4+
5+
describe('ACL DRYRUN', () => {
6+
testUtils.isVersionGreaterThanHook([7]);
7+
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
transformArguments('default', ['GET', 'key']),
11+
['ACL', 'DRYRUN', 'default', 'GET', 'key']
12+
);
13+
});
14+
15+
testUtils.testWithClient('client.aclDryRun', async client => {
16+
assert.equal(
17+
await client.aclDryRun('default', ['GET', 'key']),
18+
'OK'
19+
);
20+
}, GLOBAL.SERVERS.OPEN);
21+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { RedisCommandArgument, RedisCommandArguments } from '.';
2+
3+
export const IS_READ_ONLY = true;
4+
5+
export function transformArguments(
6+
username: RedisCommandArgument,
7+
command: Array<RedisCommandArgument>
8+
): RedisCommandArguments {
9+
return [
10+
'ACL',
11+
'DRYRUN',
12+
username,
13+
...command
14+
];
15+
}
16+
17+
export declare function transformReply(): RedisCommandArgument;
18+

packages/client/lib/commands/BLMPOP.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments } from './BLMPOP';
44

55
describe('BLMPOP', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
describe('transformArguments', () => {
99
it('simple', () => {

packages/client/lib/commands/BZMPOP.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments } from './BZMPOP';
44

55
describe('BZMPOP', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
describe('transformArguments', () => {
99
it('simple', () => {

packages/client/lib/commands/CLUSTER_LINKS.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments } from './CLUSTER_LINKS';
44

55
describe('CLUSTER LINKS', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
it('transformArguments', () => {
99
assert.deepEqual(

packages/client/lib/commands/COMMAND_GETKEYSANDFLAGS.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments } from './COMMAND_GETKEYSANDFLAGS';
44

55
describe('COMMAND GETKEYSANDFLAGS', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
it('transformArguments', () => {
99
assert.deepEqual(

packages/client/lib/commands/COMMAND_LIST.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments, FilterBy } from './COMMAND_LIST';
44

55
describe('COMMAND LIST', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
describe('transformArguments', () => {
99
it('simple', () => {

packages/client/lib/commands/EVALSHA_RO.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils from '../test-utils';
33
import { transformArguments } from './EVALSHA_RO';
44

55
describe('EVALSHA_RO', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
it('transformArguments', () => {
99
assert.deepEqual(

packages/client/lib/commands/EVAL_RO.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
33
import { transformArguments } from './EVAL_RO';
44

55
describe('EVAL_RO', () => {
6-
testUtils.isVersionGreaterThanHook([7, 0]);
6+
testUtils.isVersionGreaterThanHook([7]);
77

88
it('transformArguments', () => {
99
assert.deepEqual(

0 commit comments

Comments
 (0)