pycloudinary icon indicating copy to clipboard operation
pycloudinary copied to clipboard

Fix signature containing boolean values

Open 0x4a616e opened this issue 1 year ago • 1 comments

True in python was converted to "True" in signature calculation. JSON serialisation however converted it to "true", which resulted in invalid signatures being calculated.

Brief Summary of Changes

Signature calculation correctly handles boolean values.

What does this PR address?

  • [ ] GitHub issue (Add reference - #XX)
  • [ ] Refactoring
  • [ ] New feature
  • [X] Bug fix
  • [ ] Adds more tests

Are tests included?

  • [ ] Yes
  • [X] No

Reviewer, please note:

Checklist:

  • [ ] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I ran the full test suite before pushing the changes and all the tests pass.

0x4a616e avatar Aug 28 '24 09:08 0x4a616e

@0x4a616e , thank you for the pull request!

This is an internal (although marked as public) function.

The function to use is:

https://github.com/cloudinary/pycloudinary/blob/002c705d01d31c3c1ecd6ac50fb2a0aa65f8c989/cloudinary/utils.py#L614

Inside it performs parameters cleanup and normalization: https://github.com/cloudinary/pycloudinary/blob/002c705d01d31c3c1ecd6ac50fb2a0aa65f8c989/cloudinary/utils.py#L623

https://github.com/cloudinary/pycloudinary/blob/002c705d01d31c3c1ecd6ac50fb2a0aa65f8c989/cloudinary/utils.py#L591

(please note that boolean parameters in Upload API are converted to integers (1/0).

If you still prefer to keep your fix, please add a unit test somewhere here: https://github.com/cloudinary/pycloudinary/blob/002c705d01d31c3c1ecd6ac50fb2a0aa65f8c989/test/test_utils.py#L1452

And after that we can merge it.

const-cloudinary avatar Aug 28 '24 12:08 const-cloudinary