Skip to content

Commit

Permalink
fix: added stronger tag validations (#5585)
Browse files Browse the repository at this point in the history
Now it is impossible to filter based on invalid tag syntax.
  • Loading branch information
sjaanus authored Dec 11, 2023
1 parent ec67045 commit e8f19e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/lib/features/feature-search/feature.search.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ test('should filter features by tag', async () => {
{ name: 'my_feature_c' },
],
});

await filterFeaturesByTag('EXCLUDE_ALL:simple', 400);
await filterFeaturesByTag('EXCLUDE_ALL:simple,simple', 400);
await filterFeaturesByTag('EXCLUDE_ALL:simple,simple:jest', 400);
});

test('should filter features by environment status', async () => {
Expand Down Expand Up @@ -786,9 +790,18 @@ test('should filter features by segment', async () => {
});

test('should search features by state with operators', async () => {
await app.createFeature({ name: 'my_feature_a', stale: false });
await app.createFeature({ name: 'my_feature_b', stale: true });
await app.createFeature({ name: 'my_feature_c', stale: true });
await app.createFeature({
name: 'my_feature_a',
stale: false,
});
await app.createFeature({
name: 'my_feature_b',
stale: true,
});
await app.createFeature({
name: 'my_feature_c',
stale: true,
});

const { body } = await filterFeaturesByState('IS:active');
expect(body).toMatchObject({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openapi/spec/feature-search-query-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const featureSearchQueryParameters = [
schema: {
type: 'string',
pattern:
'^(INCLUDE|DO_NOT_INCLUDE|INCLUDE_ALL_OF|INCLUDE_ANY_OF|EXCLUDE_IF_ANY_OF|EXCLUDE_ALL):(.*?)(,([a-zA-Z0-9_]+))*$',
'^(INCLUDE|DO_NOT_INCLUDE|INCLUDE_ALL_OF|INCLUDE_ANY_OF|EXCLUDE_IF_ANY_OF|EXCLUDE_ALL):(?:\\s*[^,:]+:[^,:]+\\s*)(?:,\\s*[^,:]+:[^,:]+\\s*)*$',
example: 'INCLUDE:simple:my_tag',
},
description:
Expand Down

0 comments on commit e8f19e6

Please sign in to comment.