[TT-10856/TT-11778] fix quota limit remaining header value when key is created from policy and API is looped#6199
Conversation
|
PR Description updated to latest commit (086e61e) |
|
API Changes no api changes detected |
PR Review
Code feedback:
✨ Review tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview:
See the improve usage page for a comprehensive guide on using this tool. |
|
|
/release to release-5.3 |
|
/release to release-5-lts |
|
Working on it! Note that it can take a few minutes. |
1 similar comment
|
Working on it! Note that it can take a few minutes. |
…s created from policy and API is looped (#6199) ## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description `X-RateLimit-Remaining` header was returning `0` when key was created from policy and API is looped with `tyk://self` This is because `AuthKey` middleware is calling `CheckSessionAndIdentityForValidKey` once again during looping. This check can be skipped like what we do for `RateLimitAndQuotaCheck` middleware ## 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: --> - [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) ## 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 ___ ## **Type** bug_fix ___ ## **Description** - Fixed an issue where `X-RateLimit-Remaining` header returned incorrect values for looped requests when the key was created from a policy. - Refactored test setup for quota middleware to streamline session creation. - Added comprehensive tests to ensure correct quota headers are returned for various key and policy configurations. ___ ## **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>middleware_test.go</strong><dd><code>Refactor Test Setup for Quota Middleware</code> </dd></summary> <hr> gateway/middleware_test.go <li>Removed <code>createSessionWithQuota</code> function as it was replaced with a more <br>streamlined session creation in tests.<br> <li> Modified <code>TestQuotaNotAppliedWithURLRewrite</code> to use the new session <br>creation method. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+17/-28</a> </td> </tr> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>Extend Tests for Quota Response Headers</code> </dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added tests to verify correct quota headers for keys without policies, <br>keys from policies with per API limits, and keys from policies with <br>global limits. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+112/-31</a></td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_auth_key.go</strong><dd><code>Skip Auth Key Check for Looped Requests</code> </dd></summary> <hr> gateway/mw_auth_key.go <li>Added a check to skip auth key verification if the request is looped <br>and session limits are not to be checked. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+5/-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 83cfda1)
|
@jeffy-mathew Succesfully merged PR |
…s created from policy and API is looped (#6199) <!-- Provide a general summary of your changes in the Title above --> `X-RateLimit-Remaining` header was returning `0` when key was created from policy and API is looped with `tyk://self` This is because `AuthKey` middleware is calling `CheckSessionAndIdentityForValidKey` once again during looping. This check can be skipped like what we do for `RateLimitAndQuotaCheck` middleware <!-- 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. --> <!-- Why is this change required? What problem does it solve? --> <!-- 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. --> <!-- 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) <!-- 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 ___ bug_fix ___ - Fixed an issue where `X-RateLimit-Remaining` header returned incorrect values for looped requests when the key was created from a policy. - Refactored test setup for quota middleware to streamline session creation. - Added comprehensive tests to ensure correct quota headers are returned for various key and policy configurations. ___ <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>middleware_test.go</strong><dd><code>Refactor Test Setup for Quota Middleware</code> </dd></summary> <hr> gateway/middleware_test.go <li>Removed <code>createSessionWithQuota</code> function as it was replaced with a more <br>streamlined session creation in tests.<br> <li> Modified <code>TestQuotaNotAppliedWithURLRewrite</code> to use the new session <br>creation method. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+17/-28</a> </td> </tr> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>Extend Tests for Quota Response Headers</code> </dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added tests to verify correct quota headers for keys without policies, <br>keys from policies with per API limits, and keys from policies with <br>global limits. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+112/-31</a></td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_auth_key.go</strong><dd><code>Skip Auth Key Check for Looped Requests</code> </dd></summary> <hr> gateway/mw_auth_key.go <li>Added a check to skip auth key verification if the request is looped <br>and session limits are not to be checked. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+5/-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 83cfda1)
|
@jeffy-mathew Succesfully merged PR |
… header value when key is created from policy and API is looped (#6199) [TT-10856/TT-11778] fix quota limit remaining header value when key is created from policy and API is looped (#6199) ## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description `X-RateLimit-Remaining` header was returning `0` when key was created from policy and API is looped with `tyk://self` This is because `AuthKey` middleware is calling `CheckSessionAndIdentityForValidKey` once again during looping. This check can be skipped like what we do for `RateLimitAndQuotaCheck` middleware ## 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: --> - [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) ## 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 ___ ## **Type** bug_fix ___ ## **Description** - Fixed an issue where `X-RateLimit-Remaining` header returned incorrect values for looped requests when the key was created from a policy. - Refactored test setup for quota middleware to streamline session creation. - Added comprehensive tests to ensure correct quota headers are returned for various key and policy configurations. ___ ## **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>middleware_test.go</strong><dd><code>Refactor Test Setup for Quota Middleware</code> </dd></summary> <hr> gateway/middleware_test.go <li>Removed <code>createSessionWithQuota</code> function as it was replaced with a more <br>streamlined session creation in tests.<br> <li> Modified <code>TestQuotaNotAppliedWithURLRewrite</code> to use the new session <br>creation method. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+17/-28</a> </td> </tr> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>Extend Tests for Quota Response Headers</code> </dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added tests to verify correct quota headers for keys without policies, <br>keys from policies with per API limits, and keys from policies with <br>global limits. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+112/-31</a></td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_auth_key.go</strong><dd><code>Skip Auth Key Check for Looped Requests</code> </dd></summary> <hr> gateway/mw_auth_key.go <li>Added a check to skip auth key verification if the request is looped <br>and session limits are not to be checked. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+5/-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
…ng header value when key is created from policy and API is looped (#6199) (#6201) [TT-10856/TT-11778] fix quota limit remaining header value when key is created from policy and API is looped (#6199) ## **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description `X-RateLimit-Remaining` header was returning `0` when key was created from policy and API is looped with `tyk://self` This is because `AuthKey` middleware is calling `CheckSessionAndIdentityForValidKey` once again during looping. This check can be skipped like what we do for `RateLimitAndQuotaCheck` middleware ## 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: --> - [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) ## 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 ___ ## **Type** bug_fix ___ ## **Description** - Fixed an issue where `X-RateLimit-Remaining` header returned incorrect values for looped requests when the key was created from a policy. - Refactored test setup for quota middleware to streamline session creation. - Added comprehensive tests to ensure correct quota headers are returned for various key and policy configurations. ___ ## **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>middleware_test.go</strong><dd><code>Refactor Test Setup for Quota Middleware</code> </dd></summary> <hr> gateway/middleware_test.go <li>Removed <code>createSessionWithQuota</code> function as it was replaced with a more <br>streamlined session creation in tests.<br> <li> Modified <code>TestQuotaNotAppliedWithURLRewrite</code> to use the new session <br>creation method. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+17/-28</a> </td> </tr> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>Extend Tests for Quota Response Headers</code> </dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added tests to verify correct quota headers for keys without policies, <br>keys from policies with per API limits, and keys from policies with <br>global limits. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+112/-31</a></td> </tr> </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>mw_auth_key.go</strong><dd><code>Skip Auth Key Check for Looped Requests</code> </dd></summary> <hr> gateway/mw_auth_key.go <li>Added a check to skip auth key verification if the request is looped <br>and session limits are not to be checked. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6199/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+5/-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 --------- Co-authored-by: Jeffy Mathew <[email protected]>


User description
Description
X-RateLimit-Remainingheader was returning0when key was created from policy and API is looped withtyk://selfThis is because
AuthKeymiddleware is callingCheckSessionAndIdentityForValidKeyonce again during looping.This check can be skipped like what we do for
RateLimitAndQuotaCheckmiddlewareRelated Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Type
bug_fix
Description
X-RateLimit-Remainingheader returned incorrect values for looped requests when the key was created from a policy.Changes walkthrough
middleware_test.go
Refactor Test Setup for Quota Middlewaregateway/middleware_test.go
createSessionWithQuotafunction as it was replaced with a morestreamlined session creation in tests.
TestQuotaNotAppliedWithURLRewriteto use the new sessioncreation method.
reverse_proxy_test.go
Extend Tests for Quota Response Headersgateway/reverse_proxy_test.go
keys from policies with per API limits, and keys from policies with
global limits.
mw_auth_key.go
Skip Auth Key Check for Looped Requestsgateway/mw_auth_key.go
and session limits are not to be checked.