Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1904 - ACL DRYRUN #2102

Merged
merged 3 commits into from
Apr 26, 2022
Merged
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
3 changes: 3 additions & 0 deletions packages/client/lib/client/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CLUSTER_COMMANDS from '../cluster/commands';
import * as ACL_CAT from '../commands/ACL_CAT';
import * as ACL_DELUSER from '../commands/ACL_DELUSER';
import * as ACL_DRYRUN from '../commands/ACL_DRYRUN';
import * as ACL_GENPASS from '../commands/ACL_GENPASS';
import * as ACL_GETUSER from '../commands/ACL_GETUSER';
import * as ACL_LIST from '../commands/ACL_LIST';
Expand Down Expand Up @@ -115,6 +116,8 @@ export default {
aclCat: ACL_CAT,
ACL_DELUSER,
aclDelUser: ACL_DELUSER,
ACL_DRYRUN,
aclDryRun: ACL_DRYRUN,
ACL_GENPASS,
aclGenPass: ACL_GENPASS,
ACL_GETUSER,
Expand Down
21 changes: 21 additions & 0 deletions packages/client/lib/commands/ACL_DRYRUN.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ACL_DRYRUN';

describe('ACL DRYRUN', () => {
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
transformArguments('default', ['GET', 'key']),
['ACL', 'DRYRUN', 'default', 'GET', 'key']
);
});

testUtils.testWithClient('client.aclDryRun', async client => {
assert.equal(
await client.aclDryRun('default', ['GET', 'key']),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
});
18 changes: 18 additions & 0 deletions packages/client/lib/commands/ACL_DRYRUN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';

export const IS_READ_ONLY = true;

export function transformArguments(
username: RedisCommandArgument,
command: Array<RedisCommandArgument>
): RedisCommandArguments {
return [
'ACL',
'DRYRUN',
username,
...command
];
}

export declare function transformReply(): RedisCommandArgument;

2 changes: 1 addition & 1 deletion packages/client/lib/commands/BLMPOP.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BLMPOP';

describe('BLMPOP', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/BZMPOP.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BZMPOP';

describe('BZMPOP', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/CLUSTER_LINKS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_LINKS';

describe('CLUSTER LINKS', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_GETKEYSANDFLAGS';

describe('COMMAND GETKEYSANDFLAGS', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/COMMAND_LIST.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, FilterBy } from './COMMAND_LIST';

describe('COMMAND LIST', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/EVALSHA_RO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils from '../test-utils';
import { transformArguments } from './EVALSHA_RO';

describe('EVALSHA_RO', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/EVAL_RO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EVAL_RO';

describe('EVAL_RO', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/commands/EXPIRETIME.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EXPIRETIME';

describe('EXPIRETIME', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FCALL.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec';
import { transformArguments } from './FCALL';

describe('FCALL', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FCALL_RO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec';
import { transformArguments } from './FCALL_RO';

describe('FCALL_RO', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_DELETE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_DELETE';

describe('FUNCTION DELETE', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_DUMP.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_DUMP';

describe('FUNCTION DUMP', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_FLUSH.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_FLUSH';

describe('FUNCTION FLUSH', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_KILL.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils from '../test-utils';
import { transformArguments } from './FUNCTION_KILL';

describe('FUNCTION KILL', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_LIST.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec';
import { transformArguments } from './FUNCTION_LIST';

describe('FUNCTION LIST', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec';
import { transformArguments } from './FUNCTION_LIST_WITHCODE';

describe('FUNCTION LIST WITHCODE', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_LOAD.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MATH_FUNCTION } from '../client/index.spec';
import { transformArguments } from './FUNCTION_LOAD';

describe('FUNCTION LOAD', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_RESTORE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_RESTORE';

describe('FUNCTION RESTORE', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/FUNCTION_STATS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_STATS';

describe('FUNCTION STATS', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/LMPOP.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LMPOP';

describe('LMPOP', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/PEXPIRETIME.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './PEXPIRETIME';

describe('PEXPIRETIME', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

it('transformArguments', () => {
assert.deepEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/SINTERCARD.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SINTERCARD';

describe('SINTERCARD', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/SORT_RO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SORT_RO';

describe('SORT_RO', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/ZINTERCARD.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZINTERCARD';

describe('ZINTERCARD', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/commands/ZMPOP.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZMPOP';

describe('ZMPOP', () => {
testUtils.isVersionGreaterThanHook([7, 0]);
testUtils.isVersionGreaterThanHook([7]);

describe('transformArguments', () => {
it('simple', () => {
Expand Down