Skip to content
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

Hotfix v0.7.1 #40

Merged
merged 12 commits into from
Jun 1, 2024
Merged

Hotfix v0.7.1 #40

merged 12 commits into from
Jun 1, 2024

Conversation

rrrodzilla
Copy link
Owner

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Please provide enough information so that others can review your pull request:

Explain the details for making this change. What existing problem does the pull request solve?

Test plan (required)

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Code formatting

Closing issues

Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).

rrrodzilla added 12 commits May 31, 2024 11:43
Added build_payload_from_claims_prop_test.rs to include regression tests for issue #39, ensuring the fix for invalid JSON payloads with CustomClaims remains effective.
Introduced generic_claims_wrap_value_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Created an empty generic_claims_wrap_value_prop_test.rs file for future test implementations.
…_claims

Added proptest dependency to Cargo.toml for property-based testing.
Created build_payload_from_claims_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Updated build_payload_from_claims_prop_test.rs to include detailed property tests for the build_payload_from_claims function.
Added generic_claims_wrap_value_prop_test.proptest-regressions with additional seeds for failure cases.
Implemented generic_claims_wrap_value_prop_test.rs to validate the correctness and robustness of the wrap_value function using property tests.
Updated set_claim method to ignore empty keys and handle null values correctly.
Refactored build_payload_from_claims to ensure proper nesting and serialization of claims.
Added wrap_claims and wrap_value helper functions to handle JSON object wrapping.
Included comprehensive tests for various claim scenarios:
Custom claim serialization
Empty claims
Null claims
Nested structures
Multiple claims
Different data types
…o claims

Refactored GenericBuilder to improve readability and maintainability.
Added tests for dynamic claims and scenarios with no claims for V2, Local tokens.
Ensured proper handling of various claim types and edge cases in the builder and parser.
Updated Cargo.toml to reflect the new version 0.7.1.
Updated Cargo.toml to reflect the new version 0.7.1.
These commits are intended to fix issue #39.

feat(tests): add regression tests for issue #39 and proptest seeds

Added build_payload_from_claims_prop_test.rs to include regression tests for issue #39, ensuring the fix for invalid JSON payloads with CustomClaims remains effective.
Introduced generic_claims_wrap_value_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Created an empty generic_claims_wrap_value_prop_test.rs file for future test implementations.
feat(tests): add property tests for wrap_value and build_payload_from_claims

Added proptest dependency to Cargo.toml for property-based testing.
Created build_payload_from_claims_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Updated build_payload_from_claims_prop_test.rs to include detailed property tests for the build_payload_from_claims function.
Added generic_claims_wrap_value_prop_test.proptest-regressions with additional seeds for failure cases.
Implemented generic_claims_wrap_value_prop_test.rs to validate the correctness and robustness of the wrap_value function using property tests.
fix(generic_builder): handle empty keys and null values in claims

Updated set_claim method to ignore empty keys and handle null values correctly.
Refactored build_payload_from_claims to ensure proper nesting and serialization of claims.
Added wrap_claims and wrap_value helper functions to handle JSON object wrapping.
Included comprehensive tests for various claim scenarios: custom claim serialization, empty claims, null claims, nested structures, multiple claims, and different data types.
fix(generic_builder): refactor and add tests for dynamic claims and no claims

Refactored GenericBuilder to improve readability and maintainability.
Added tests for dynamic claims and scenarios with no claims for V2, Local tokens.
Ensured proper handling of various claim types and edge cases in the builder and parser.
chore(release): bump version to 0.7.1

Updated Cargo.toml to reflect the new version 0.7.1.
These changes aim to address and resolve the issues related to invalid JSON payloads when using CustomClaims as described in issue #39.
These commits are intended to fix issue #39.

feat(tests): add regression tests for issue #39 and proptest seeds

Added build_payload_from_claims_prop_test.rs to include regression tests for issue #39, ensuring the fix for invalid JSON payloads with CustomClaims remains effective.
Introduced generic_claims_wrap_value_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Created an empty generic_claims_wrap_value_prop_test.rs file for future test implementations.
feat(tests): add property tests for wrap_value and build_payload_from_claims

Added proptest dependency to Cargo.toml for property-based testing.
Created build_payload_from_claims_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Updated build_payload_from_claims_prop_test.rs to include detailed property tests for the build_payload_from_claims function.
Added generic_claims_wrap_value_prop_test.proptest-regressions with additional seeds for failure cases.
Implemented generic_claims_wrap_value_prop_test.rs to validate the correctness and robustness of the wrap_value function using property tests.
fix(generic_builder): handle empty keys and null values in claims

Updated set_claim method to ignore empty keys and handle null values correctly.
Refactored build_payload_from_claims to ensure proper nesting and serialization of claims.
Added wrap_claims and wrap_value helper functions to handle JSON object wrapping.
Included comprehensive tests for various claim scenarios: custom claim serialization, empty claims, null claims, nested structures, multiple claims, and different data types.
fix(generic_builder): refactor and add tests for dynamic claims and no claims

Refactored GenericBuilder to improve readability and maintainability.
Added tests for dynamic claims and scenarios with no claims for V2, Local tokens.
Ensured proper handling of various claim types and edge cases in the builder and parser.
chore(release): bump version to 0.7.1

Updated Cargo.toml to reflect the new version 0.7.1.
These changes aim to address and resolve the issues related to invalid JSON payloads when using CustomClaims as described in issue #39.
These commits are intended to fix issue #39.

feat(tests): add regression tests for issue #39 and proptest seeds

Added build_payload_from_claims_prop_test.rs to include regression tests for issue #39, ensuring the fix for invalid JSON payloads with CustomClaims remains effective.
Introduced generic_claims_wrap_value_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Created an empty generic_claims_wrap_value_prop_test.rs file for future test implementations.
feat(tests): add property tests for wrap_value and build_payload_from_claims

Added proptest dependency to Cargo.toml for property-based testing.
Created build_payload_from_claims_prop_test.proptest-regressions to store seeds for failure cases generated by proptest.
Updated build_payload_from_claims_prop_test.rs to include detailed property tests for the build_payload_from_claims function.
Added generic_claims_wrap_value_prop_test.proptest-regressions with additional seeds for failure cases.
Implemented generic_claims_wrap_value_prop_test.rs to validate the correctness and robustness of the wrap_value function using property tests.
fix(generic_builder): handle empty keys and null values in claims

Updated set_claim method to ignore empty keys and handle null values correctly.
Refactored build_payload_from_claims to ensure proper nesting and serialization of claims.
Added wrap_claims and wrap_value helper functions to handle JSON object wrapping.
Included comprehensive tests for various claim scenarios: custom claim serialization, empty claims, null claims, nested structures, multiple claims, and different data types.
fix(generic_builder): refactor and add tests for dynamic claims and no claims

Refactored GenericBuilder to improve readability and maintainability.
Added tests for dynamic claims and scenarios with no claims for V2, Local tokens.
Ensured proper handling of various claim types and edge cases in the builder and parser.
chore(release): bump version to 0.7.1

Updated Cargo.toml to reflect the new version 0.7.1.
These changes aim to address and resolve the issues related to invalid JSON payloads when using CustomClaims as described in issue #39.
@rrrodzilla rrrodzilla merged commit cce5cf5 into main Jun 1, 2024
36 checks passed
@rrrodzilla rrrodzilla deleted the hotfix-v0.7.1 branch June 1, 2024 00:45
@rrrodzilla
Copy link
Owner Author

rrrodzilla commented Jun 1, 2024

Pull Request Summary

Description

This pull request closes #39 , which reported an invalid JSON payload when using CustomClaims with types that serialize to JSON objects. The issue caused the builder to generate an invalid JSON payload due to improper handling of multiple object delimiters, resulting in successful token creation but failed validation with a JSON error.

Changes Made

  • Updated the build_payload_from_claims function:

    • Ensured proper serialization and wrapping of claims into valid JSON objects.
    • Implemented a recursive function to wrap each claim value to maintain valid JSON structure.
  • Added utility functions:

    • wrap_claims: Recursively wraps each claim value to ensure all values are valid JSON objects.
    • wrap_value: Ensures proper nesting of JSON values, handling various edge cases including empty objects, arrays, and null values.
  • Included comprehensive tests:

    • Added property tests for wrap_value and build_payload_from_claims functions, validating correctness and robustness.
    • Added unit tests for scenarios including null values, empty objects, primitive values, arrays, nested structures, and multiple claims.

Key Test Scenarios

  • Null Values: Ensures null values remain null and are not wrapped unnecessarily.
  • Empty Objects: Verifies that empty maps are wrapped as empty JSON objects.
  • Primitive Values: Confirms that primitive values (e.g., strings, numbers) remain unchanged.
  • Arrays: Ensures arrays, including empty arrays, are wrapped correctly and consistently.
  • Nested Structures: Validates the recursive wrapping and serialization of nested JSON objects and arrays.
  • Multiple Claims: Confirms that multiple claims of different data types are correctly serialized and validated.

Conclusion

The updates ensure that the CustomClaims builder generates valid JSON payloads, resolving the reported issue. The added tests demonstrate that the solution is robust and reliable for various practical use cases, contributing to the overall stability and reliability of the system.

Credit and thanks to @xbb for reporting the issue by opening issue #39 and for taking the time to offer a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant