Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging to release-5.7: [TT-12710]deleting All Partitioned Policies a…
… Key is linked to does not delete the Key (#6473) (#6781) ### **User description** [TT-12710]deleting All Partitioned Policies a Key is linked to does not delete the Key (#6473) ### **User description** TASK: https://tyktech.atlassian.net/browse/TT-12710 Fixed case in which trying to apply a non-existing policy error would be swallowed when having partitioned keys. <!-- Provide a general summary of your changes in the Title above --> ## Description <!-- Describe your changes in detail --> ## Related Issue <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Bug fix ___ ### **Description** - Fixed a bug where errors for non-existing policies were ignored if multiple policies were processed, ensuring that an error is returned immediately. - Improved error handling in the `Apply` method of the `Service` to prevent silent failures when policies are missing. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>apply.go</strong><dd><code>Fix error handling for non-existing policies in Apply method</code></dd></summary> <hr> internal/policy/apply.go <li>Removed logic that continued processing policies when a non-existing <br>policy was encountered.<br> <li> Ensured that an error is returned immediately if a policy is not <br>found.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6473/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+0/-4</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions [TT-12710]: https://tyktech.atlassian.net/browse/TT-12710?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ ### **PR Type** Bug fix, Tests ___ ### **Description** - Fixed a bug where keys with no valid policies were not handled correctly, ensuring an error is returned when no applicable policies exist. - Enhanced test cases across multiple files to validate policy application, deletion, and behavior in various scenarios. - Simplified policy synchronization logic in the gateway server. - Added utility functions for policy deletion to improve test management. - Improved JWT session and multi-authentication tests to include API ID and access rights in policies. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>api_test.go</strong><dd><code>Enhanced test coverage for policy application and deletion.</code></dd></summary> <hr> gateway/api_test.go <li>Added new test cases to validate policy application and deletion <br>behavior.<br> <li> Enhanced existing test cases to include additional policy scenarios.<br> <li> Introduced a new policy with ACL and access rights for testing.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+102/-26</a></td> </tr> <tr> <td> <details> <summary><strong>multiauth_test.go</strong><dd><code>Updated multi-authentication tests with policy enhancements.</code></dd></summary> <hr> gateway/multiauth_test.go <li>Updated test cases to include API ID and access rights in policies.<br> <li> Improved test scenarios for multi-authentication with JWT.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-f7a567eba510b8bdffbc8e0878461e5dac9c066e8cc5feaa18eeccde54555f22">+7/-2</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_jwt_test.go</strong><dd><code>Enhanced JWT session tests with policy validation.</code> </dd></summary> <hr> gateway/mw_jwt_test.go <li>Added API ID and access rights to policies in JWT-related tests.<br> <li> Enhanced JWT session tests to validate policy behavior.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-406bf8fdb6c0cc77f04c6245c70abfc592ddb1525aa843200d850e14d135ebfc">+137/-12</a></td> </tr> <tr> <td> <details> <summary><strong>testutil.go</strong><dd><code>Added policy deletion utility for tests.</code> </dd></summary> <hr> gateway/testutil.go <li>Added a utility function to delete policies during tests.<br> <li> Improved test utilities for policy management.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-7aaf6ae49fb8f58a8c99d337fedd15b3e430dd928ed547e425ef429b10d28ce8">+6/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>apply_test.go</strong><dd><code>Improved tests for custom policy application.</code> </dd></summary> <hr> internal/policy/apply_test.go <li>Updated tests to include ACL validation in policy application.<br> <li> Enhanced test cases for custom policy application logic.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-5af7e299a6b0ce11e22f8aa4a01854b1151f4b54dccc68f0cd1cbedee5aed7c8">+5/-2</a> </td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>server.go</strong><dd><code>Simplified policy synchronization logic.</code> </dd></summary> <hr> gateway/server.go <li>Simplified policy synchronization logic by removing redundant checks.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+1/-3</a> </td> </tr> </table></td></tr><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>apply.go</strong><dd><code>Fixed error handling for invalid policy application.</code> </dd></summary> <hr> internal/policy/apply.go <li>Fixed bug where keys with no valid policies were not handled <br>correctly.<br> <li> Added error handling for sessions with no applicable policies.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6781/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+4/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information Co-authored-by: andrei-tyk <[email protected]>
- Loading branch information