Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lerna-debug.log*
# Tests
/coverage
/.nyc_output
**/coverage

# IDEs and editors
/.idea
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class KeysController extends BaseController {
super();
}

@Get('')
@Post('')
@HttpCode(200)
@ApiOperation({ description: 'Get keys by cursor position' })
@ApiRedisParams()
@ApiOkResponse({
Expand All @@ -50,7 +51,7 @@ export class KeysController extends BaseController {
@ApiQueryRedisStringEncoding()
async getKeys(
@Param('dbInstance') dbInstance: string,
@Query() getKeysDto: GetKeysDto,
@Body() getKeysDto: GetKeysDto,
): Promise<GetKeysWithDetailsResponse[]> {
return this.keysBusinessService.getKeys(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { server, request, constants, rte } = deps;

// endpoint to test
const endpoint = (instanceId = constants.TEST_INSTANCE_ID) =>
request(server).get(`/instance/${instanceId}/keys`);
request(server).post(`/instance/${instanceId}/keys`);

const responseSchema = Joi.array().items(Joi.object().keys({
total: Joi.number().integer().required(),
Expand Down Expand Up @@ -56,7 +56,7 @@ const isKeyInResponse = (body, keyName) => _.find(
),
)

describe('GET /instance/:instanceId/keys', () => {
describe('POST /instance/:instanceId/keys', () => {
// todo: add query validation
xdescribe('Validation', () => {});

Expand All @@ -68,7 +68,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should return all keys in utf-8 (by default)',
query: {
data: {
count: 10_000,
cursor: '0',
},
Expand All @@ -81,6 +81,8 @@ describe('GET /instance/:instanceId/keys', () => {
name: 'Should return all keys in utf-8',
query: {
encoding: 'utf8',
},
data: {
count: 10_000,
cursor: '0',
},
Expand All @@ -93,6 +95,8 @@ describe('GET /instance/:instanceId/keys', () => {
name: 'Should return all keys in ascii',
query: {
encoding: 'ascii',
},
data: {
count: 10_000,
cursor: '0',
},
Expand All @@ -105,6 +109,8 @@ describe('GET /instance/:instanceId/keys', () => {
name: 'Should return all keys in buffer',
query: {
encoding: 'buffer',
},
data: {
count: 10_000,
cursor: '0',
},
Expand All @@ -126,7 +132,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should find key by exact name',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_1`
},
Expand All @@ -153,7 +159,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should not find key by exact name',
query: {
data: {
cursor: '0',
match: 'not_exist_key'
},
Expand All @@ -179,7 +185,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should prevent full scan in one request',
query: {
data: {
count: 100,
cursor: '0',
match: 'not_exist_key*'
Expand Down Expand Up @@ -208,7 +214,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with * in the end',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_11*`
},
Expand Down Expand Up @@ -237,7 +243,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with * in the beginning',
query: {
data: {
cursor: '0',
match: '*_key_111'
},
Expand Down Expand Up @@ -266,7 +272,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with * in the middle',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_*_111`
},
Expand All @@ -293,7 +299,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with ? in the end',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_10?`
},
Expand Down Expand Up @@ -322,7 +328,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with [a-b] glob pattern',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_10[0-5]`
},
Expand Down Expand Up @@ -351,7 +357,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with [a,b,c] glob pattern',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_10[0,1,2]`
},
Expand Down Expand Up @@ -380,7 +386,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with [abc] glob pattern',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_10[012]`
},
Expand Down Expand Up @@ -409,7 +415,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with [^a] glob pattern',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_str_key_10[^0]`
},
Expand Down Expand Up @@ -438,7 +444,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should search by with combined glob patterns',
query: {
data: {
cursor: '0',
match: `${constants.TEST_RUN_ID}_s?r_*_[1][0-5][^0]`
},
Expand Down Expand Up @@ -470,7 +476,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should scan all types',
query: {
data: {
cursor: '0',
},
responseSchema,
Expand All @@ -483,7 +489,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should scan by provided count value',
query: {
data: {
count: 500,
cursor: '0',
},
Expand Down Expand Up @@ -517,7 +523,7 @@ describe('GET /instance/:instanceId/keys', () => {
while (cursor !== 0) {
await validateApiCall({
endpoint,
query: {
data: {
cursor: cursor || 0,
count: 99,
},
Expand All @@ -542,7 +548,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (string)',
query: {
data: {
cursor: '0',
type: 'string',
count: 200,
Expand All @@ -562,7 +568,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should filter by type (list)',
query: {
data: {
cursor: '0',
type: 'list',
count: 200,
Expand All @@ -582,7 +588,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should filter by type (set)',
query: {
data: {
cursor: '0',
type: 'set',
count: 200,
Expand All @@ -602,7 +608,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should filter by type (zset)',
query: {
data: {
cursor: '0',
type: 'zset',
count: 200,
Expand All @@ -622,7 +628,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should filter by type (hash)',
query: {
data: {
cursor: '0',
type: 'hash',
count: 200,
Expand All @@ -649,7 +655,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (ReJSON-RL)',
query: {
data: {
cursor: '0',
type: 'ReJSON-RL',
count: 200,
Expand All @@ -675,7 +681,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (timeseries)',
query: {
data: {
cursor: '0',
type: 'TSDB-TYPE',
count: 200,
Expand All @@ -701,7 +707,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (stream)',
query: {
data: {
cursor: '0',
type: 'stream',
count: 200,
Expand All @@ -727,7 +733,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (stream)',
query: {
data: {
cursor: '0',
type: 'graphdata',
count: 200,
Expand All @@ -754,7 +760,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should scan all types',
query: {
data: {
cursor: '0',
},
responseSchema,
Expand All @@ -780,7 +786,7 @@ describe('GET /instance/:instanceId/keys', () => {
},
{
name: 'Should scan by provided count value',
query: {
data: {
count: 300,
cursor: '0',
},
Expand Down Expand Up @@ -813,7 +819,7 @@ describe('GET /instance/:instanceId/keys', () => {
while (cursor.length > 0) {
await validateApiCall({
endpoint,
query: {
data: {
cursor: cursor.join('||'),
count: 99,
},
Expand All @@ -840,7 +846,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should filter by type (string)',
query: {
data: {
cursor: '0',
type: 'string',
count: 200,
Expand Down Expand Up @@ -878,7 +884,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'check keyname with non-ASCII symbols should be properly listed',
query: {
data: {
cursor: '0',
count: 200,
},
Expand Down Expand Up @@ -908,7 +914,7 @@ describe('GET /instance/:instanceId/keys', () => {
[
{
name: 'Should scan all types',
query: {
data: {
cursor: '0',
match: key
},
Expand All @@ -933,15 +939,15 @@ describe('GET /instance/:instanceId/keys', () => {
{
name: 'Should remove key',
endpoint: () => endpoint(constants.TEST_INSTANCE_ACL_ID),
query: {
data: {
cursor: '0',
},
statusCode: 200,
},
{
name: 'Should throw error if no permissions for "scan" command',
endpoint: () => endpoint(constants.TEST_INSTANCE_ACL_ID),
query: {
data: {
cursor: '0',
},
statusCode: 403,
Expand Down