From 29dcd98b92a3a8a3034705b6d13d2304dbdb4062 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Tue, 11 Jun 2024 15:14:13 -0400 Subject: [PATCH] Add tests for source-side set sizes (#1332) In preparation for addressing #1321. --- ts/src/header-validator/source.test.ts | 40 +++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/ts/src/header-validator/source.test.ts b/ts/src/header-validator/source.test.ts index f92ed9bd4e..e5e31d1da9 100644 --- a/ts/src/header-validator/source.test.ts +++ b/ts/src/header-validator/source.test.ts @@ -197,6 +197,31 @@ const testCases: TestCase[] = [ }, ], }, + { + name: 'destination-list-empty', + json: `{"destination": []}`, + expectedErrors: [ + { + path: ['destination'], + msg: 'length must be in the range [1, 3]', + }, + ], + }, + { + name: 'destination-list-too-long', + json: `{"destination": [ + "https://a.test", + "https://b.test/1", + "https://b.test/2", + "https://c.test/3" + ]}`, + expectedErrors: [ + { + path: ['destination'], + msg: 'length must be in the range [1, 3]', + }, + ], + }, { name: 'filter-data-wrong-type', @@ -350,7 +375,7 @@ const testCases: TestCase[] = [ name: 'filter-data-too-many-values', json: JSON.stringify({ destination: 'https://a.test', - filter_data: { a: Array.from({ length: 51 }, (_, i) => `${i}`) }, + filter_data: { a: Array.from({ length: 51 }, () => '') }, }), expectedErrors: [ { @@ -2079,6 +2104,19 @@ const testCases: TestCase[] = [ }, ], }, + { + name: 'trigger-data-too-many-within', + json: JSON.stringify({ + destination: 'https://a.test', + trigger_data: Array.from({ length: 33 }, () => 0), + }), + expectedErrors: [ + { + path: ['trigger_data'], + msg: 'length must be in the range [0, 32]', + }, + ], + }, { name: 'trigger-data-duplicated-across', json: `{