apideck-libraries / portman

Port OpenAPI Specs to Postman Collections, inject test suite and run via Newman 👨🏽‍🚀
http://getportman.com/
Apache License 2.0
634 stars 60 forks source link

Fuzzing - Variation Requests for a range of request examples #191

Open thim81 opened 2 years ago

thim81 commented 2 years ago

Currently Portman generates a variation where the 1 example is used as request body in the generated request.

In case there are multiple examples, Portman could generate a variation per example:

  /mobile/v1/messages/push/send:
    post:
      operationId: post-push-send
      x-include: true
      x-release: live
      summary: Send push messages
      description: Send push messages in bulk to a range of devices.
      parameters:
        - $ref: '#/components/parameters/X-OAuth2'
        - $ref: '#/components/parameters/application-json'
      requestBody:
        content:
          application/json:
            schema:
              description: The payload for sending a push messages in bulk.
              type: array
              items:
                $ref: '#/components/schemas/SendPushBulkModel'
            examples:
              sample-send-push-apple:
                $ref: '#/components/examples/sample-send-push-apple'
              sample-send-push-google:
                $ref: '#/components/examples/sample-send-push-google'
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendPushBulkResponse'
      tags:
        - Bulk sending
BenjaminDC commented 1 year ago

@thim81 that would be a great for customers who use generated postman collection from the spec 🙏

thim81 commented 1 year ago

hi @BenjaminDC

I'm curious about what you interpret this feature and what would you expect as a result? Would you mind sharing your use-case/experience.

BenjaminDC commented 1 year ago

Basically, what I expect is the ability to specify an example reference in the variation Tests and then having one postman request per variation. if the example reference is not specified, then we could fallback to the first one.

proposal :

{
      "openApiOperationIds": [
        "post-push-send"
      ],
      "exampleReference": "#/components/examples/sample-send-push-google", <---
      "overwriteRequestBody": [
        {
          "key": "[0].content.expiration",
          "value": "{{expiration_date_future}}",
          "overwrite": true
        },
        {
          "key": "[0].context.profile",
          "value": "automation_profile",
          "overwrite": true
        },
        {
          "key": "[0].reference",
          "value": "newman{{$guid}}",
          "overwrite": true
        }
      ]
    }
thim81 commented 1 year ago

@BenjaminDC This is a good proposal, we might tweak it a bit with regards to the setting name.

We are working on adding some support for overwriting "form-data" & "x-www-form-urlencoded" request bodies. We will try to find some time after that to work on this.