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.8: [TT-7306] Revert allow list to migrated mock response (#6946) #6948

Conversation

buger
Copy link
Member

@buger buger commented Mar 13, 2025

User description

TT-7306 Revert allow list to migrated mock response (#6946)

User description

TT-7306
Summary [OAS:migration] Migrate Mock Response from Classic API Definition to OAS API Definition
Type Bug Bug
Status In Dev
Points N/A
Labels QA_Fail

Description

This PR makes sure that allow_list is not removed from migrated mock
responses

Related Issue

https://tyktech.atlassian.net/browse/TT-7306

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

  • 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

  • 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 📝

Relevant files
Enhancement
operation.go
Remove nil-reset of allow in operation config.                     

apidef/oas/operation.go

  • Removed resetting allow property to nil.
  • Preserve allow configuration for mock responses.
  • +0/-2     
    Tests
    mock_response.yml
    Update mock response fixtures allow/block configuration. 

    apidef/oas/testdata/fixtures/mock_response.yml

  • Replace allow: with explicit allow block.
  • Add new block list test and update response settings.
  • Enable allow list with enabled flag in fixtures.
  • +96/-4   

    Need help?
  • Type /help how to
  • ... in the comments thread for any questions about PR-Agent
    usage.

  • Check out the documentation
    for more information.

  • 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 📝

    Relevant files
    Enhancement
    operation.go
    Remove resetting allow field in operation code                     

    apidef/oas/operation.go

  • Removed tykOperation.Allow = nil line.
  • Preserves allow configuration for mock responses.
  • +0/-2     
    Tests
    mock_response.yml
    Update mock response fixtures allow/block settings             

    apidef/oas/testdata/fixtures/mock_response.yml

  • Replaced allow with explicit settings.
  • Added block configuration for test GET operations.
  • Introduced new test cases for classic mock responses.
  • +96/-4   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • ### **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>
    
    (cherry picked from commit dad0e98)
    Copy link
    Contributor

    API Changes

    no api changes detected

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    6946 - Partially compliant

    Compliant requirements:

    • Allow list is preserved in operation configuration.
    • Fixture tests now have explicit allow settings and include new block list cases.

    Non-compliant requirements:

    []

    Requires further human verification:

    • Verify that the legacy (classic) configuration using allow: is handled as expected.
    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Config Consistency

    Review the consistency in the new explicit allow and block settings across different test cases to ensure they align with expected behavior for both migrated and classic responses.

    - desc: "block list - classic"
      source: "classic"
      input:
        version_data:
          versions:
            "":
              extended_paths:
                black_list:
                  - path: "/test"
                    method: ""
                    ignore_case: false
                    disabled: false
                    method_actions:
                      GET:
                        action: "reply"
                        code: 200
                        headers:
                          Content-Type: "application/json"
                        data: '{"message": "success"}'
      output:
        paths:
          /test:
            get:
              operationId: testGET
              responses:
                "200":
                  description: ''
        x-tyk-api-gateway:
          middleware:
            operations:
              testGET:
                allow: <nil>
                block:
                  enabled: true
                mockResponse:
                  enabled: true
                  code: 200
                  body: '{"message": "success"}'
                  headers:
                    - name: Content-Type
                      value: application/json
                ignoreAuthentication:
                  enabled: true
    - desc: "basic mock response - classic"
      source: "classic"
      input:
        version_data:
          versions:
            "":
              extended_paths:
                ignored:
                  - path: "/test"
                    method: ""
                    ignore_case: false
                    disabled: false
                    method_actions:
                      GET:
                        action: "reply"
                        code: 200
                        headers:
                          Content-Type: "application/json"
                        data: '{"message": "success"}'
      output:
        paths:
          /test:
            get:
              operationId: testGET
              responses:
                "200":
                  description: ''
        x-tyk-api-gateway:
          middleware:
            operations:
              testGET:
                allow: <nil>
                block: <nil>
                mockResponse:
                  enabled: true
                  code: 200
                  body: '{"message": "success"}'
                  headers:
                    - name: Content-Type
                      value: application/json
                ignoreAuthentication:
                  enabled: true

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Unify configuration booleans

    Verify that the differing boolean and nil configurations for allow and block in
    similar test cases are intentional to avoid unexpected test behaviors.

    apidef/oas/testdata/fixtures/mock_response.yml [376-420]

     ... 
    -# In "block list - classic":
    -        allow: <nil>
    +# Unify test case configuration if consistent behavior is intended:
    +        allow:
    +          enabled: true
             block:
    -          enabled: true
    +          enabled: false
     ...
    -# In "basic mock response - classic":
    -        allow: <nil>
    -        block: <nil>
    Suggestion importance[1-10]: 3

    __

    Why: The suggestion calls for verifying and potentially unifying the differing configurations between similar test cases, but it is more a prompt for review than a concrete actionable change, resulting in only a modest potential impact.

    Low

    @edsonmichaque edsonmichaque merged commit d8608ea into release-5.8 Mar 13, 2025
    35 of 37 checks passed
    @edsonmichaque edsonmichaque deleted the merge/release-5.8/dad0e9805ef5ff7aa1f19f3357e7c7766693b9a1 branch March 13, 2025 11:42
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants