Kong Service Virtualization

Third Party

Mock request and response pairs

Use the Kong Service Virtualization plugin to mock two request-response pairs.
Trigger each mock by including the test name in the X-VirtualRequest header, for example:

X-VirtualRequest: TestCase1 or X-VirtualRequest: TestCase2.

Prerequisites

  • The Kong Service Virtualization plugin is installed.

Set up the plugin

Add this section to your declarative configuration file:

_format_version: "3.0"
plugins:
  - name: kong-service-virtualization
    config:
      virtual_tests:
      - name: TestCase1
        requestHttpMethod: POST
        requestHash: '0296217561490155228da9c17fc555cf9db82d159732f3206638c25f04a285c4'
        responseHttpStatus: '200'
        responseContentType: application/json
        response: eyJtZXNzYWdlIjogIkEgQmlnIFN1Y2Nlc3MhIn0=
      - name: TestCase2
        requestHttpMethod: GET
        requestHash: e2c319e4ef41706e2c0c1b266c62cad607a014c59597ba662bef6d10a0b64a32
        responseHttpStatus: '200'
        responseContentType: application/json
        response: eyJtZXNzYWdlIjogIkFub3RoZXIgU3VjY2VzcyEifQ==
Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!