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

Bug with matching/key replacement #672

Closed
ia-chyde opened this issue Nov 1, 2024 · 19 comments
Closed

Bug with matching/key replacement #672

ia-chyde opened this issue Nov 1, 2024 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@ia-chyde
Copy link

ia-chyde commented Nov 1, 2024

In v1.30.5 a bug was introduced with matching values. Pinning my portman version to 1.30.4 fixes the issue.
ATTN: @thim81

This is the OAS value being replaced - but in 1.30.5 it is replacing in some areas with the example, but in other areas it's replacing properly with the overridden value.
image

Example fail from html report:
image

Example of replacement setup from the portman config:
image

@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

hi @ia-chyde

We did improve some matching logic and added additional tests, so it seems to have caused some side-effects.

I'll look into it and add a test to cover this.

@thim81 thim81 self-assigned this Nov 1, 2024
@thim81 thim81 added the bug Something isn't working label Nov 1, 2024
@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

hi @ia-chyde

Could you share the OpenAPI path (only the path is sufficient)? So we can run some manual validations?

@ia-chyde
Copy link
Author

ia-chyde commented Nov 1, 2024

/workspace/portman/OASfromAPI.json (in a jenkins agent workspace)
If you want the full request url, it's above in the screenshots.

@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

hi @ia-chyde

We have a PR ready that should fix the reported issue.

The input

paths:
  /licenses/{licenseKey}/modules:
    delete:
      summary: Delete a license module
      operationId: deleteLicenseModule
      parameters:
        - $ref: '#/components/parameters/licenseKey'
        - name: modules
          in: query
          description: List of modules to delete, separated by commas
          required: true
          schema:
            type: string
            example: com.inductiveautomation.perspective,com.inductiveautomation.sqlbridge
      responses:
        '204':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found
components:
  parameters:
    licenseKey:
      name: licenseKey
      in: path
      required: true
      description: The license key of the license
      schema:
        type: string
        minLength: 8
        example: хххххххХ

with the targeting

"overwrites": [
    {
      "openApiOperation": "DELETE::/licenses/{licenseKey}/modules*",
      "overwriteRequestPathVariables": [
        {
          "key": "licenseKey",
          "value": "{{licenseKey}}"
        }
      ]
    }
  ]

results in:
image

@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

hi @ia-chyde

We just release version 1.30.6 which should handle your reported issue.
If this solves your issue, feel free to close this.

If not, please provide more info so we can reproduce it and look further for a fix.

@ia-chyde
Copy link
Author

ia-chyde commented Nov 1, 2024

Still one bug. Now there is a queryparam that's failing to replace. Seems it's not appending the query param to the URL:
image

Definition in OAS:
image

@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

How does the Portman config looks like?

@ia-chyde
Copy link
Author

ia-chyde commented Nov 1, 2024

sorry, meant to include that
image

@thim81
Copy link
Collaborator

thim81 commented Nov 1, 2024

hi @ia-chyde

This is the result, so it looks like it is working?

image

OpenAPI spec:

openapi: 3.0.3
info:
  title: 672 - License API2
  version: 1.0.0

paths:
  /licenses:
    get:
      summary: Get licenses
      description: |
        Returns a list of licenses that match the specified query. Valid query should either be origin and nativeId, or be licenseKeys.
      security:
        - GeneralRO: []
        - GeneralRW: []
      parameters:
        - in: query
          name: origin
          description: The origin of the license owner
          schema:
            $ref: '#/components/schemas/Origin'
          required: false
        - in: query
          name: nativeId
          description: The native ID of the license owner within the origin system
          schema:
            $ref: '#/components/schemas/NativeId'
          required: false
        - in: query
          name: licenseKeys
          description: Comma-separated list of one or more licenseKeys
          schema:
            type: string
            minLength: 1
          required: false
      responses:
        '200':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found

components:
  schemas:
    Origin:
      type: string
      example: "example-origin"
    NativeId:
      type: string
      example: "example-native-id"

Portman config:

{
  "globals": {
    "stripResponseExamples": true
  },
  "overwrites": [
    {
      "openApiOperation": "GET::/licenses",
      "overwriteRequestQueryParams": [
        {
          "key": "licenseKeys",
          "value": "{{licenseKey}}",
          "disable": false,
          "overwrite": true
        }
      ]
    }
  ],
  "version": 1
}

@ia-chyde
Copy link
Author

ia-chyde commented Nov 2, 2024

This is from the postman-generated collection. You can see it is not putting the path param in the request, and on the previous version, it was
image

@thim81
Copy link
Collaborator

thim81 commented Nov 3, 2024

hi @ia-chyde

I used the following:

OpenAPI

openapi: 3.0.0
info:
  title: 672 - License API2
  version: 1.0.0

paths:
  /licenses:
    get:
      summary: Get licenses
      description: |
        Returns a list of licenses that match the specified query. Valid query should either be origin and nativeId, or be licenseKeys.
      security:
        - GeneralRO: []
        - GeneralRW: []
      parameters:
        - in: query
          name: origin
          description: The origin of the license owner
          schema:
            $ref: '#/components/schemas/Origin'
          required: false
        - in: query
          name: nativeId
          description: The native ID of the license owner within the origin system
          schema:
            $ref: '#/components/schemas/NativeId'
          required: false
        - in: query
          name: licenseKeys
          description: Comma-separated list of one or more licenseKeys
          schema:
            type: string
            minLength: 1
          required: false
      responses:
        '200':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found
  /licenses/{licenseKey}:
    get:
      summary: Get a single license
      description: Returns a single license by licenseKey.
      security:
        - GeneralRO: []
        - GeneralRW: []
      parameters:
        - in: path
          name: licenseKey
          description: The key of the license to retrieve
          schema:
            type: string
            minLength: 8
            example: хххххххХ
          required: true
      responses:
        '200':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found
components:
  schemas:
    Origin:
      type: string
      example: "example-origin"
    NativeId:
      type: string
      example: "example-native-id"

With this Portman config:

{
  "globals": {
    "stripResponseExamples": true
  },
  "overwrites": [
    {
      "openApiOperation": "GET::/licenses",
      "overwriteRequestQueryParams": [
        {
          "key": "licenseKeys",
          "value": "{{licenseKey}}",
          "disable": false,
          "overwrite": true
        }
      ]
    },
    {
      "openApiOperation": "GET::/licenses/*",
      "overwriteRequestQueryParams": [
        {
          "key": "licenseKeys",
          "value": "{{licenseKey}}",
          "disable": false,
          "overwrite": true
        }
      ],
      "overwriteRequestPathVariables": [
        {
          "key": "licenseKey",
          "value": "{{licenseKey}}"
        }
      ]
    }
  ],
  "version": 1
}

Results in:

image image

What did you had in your Portman Config?

@ia-chyde
Copy link
Author

ia-chyde commented Nov 4, 2024

hi @ia-chyde

I used the following:

OpenAPI

openapi: 3.0.0
info:
  title: 672 - License API2
  version: 1.0.0

paths:
  /licenses:
    get:
      summary: Get licenses
      description: |
        Returns a list of licenses that match the specified query. Valid query should either be origin and nativeId, or be licenseKeys.
      security:
        - GeneralRO: []
        - GeneralRW: []
      parameters:
        - in: query
          name: origin
          description: The origin of the license owner
          schema:
            $ref: '#/components/schemas/Origin'
          required: false
        - in: query
          name: nativeId
          description: The native ID of the license owner within the origin system
          schema:
            $ref: '#/components/schemas/NativeId'
          required: false
        - in: query
          name: licenseKeys
          description: Comma-separated list of one or more licenseKeys
          schema:
            type: string
            minLength: 1
          required: false
      responses:
        '200':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found
  /licenses/{licenseKey}:
    get:
      summary: Get a single license
      description: Returns a single license by licenseKey.
      security:
        - GeneralRO: []
        - GeneralRW: []
      parameters:
        - in: path
          name: licenseKey
          description: The key of the license to retrieve
          schema:
            type: string
            minLength: 8
            example: хххххххХ
          required: true
      responses:
        '200':
          description: No Content - Successfully deleted the license module
        '400':
          description: Bad Request - Invalid license key or parameters
        '404':
          description: Not Found - License key not found
components:
  schemas:
    Origin:
      type: string
      example: "example-origin"
    NativeId:
      type: string
      example: "example-native-id"

With this Portman config:

{
  "globals": {
    "stripResponseExamples": true
  },
  "overwrites": [
    {
      "openApiOperation": "GET::/licenses",
      "overwriteRequestQueryParams": [
        {
          "key": "licenseKeys",
          "value": "{{licenseKey}}",
          "disable": false,
          "overwrite": true
        }
      ]
    },
    {
      "openApiOperation": "GET::/licenses/*",
      "overwriteRequestQueryParams": [
        {
          "key": "licenseKeys",
          "value": "{{licenseKey}}",
          "disable": false,
          "overwrite": true
        }
      ],
      "overwriteRequestPathVariables": [
        {
          "key": "licenseKey",
          "value": "{{licenseKey}}"
        }
      ]
    }
  ],
  "version": 1
}

Results in:

image image
What did you had in your Portman Config?

#672 (comment) from above - I see you also had one replacing for /licenses/* - I don't have this and before your changes, it was not necessary.

@thim81
Copy link
Collaborator

thim81 commented Nov 4, 2024

Did you not had a * in the openApiOperation?

image

@ia-chyde
Copy link
Author

ia-chyde commented Nov 4, 2024

that's right. only that one entry you see. Worked fine in previous version.

@thim81
Copy link
Collaborator

thim81 commented Nov 4, 2024

Hmm 🤔 that should not have worked for the endpoints "/licenses/..." since there was no * wildcard character involved in the openApiOperation.

I have a PR that will allow matching with "GET: :/licenses*" would you be OK with that?

@ia-chyde
Copy link
Author

ia-chyde commented Nov 4, 2024 via email

@thim81
Copy link
Collaborator

thim81 commented Nov 5, 2024

hi @ia-chyde

We just release version v1.30.7, could you give a try?
You will have to update "openApiOperation": "GET::/licenses*" by adding an ending *

@ia-chyde
Copy link
Author

ia-chyde commented Nov 6, 2024 via email

@ia-chyde ia-chyde closed this as completed Nov 6, 2024
@thim81
Copy link
Collaborator

thim81 commented Nov 6, 2024

@ia-chyde Thanks for the patience and the assistance during the validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants