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.0: [TT-13507] Fix for custom domains with subs…
…tring listen path (#6705) (#6724) ### **User description** [TT-13507] Fix for custom domains with substring listen path (#6705) ### **User description** Actual fix for domain matching edge case related to substring listen paths. Fixed the sorting function for the listen paths and added some unit tests. Extra: httpbin service not working on macos with apple silicon; now it does <!-- 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, Configuration changes ___ ### **Description** - Fixed the domain sorting logic in the API loader by changing the comparison from domain length to lexicographical order to ensure correct domain matching. - Updated the Docker configuration for the httpbin service to specify the platform as `linux/amd64`, addressing compatibility issues on macOS with Apple Silicon. ___ ### **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>api_loader.go</strong><dd><code>Fix domain sorting logic in API loader</code> </dd></summary> <hr> gateway/api_loader.go <li>Modified sorting logic for API specs by domain.<br> <li> Changed comparison from domain length to lexicographical order.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6705/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+1/-1</a> </td> </tr> </table></td></tr><tr><td><strong>Configuration changes</strong></td><td><table> <tr> <td> <details> <summary><strong>httpbin.yml</strong><dd><code>Specify platform for httpbin service in Docker configuration</code></dd></summary> <hr> docker/services/httpbin.yml - Added platform specification for httpbin service. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6705/files#diff-1a1b1d8bf4798076a41ca5f3bba0d465dc387e58b6593adbb28a4d5fe60eb810">+1/-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 [TT-13507]: https://tyktech.atlassian.net/browse/TT-13507?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ ### **PR Type** Bug fix, Configuration changes ___ ### **Description** - Refactored the domain sorting logic in the API loader by introducing a new function `sortSpecsByListenPath`. The sorting now prioritizes listen path length over domain length and ensures empty domains are sorted to the end. - Updated the Docker configuration for the httpbin service to specify the platform as `linux/amd64`, addressing compatibility issues on macOS with Apple Silicon. ___ ### **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>api_loader.go</strong><dd><code>Refactor domain sorting logic in API loader</code> </dd></summary> <hr> gateway/api_loader.go <li>Introduced a new function <code>sortSpecsByListenPath</code> to handle sorting.<br> <li> Changed sorting logic to prioritize listen path length over domain <br>length.<br> <li> Ensured empty domains are sorted to the end.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6724/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+15/-8</a> </td> </tr> </table></td></tr><tr><td><strong>Configuration changes</strong></td><td><table> <tr> <td> <details> <summary><strong>httpbin.yml</strong><dd><code>Specify platform for httpbin service in Docker configuration</code></dd></summary> <hr> docker/services/httpbin.yml <li>Added platform specification <code>linux/amd64</code> for the httpbin service.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6724/files#diff-1a1b1d8bf4798076a41ca5f3bba0d465dc387e58b6593adbb28a4d5fe60eb810">+1/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Additional files (token-limit)</strong></td><td><table> <tr> <td> <details> <summary><strong>api_loader_test.go</strong><dd><code>...</code> </dd></summary> <hr> gateway/api_loader_test.go ... </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6724/files#diff-f696545a659f4d96421b253edef4bcc8da0e7f52120b8f8866d32cbbb7cc1afc">+8888/-1</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]> (cherry picked from commit bbd01ec)
- Loading branch information