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

Merging to release-5.3: fix unnecessary call to DeleteRawKey if no allowance scope is defined (TT-11721) (#6373) #6375

Merged

Commits on Jun 26, 2024

  1. 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 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>&nbsp;
    &nbsp; </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>&nbsp;
    </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)
    pvormste authored and Tyk Bot committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    4a0a9a0 View commit details
    Browse the repository at this point in the history