Skip to content

Commit 9458a07

Browse files
committed
test(api): reseed array key before ACL deny cases (RI-8219, #6078)
The outer `beforeEach(rte.data.truncate)` wipes data between every test, including ACL cases. Only the authorised-user case re-seeded `aclKey` in its `before`; the forbidden-command cases just flipped ACL rules. As a result `checkIfKeyNotExists` returned 404 before Redis ever ran the target array command, so the suite expected 403 but got Not Found on ACL-enabled runs. Reseed `aclKey` via the root `rte.client` (which bypasses ACL) in each deny case's `before`, then flip the ACL rules for the API request. Fixes the same pattern in all seven array integration test files.
1 parent a7361d0 commit 9458a07

7 files changed

Lines changed: 42 additions & 7 deletions

redisinsight/api/test/api/array/POST-databases-id-array-get_count.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ describe('POST /databases/:instanceId/array/get-count', () => {
139139
data: { keyName: aclKey },
140140
statusCode: 403,
141141
responseBody: { statusCode: 403, error: 'Forbidden' },
142-
before: () => rte.data.setAclUserRules('~* +@all -arcount'),
142+
// beforeEach() wipes the key between tests; reseed via the root
143+
// client (ACL rules below only affect the API request).
144+
before: async () => {
145+
await rte.client.call('ARSET', aclKey, '0', 'x');
146+
await rte.data.setAclUserRules('~* +@all -arcount');
147+
},
143148
},
144149
].map(mainCheckFn);
145150
});

redisinsight/api/test/api/array/POST-databases-id-array-get_element.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ describe('POST /databases/:instanceId/array/get-element', () => {
211211
data: { keyName: aclKey, index: '0' },
212212
statusCode: 403,
213213
responseBody: { statusCode: 403, error: 'Forbidden' },
214-
before: () => rte.data.setAclUserRules('~* +@all -arget'),
214+
// beforeEach() wipes the key between tests; reseed via the root
215+
// client (ACL rules below only affect the API request).
216+
before: async () => {
217+
await rte.client.call('ARSET', aclKey, '0', 'x');
218+
await rte.data.setAclUserRules('~* +@all -arget');
219+
},
215220
},
216221
].map(mainCheckFn);
217222
});

redisinsight/api/test/api/array/POST-databases-id-array-get_elements.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ describe('POST /databases/:instanceId/array/get-elements', () => {
191191
data: { keyName: aclKey, indexes: ['0'] },
192192
statusCode: 403,
193193
responseBody: { statusCode: 403, error: 'Forbidden' },
194-
before: () => rte.data.setAclUserRules('~* +@all -armget'),
194+
// beforeEach() wipes the key between tests; reseed via the root
195+
// client (ACL rules below only affect the API request).
196+
before: async () => {
197+
await rte.client.call('ARSET', aclKey, '0', 'x');
198+
await rte.data.setAclUserRules('~* +@all -armget');
199+
},
195200
},
196201
].map(mainCheckFn);
197202
});

redisinsight/api/test/api/array/POST-databases-id-array-get_length.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ describe('POST /databases/:instanceId/array/get-length', () => {
165165
data: { keyName: aclKey },
166166
statusCode: 403,
167167
responseBody: { statusCode: 403, error: 'Forbidden' },
168-
before: () => rte.data.setAclUserRules('~* +@all -arlen'),
168+
// beforeEach() wipes the key between tests; reseed via the root
169+
// client (ACL rules below only affect the API request).
170+
before: async () => {
171+
await rte.client.call('ARSET', aclKey, '0', 'x');
172+
await rte.data.setAclUserRules('~* +@all -arlen');
173+
},
169174
},
170175
].map(mainCheckFn);
171176
});

redisinsight/api/test/api/array/POST-databases-id-array-get_next_index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ describe('POST /databases/:instanceId/array/get-next-index', () => {
136136
data: { keyName: aclKey },
137137
statusCode: 403,
138138
responseBody: { statusCode: 403, error: 'Forbidden' },
139-
before: () => rte.data.setAclUserRules('~* +@all -arnext'),
139+
// beforeEach() wipes the key between tests; reseed via the root
140+
// client (ACL rules below only affect the API request).
141+
before: async () => {
142+
await rte.client.call('ARSET', aclKey, '0', 'x');
143+
await rte.data.setAclUserRules('~* +@all -arnext');
144+
},
140145
},
141146
].map(mainCheckFn);
142147
});

redisinsight/api/test/api/array/POST-databases-id-array-get_range.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ describe('POST /databases/:instanceId/array/get-range', () => {
221221
data: { keyName: aclKey, start: '0', end: '0' },
222222
statusCode: 403,
223223
responseBody: { statusCode: 403, error: 'Forbidden' },
224-
before: () => rte.data.setAclUserRules('~* +@all -argetrange'),
224+
// beforeEach() wipes the key between tests; reseed via the root
225+
// client (ACL rules below only affect the API request).
226+
before: async () => {
227+
await rte.client.call('ARSET', aclKey, '0', 'x');
228+
await rte.data.setAclUserRules('~* +@all -argetrange');
229+
},
225230
},
226231
].map(mainCheckFn);
227232
});

redisinsight/api/test/api/array/POST-databases-id-array-scan.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ describe('POST /databases/:instanceId/array/scan', () => {
244244
data: { keyName: aclKey, start: '0', end: '0' },
245245
statusCode: 403,
246246
responseBody: { statusCode: 403, error: 'Forbidden' },
247-
before: () => rte.data.setAclUserRules('~* +@all -arscan'),
247+
// beforeEach() wipes the key between tests; reseed via the root
248+
// client (ACL rules below only affect the API request).
249+
before: async () => {
250+
await rte.client.call('ARSET', aclKey, '0', 'x');
251+
await rte.data.setAclUserRules('~* +@all -arscan');
252+
},
248253
},
249254
].map(mainCheckFn);
250255
});

0 commit comments

Comments
 (0)