From 49ca4db7ba650c8ca3b1345090e2e8a728bac126 Mon Sep 17 00:00:00 2001 From: elwafa Date: Wed, 12 Feb 2025 21:18:03 +0200 Subject: [PATCH 1/3] preparing for release v0.9.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e8bfd50..163f51d 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "volt-test/php-sdk", "description": "Volt Test PHP SDK - A performance testing tool for PHP applications", "type": "library", - "version": "0.9.0", + "version": "0.9.1", "keywords": [ "volt-test", "php-sdk", From 60dbc587a3fe1f8d35d8ec4195af164da4c17fd3 Mon Sep 17 00:00:00 2001 From: Islam A-Elwafa Date: Wed, 12 Feb 2025 21:46:15 +0200 Subject: [PATCH 2/3] feat(validation): Support array indexing in JSON path validation (#21) * feat(validation): Support array indexing in JSON path validation - Updated the JSON path validation regex to allow array indexing (e.g., `$.data[0].attribute`). - Ensured compatibility with dot notation for nested objects (e.g., `$.data.object.attribute`). - Improved validation to support mixed array and object paths (e.g., `$.data[0].nested[2].value`). - Added stricter checks to prevent malformed paths. --- src/Extractors/JsonExtractor.php | 5 +++-- tests/Units/JsonExtractorTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Extractors/JsonExtractor.php b/src/Extractors/JsonExtractor.php index c7c6fb2..7a1cb17 100644 --- a/src/Extractors/JsonExtractor.php +++ b/src/Extractors/JsonExtractor.php @@ -44,10 +44,11 @@ public function validate(): bool if (empty($this->selector) || $this->selector === '$.') { throw new InvalidJsonPathException('JSON path cannot be empty'); } - // Validate the selector ex: $.meta.token + // Validate the selector ex: $.meta.token or $.data[0].name // Validate the selector follows proper JSON path format // Should start with $ followed by dot and valid path segments - if (! preg_match('/^\$(\.[a-zA-Z0-9_]+)*$/', $this->selector)) { + $pattern = '/^\$(\.[a-zA-Z0-9_]+|\[[0-9]+\])*$/'; + if (! preg_match($pattern, $this->selector)) { throw new InvalidJsonPathException('Invalid JSON path'); } diff --git a/tests/Units/JsonExtractorTest.php b/tests/Units/JsonExtractorTest.php index b16c437..6a7dcfb 100644 --- a/tests/Units/JsonExtractorTest.php +++ b/tests/Units/JsonExtractorTest.php @@ -46,6 +46,9 @@ public static function validJsonPathProvider(): array ['with_underscore'], ['with.numbers.123'], ['mixed.path_with.numbers123'], + ['mixed[0].path'], + ['mixed[0].path[1]'], + ['mixed[0].path[1].with[2].numbers[3]'], ]; } @@ -67,6 +70,12 @@ public static function invalidJsonPathProvider(): array ['$invalid.start'], ['invalid$.middle'], ['path.with.$'], + ['$.data[abc]'], + ['$.data[0].name[abc]'], + ['$.data[0].name[0].'], + ['$.data[0].name[0].[1]'], + ['$.data[0].name[0].[1].'], + ['$.data[0].name[0].[1].name'], ]; } From addf2df95f6bb3010b0d3e5d92d15c811d7132d3 Mon Sep 17 00:00:00 2001 From: elwafa Date: Wed, 12 Feb 2025 21:53:54 +0200 Subject: [PATCH 3/3] update engine version --- src/Platform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform.php b/src/Platform.php index 5ca62a9..85f5de7 100644 --- a/src/Platform.php +++ b/src/Platform.php @@ -6,7 +6,7 @@ class Platform { private const BINARY_NAME = 'volt-test'; - private const ENGINE_CURRENT_VERSION = 'v0.1.1'; + private const ENGINE_CURRENT_VERSION = 'v0.9.1'; private const BASE_DOWNLOAD_URL = 'https://github.com/volt-test/binaries/releases/download'; private const SUPPORTED_PLATFORMS = [ 'linux-amd64' => 'volt-test-linux-amd64',