-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Merging to release-5.3: fix unnecessary call to DeleteRawKey if no allowance scope is defined (TT-11721) (#6373) #6375
Merging to release-5.3: fix unnecessary call to DeleteRawKey if no allowance scope is defined (TT-11721) (#6373) #6375
Conversation
…#6373) ### **User description** This PR fixes an issue where `DeleteRawKey` is called multiple times for AllowanceScopes that are non-existent. ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] 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) ___ ### **PR Type** Bug fix, Tests ___ ### **Description** - Added a new method `deleteRawKeysWithAllowanceScope` in `DefaultSessionManager` to handle deletion of raw keys with allowance scopes. - Modified `ResetQuota` to use the new method for better handling of raw key deletions. - Implemented checks to skip deletion if the allowance scope is empty, preventing unnecessary calls. - Added comprehensive unit tests for the new method, covering various edge cases and ensuring correct behavior. ___ ### **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>auth_manager.go</strong><dd><code>Add method to handle raw key deletion with allowance scopes</code></dd></summary> <hr> gateway/auth_manager.go <li>Added a new method <code>deleteRawKeysWithAllowanceScope</code> to handle deletion <br>of raw keys with allowance scopes.<br> <li> Modified <code>ResetQuota</code> to use the new method.<br> <li> Added checks to skip deletion if the allowance scope is empty.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6373/files#diff-311e18b071d244ed1615c0019215b633278679df373288b3451bcc5cf7c52c4e">+13/-2</a> </td> </tr> </table></td></tr><tr><td><strong>Tests </strong></td><td><table> <tr> <td> <details> <summary><strong>auth_manager_test.go</strong><dd><code>Add unit tests for deleteRawKeysWithAllowanceScope method</code></dd></summary> <hr> gateway/auth_manager_test.go <li>Added unit tests for <code>deleteRawKeysWithAllowanceScope</code> method.<br> <li> Created a mock <code>countingStorageHandler</code> to count delete operations.<br> <li> Tested various scenarios including nil storage handler, nil session, <br>and sessions with/without allowance scopes.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6373/files#diff-665d567ebb80f4c7bb6c683cc8ad317928a10b450468634506012a20a54153c9">+190/-0</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 (cherry picked from commit 3985ca2)
PR Reviewer Guide 🔍
|
API Changes no api changes detected |
PR Code Suggestions ✨
|
|
User description
fix unnecessary call to DeleteRawKey if no allowance scope is defined (#6373)
User description
This PR fixes an issue where
DeleteRawKey
is called multiple times forAllowanceScopes that are non-existent.
Types of changes
functionality to change)
coverage to functionality)
PR Type
Bug fix, Tests
Description
deleteRawKeysWithAllowanceScope
inDefaultSessionManager
to handle deletion of raw keys with allowancescopes.
ResetQuota
to use the new method for better handling of rawkey deletions.
preventing unnecessary calls.
edge cases and ensuring correct behavior.
Changes walkthrough 📝
auth_manager.go
Add method to handle raw key deletion with allowance scopes
gateway/auth_manager.go
deleteRawKeysWithAllowanceScope
to handle deletionof raw keys with allowance scopes.
ResetQuota
to use the new method.auth_manager_test.go
Add unit tests for deleteRawKeysWithAllowanceScope method
gateway/auth_manager_test.go
deleteRawKeysWithAllowanceScope
method.countingStorageHandler
to count delete operations.and sessions with/without allowance scopes.
PR Type
Bug fix, Tests
Description
deleteRawKeysWithAllowanceScope
inDefaultSessionManager
to handle deletion of raw keys with allowance scopes.ResetQuota
to use the new method for better handling of raw key deletions.Changes walkthrough 📝
auth_manager.go
Add method for raw key deletion with allowance scopes
gateway/auth_manager.go
deleteRawKeysWithAllowanceScope
method to handle raw keydeletions with allowance scopes.
ResetQuota
to use the new method.auth_manager_test.go
Add unit tests for raw key deletion method
gateway/auth_manager_test.go
deleteRawKeysWithAllowanceScope
.countingStorageHandler
for test purposes.