-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern Validation - Max Length Issue Fix #1426
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samyakOO7
requested review from
joelrosario,
nashjain,
harikrishnan83,
pranavgawri,
yogeshnikam671 and
StarKhan6368
November 14, 2024 11:51
- Removing comments and instead renaming variables for readability - Removing redundant rows in parameterised test for min and max length based String generation - Adding test for regex based generation - Extracting regex generation code to separate method
harikrishnan83
removed request for
nashjain,
pranavgawri,
yogeshnikam671 and
StarKhan6368
November 19, 2024 04:40
harikrishnan83
approved these changes
Nov 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
joelrosario
requested changes
Nov 21, 2024
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
core/src/main/kotlin/io/specmatic/core/pattern/StringPattern.kt
Outdated
Show resolved
Hide resolved
core/src/test/kotlin/io/specmatic/core/pattern/StringPatternTest.kt
Outdated
Show resolved
Hide resolved
core/src/test/kotlin/io/specmatic/core/pattern/StringPatternTest.kt
Outdated
Show resolved
Hide resolved
* main: (124 commits) Fix schema regex and generation 2.0.43 Generate 4xx responses as per the schema in virtual-service be it any pattern containing a json object pattern Ignore a seed data entry which involves attribute selection during the seed data load stage of the virtual service Ignore a seed data entry with an id which is pre-existing in the cache of the virtual service Fix failing tests due to stale config. Add test for ExamplePreProcessor Add tests for Asserts. Cleanup on amber validation. 2.0.42 Changes for GoBack Added Details Pre Div Removed highlighting of specmatic errors in editor Editor syntax highlighting Fix full pattern validation with ListPattern. Add tests for partially valid examples. Better mismatchMessages for missing optional keys. better variable namings and partial handling Interactive Server partially valid examples. Modify result logic when all keys are mandatory. ...
- adding tests for contradicting length constraints and regex
harikrishnan83
approved these changes
Dec 14, 2024
joelrosario
approved these changes
Dec 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pattern validation was taking priority in response schema for stub and request schema for test over max length parameter due to random() method generating value more than default
Fixed the use case putting a constraint of max length on random() method so that it never generates value for than max length keeping the current logic intact
Test Spec File - validate-regex-spec.yaml.zip
Backward Compatibility Spec (v2.0.36 release check) -
validate-regex-spec.yaml.zip
Logic used -
Test for maximum length conditions :
Request :
{minLength : 2, maxLength: 11}
Response :
{minLength : 2, maxLength: 6}
Before Stub :
Generated value : 9 digit
Before Test:
Details:
After Issue Fixed Stub:
After Issue Fixed Test:
Test for Minimum Length conditions:
Request :
{minLength : 2, maxLength: 11}
Response :
{minLength : 2, maxLength: 6}
Stub:
Before Fix (The output generated was defaulting to 5 as minimum for num<5 (breaching min validation):
After Fix (Min validation is respected):
Test :
Before Fix:
After Fix :
Some edge cases taken care of defaults -
Request { maxLength = 4 }
Response { maxLength = 4 }
min = null and max (4) < default (5) [pattern (min = Generex(min val = 1), max = 4)]
Stub-
Test -
Request { maxLength = 15 }
Response { maxLength = 15 }
min length = null and max length > default (5) [pattern (min = default(5), max = 15)]
Stub-
Test -
Clear outputs respecting validation schema are found with multiple test of min and max length
Thanks