Skip to content

Commit d8608ea

Browse files
bugeredsonmichaque
andauthored
Merging to release-5.8: [TT-7306] Revert allow list to migrated mock response (#6946) (#6948)
### **User description** [TT-7306] Revert allow list to migrated mock response (#6946) ### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-7306" title="TT-7306" target="_blank">TT-7306</a></summary> <br /> <table> <tr> <th>Summary</th> <td>[OAS:migration] Migrate Mock Response from Classic API Definition to OAS API Definition</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td><a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20QA_Fail%20ORDER%20BY%20created%20DESC" title="QA_Fail">QA_Fail</a></td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- <!-- Provide a general summary of your changes in the Title above --> ## Description <!-- Describe your changes in detail --> This PR makes sure that `allow_list` is not removed from migrated mock responses ## 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. --> https://tyktech.atlassian.net/browse/TT-7306 ## 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** - Enhancement - Tests ___ ### **Description** - Remove resetting of allow list in OAS operations. - Update fixture tests with structured allow and block settings. - Add new test cases for block list and classic mock response. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>operation.go</strong><dd><code>Remove nil-reset of allow in operation config.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> apidef/oas/operation.go <li>Removed resetting allow property to nil.<br> <li> Preserve allow configuration for mock responses. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6946/files#diff-6d92d2d5b09a5fa7129609bb7cd0d383d015250ec07062b6a93a83257be51fb5">+0/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>mock_response.yml</strong><dd><code>Update mock response fixtures allow/block configuration.</code>&nbsp; </dd></summary> <hr> apidef/oas/testdata/fixtures/mock_response.yml <li>Replace allow: <nil> with explicit allow block.<br> <li> Add new block list test and update response settings.<br> <li> Enable allow list with enabled flag in fixtures. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6946/files#diff-c7c72a9398d68abedf9238cc2a9606521069e13034f921e7a979d859e0559c8d">+96/-4</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> [TT-7306]: https://tyktech.atlassian.net/browse/TT-7306?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ ### **PR Type** - Enhancement - Tests ___ ### **Description** - Removed resetting of `allow` in operation configuration. - Updated fixtures with explicit `allow` and `block` settings. - Added new test cases for classic mock responses. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>operation.go</strong><dd><code>Remove resetting allow field in operation code</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> apidef/oas/operation.go <li>Removed <code>tykOperation.Allow = nil</code> line.<br> <li> Preserves <code>allow</code> configuration for mock responses. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6948/files#diff-6d92d2d5b09a5fa7129609bb7cd0d383d015250ec07062b6a93a83257be51fb5">+0/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>mock_response.yml</strong><dd><code>Update mock response fixtures allow/block settings</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> apidef/oas/testdata/fixtures/mock_response.yml <li>Replaced <code><nil></code> allow with explicit settings.<br> <li> Added <code>block</code> configuration for test GET operations.<br> <li> Introduced new test cases for classic mock responses. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6948/files#diff-c7c72a9398d68abedf9238cc2a9606521069e13034f921e7a979d859e0559c8d">+96/-4</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> Co-authored-by: Edson Michaque <[email protected]>
1 parent 0ec9d12 commit d8608ea

File tree

2 files changed

+96
-6
lines changed

2 files changed

+96
-6
lines changed

apidef/oas/operation.go

-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ func (s *OAS) fillMockResponsePaths(paths openapi3.Paths, ep apidef.ExtendedPath
265265
tykOperation.MockResponse = nil
266266
tykOperation.IgnoreAuthentication = nil
267267
}
268-
269-
tykOperation.Allow = nil
270268
}
271269
}
272270

apidef/oas/testdata/fixtures/mock_response.yml

+96-4
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ tests:
164164
middleware:
165165
operations:
166166
testGET:
167-
allow: <nil>
167+
block: <nil>
168+
allow:
169+
enabled: true
168170
mockResponse:
169171
enabled: true
170172
code: 200
@@ -241,7 +243,9 @@ tests:
241243
middleware:
242244
operations:
243245
testGET:
244-
allow: <nil>
246+
block: <nil>
247+
allow:
248+
enabled: true
245249
mockResponse:
246250
enabled: true
247251
code: 200
@@ -252,7 +256,8 @@ tests:
252256
ignoreAuthentication:
253257
enabled: true
254258
testPOST:
255-
allow: <nil>
259+
allow:
260+
enabled: true
256261
mockResponse:
257262
enabled: true
258263
code: 201
@@ -301,7 +306,9 @@ tests:
301306
middleware:
302307
operations:
303308
testGET:
304-
allow: <nil>
309+
block: <nil>
310+
allow:
311+
enabled: false
305312
mockResponse:
306313
enabled: false
307314
code: 404
@@ -335,3 +342,88 @@ tests:
335342
x-tyk-api-gateway:
336343
middleware:
337344
operations: {}
345+
- desc: "block list - classic"
346+
source: "classic"
347+
input:
348+
version_data:
349+
versions:
350+
"":
351+
extended_paths:
352+
black_list:
353+
- path: "/test"
354+
method: ""
355+
ignore_case: false
356+
disabled: false
357+
method_actions:
358+
GET:
359+
action: "reply"
360+
code: 200
361+
headers:
362+
Content-Type: "application/json"
363+
data: '{"message": "success"}'
364+
output:
365+
paths:
366+
/test:
367+
get:
368+
operationId: testGET
369+
responses:
370+
"200":
371+
description: ''
372+
x-tyk-api-gateway:
373+
middleware:
374+
operations:
375+
testGET:
376+
allow: <nil>
377+
block:
378+
enabled: true
379+
mockResponse:
380+
enabled: true
381+
code: 200
382+
body: '{"message": "success"}'
383+
headers:
384+
- name: Content-Type
385+
value: application/json
386+
ignoreAuthentication:
387+
enabled: true
388+
- desc: "basic mock response - classic"
389+
source: "classic"
390+
input:
391+
version_data:
392+
versions:
393+
"":
394+
extended_paths:
395+
ignored:
396+
- path: "/test"
397+
method: ""
398+
ignore_case: false
399+
disabled: false
400+
method_actions:
401+
GET:
402+
action: "reply"
403+
code: 200
404+
headers:
405+
Content-Type: "application/json"
406+
data: '{"message": "success"}'
407+
output:
408+
paths:
409+
/test:
410+
get:
411+
operationId: testGET
412+
responses:
413+
"200":
414+
description: ''
415+
x-tyk-api-gateway:
416+
middleware:
417+
operations:
418+
testGET:
419+
allow: <nil>
420+
block: <nil>
421+
mockResponse:
422+
enabled: true
423+
code: 200
424+
body: '{"message": "success"}'
425+
headers:
426+
- name: Content-Type
427+
value: application/json
428+
ignoreAuthentication:
429+
enabled: true

0 commit comments

Comments
 (0)