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

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 field in OAS operations.

    • Updated fixture YAML to use explicit allow settings and add block configuration.

    • Added new test cases for both block list and basic mock response in classic endpoints.


    Changes walkthrough 📝

    Relevant files
    Enhancement
    operation.go`
    Remove nil reset for allow configuration.                               

    apidef/oas/operation.go

  • Removed line that resets allow to nil.
  • Ensured preservation of allow configuration.
  • Tests
    mock_response.yml`
    Update fixtures with explicit allow and block settings.   

    apidef/oas/testdata/fixtures/mock_response.yml

  • Replaced allow: with explicit structure.
  • Introduced block: where applicable.
  • Added new fixture entries for block list and basic mock response.
  • Additional files
    operation.go +0/-2     
    mock_response.yml +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:

    • Preserve the allow_list property.
    • Update fixture tests with explicit allow and block configurations.

    Non-compliant requirements:

    None

    Requires further human verification:

    None

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Configuration Consistency

    Ensure that the new explicit configurations for allow and block fields are consistent across all test cases and align with system expectations, especially the use of in some cases.

    block: <nil>
    allow:
      enabled: true
    mockResponse:
      enabled: true
      code: 200
      body: '{"message": "success"}'

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Standardize config types

    Standardize the configuration types by using consistent mapping objects for both
    block and allow instead of mixing and object types.

    apidef/oas/testdata/fixtures/mock_response.yml [167-169]

    -block: <nil>
    +block:
    +  enabled: true
     allow:
       enabled: true
    Suggestion importance[1-10]: 5

    __

    Why: The suggestion aims to improve consistency by converting a raw "" value for "block" into a mapping object mirroring the "allow" configuration. While this change standardizes the config types, its impact is moderate and may not be strictly required.

    Low

    @edsonmichaque edsonmichaque merged commit 3e005d2 into release-5.8.0 Mar 13, 2025
    25 of 37 checks passed
    @edsonmichaque edsonmichaque deleted the merge/release-5.8.0/dad0e9805ef5ff7aa1f19f3357e7c7766693b9a1 branch March 13, 2025 11:50
    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