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

Invalid JSON payload when using CustomClaims with T that serialize to an JSON object #39

Closed
xbb opened this issue May 31, 2024 · 2 comments

Comments

@xbb
Copy link

xbb commented May 31, 2024

Describe the bug
If you pass a serializable struct to CustomClaims the builder will generate an invalid JSON payload due to the trimming of multiple object delimiters.

The builder will still build a token successfully, but the validation will fail with a JSON error.

See my quick fix attempt here: xbb@00b1a90

@rrrodzilla
Copy link
Owner

Thanks I'll have a look

rrrodzilla added a commit that referenced this issue Jun 1, 2024
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.
rrrodzilla added a commit that referenced this issue Jun 1, 2024
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 added a commit that referenced this issue Jun 1, 2024
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 added a commit that referenced this issue Jun 1, 2024
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 added a commit that referenced this issue Jun 1, 2024
* 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
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.

* chore(release): bump version to 0.7.1

Updated Cargo.toml to reflect the new version 0.7.1.

* fix: resolve invalid JSON payloads with CustomClaims (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.

* fix: resolve invalid JSON payloads with CustomClaims (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 mentioned this issue Jun 1, 2024
@rrrodzilla
Copy link
Owner

rrrodzilla commented Jun 1, 2024

Closing issue #39 as it has been addressed in PR #40 and published to crates.io as v0.7.1. Please refer to the closing notes in the PR for a description of the fix. Credit and thanks to @xbb for reporting the issue and offering a suggestion on the fix.

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

No branches or pull requests

2 participants