Ekko Proxy WireMock Editor

The Ekko Proxy WireMock Editor lets you manage wiremocks for the proxy instances. The wiremock configuration files created by the editor are not just available to the proxy instances but can also be used in WireMock based unit tests.

Managing WireMocks

The Mock Editor is accessed from the navigation pane and lists any virtual mocks that are available to the proxy instances:

ekkoproxy wiremock management screen

Available WireMocks will appear in the table as shown above and are stored in a mocks folder (relative to the application).

Fields and functions

The fields and functions of this part of the WireMock management view are as follows:

Field Description
Search The search field can be used to search the table showing the available mocks. Pressing the Enter key or clicking the search button will initiate the search and filter the table showing only matches. The table header will show if it's filtered or not by displaying the filtered icon:
Link status A green link means the Ekko Proxy client is connected to the Ekko Proxy Server.
A red link means the Ekko Proxy client has been disconnected from the Ekko Proxy Server.
Import/Export mocks Click to select import / export option from menu:

: Import Mocks...
Shows import mocks dialog where Ekko Proxy mock files (*.json or a zip file containing one or more of the same in a mocks folder) can be dragged & dropped for import. Alternatively a mocks folder can be selected for import.

: Export Mocks
Exports any Ekko Proxy mock files (located in /mocks/*.json) to your browser downloads directory as a zip file.
Compare The 'Compare' button provides the option to compare two mock files in the Compare dialog.

Note this button is only enabled when exactly two mocks are selected.
Open The 'Open' button opens a mock file in a new browser tab / window.

Note depending on browser settings then you may need to enable pop-ups for the Ekko Proxy client as otherwise the action may be blocked by the browser.
Delete Deletes the selected mock file(s) from disk.

Note this cannot be undone!

Mocks table

The mocks table contain the following columns:

Field Description
Name / Id The name or id of the wiremock. The unique id is shown if the mock has no name.
Scenario The scenario name of the wiremock if any.
Method The HTTP request method of the wiremock e.g. GET, POST etc.
Matcher The matcher type used to match the url.
Url The request url for the wiremock.
Status The HTTP response status of the wiremock e.g. 200
Filename The filename of the wiremock json file.

Note multiple messages can be selected by clicking the check box or by holding down the Ctrl key while clicking on a mock row.

Mock details

Mock details of a mock (either selected from the mocks table or directly entered) are displayed in the mock details section as shown below.

ekkoproxy WireMock details section

The fields on the mock details section are described below:

Field Description
Mock Name The name of the wiremock.
Priority The priority of the wiremock from 1 to 10 with 1 being highest and 10 lowest priority. Defaults to 5.

Note if a wiremock has a priority of 10 then in proxy playback mode the mock will only be considered if there is no matching recording to serve instead. Mocks with higher priority than 10 (i.e. 1 to 9) will always be considered before any proxy recordings.
Global If checked the wiremock is available to all proxy instances. If unchecked then the Proxy Port field needs to be specified making the wiremock available to the proxy instance running on that port only.
Proxy Port The proxy listening port [1 - 65535] that the wiremock should be available to. Can only be filled if the Global field is unchecked.
Scenario Name The scenario name of the wiremock if any.
Required Scenario State The required scenario state of the wiremock if any.

Note the starting state for a scenario should be 'Started'.
New Scenario State The new scenario state to set if any.

Request details

The request details section shows the request matching details of a mock:

ekkoproxy WireMock request details

The fields and functions of this part of the mock management view are:

Field Description
Method The HTTP method that a request needs to match for this mock.
Url Matcher The url matcher type for matching this mock. The matching types are:
  • equalTo - equality matching on the url path and query string.
  • matching - regular expression matching on the url path and query string.
  • pathEqualTo - equality matching on the url path only. You should use this option if you are also using any query string parameter matchers.
  • pathMatching - regular expression matching on the url path only.
  • anyUrl - matching for any url. When this is selected then no url value can be specified as the mock will match on any.
Url Value The request url / pattern value to match.
HEADERS The headers tab allows for matching on one or more request header values.

Name - the name of the header to look for.
Matching - the type of match to try and match the value with:
  • contains - matches if the a portion of the header equals the value.
  • doesNotMatch - does a negative match i.e. the match succeeds when the header value does not match the regular expression.
  • equalTo - deems a match if the header is equal to the value.
  • equalToIgnoreCase - matches if the header is equal to the value, ignoring case.
  • matches - will match the header against the given regular expression.
Value - the header value to match.
Action - the actions for the row: move row up, move row down, delete row.
QUERY PARAMS The query params tab allows for matching on one or more request query parameter values.

Name - the name of the query parameter to look for.
Matching - the type of match to try and match the value with. See description of match type above.
Value - the query parameter value to match.
Action - the actions for the row: move row up, move row down, delete row.
COOKIES The cookies tab allows for matching on one or more request cookie values.

Name - the name of the cookie to look for.
Matching - the type of match to try and match the value with. See description of match type above.
Value - the cookie value to match.
Action - the actions for the row: move row up, move row down, delete row.
BODY PATTERNS The body patterns tab allows for matching on one or more request body values.

Matching - the type of match to try and match the value with:
  • anything - matches any body. No value required.
  • binaryEqualTo - matches if the entire binary body equals the expected value.
  • contains - matches if the a portion of the body equals the value.
  • doesNotMatch - negative regular expression match i.e. the match succeeds when the body value does not match the regular expression.
  • equalTo - deems a match if the body is equal to the value.
  • equalToIgnoreCase - matches if the body is equal to the value, ignoring case.
  • equalToJson - matches if the body is valid JSON and is a semantic match for the value.
  • equalToXml - matches if the attribute value is valid XML and is semantically equal to the expected XML document.
  • matches - will match the body against the given regular expression.
  • matchesJsonPath - deems a match if the attribute value is valid JSON and matches the JSON Path expression supplied. A JSON body will be considered to match a path expression if the expression returns either a non-null single value (string, integer etc.), or a non-empty object or array.
  • matchesXPath - matches if the body is valid XML and matches the XPath expression supplied. An XML document will be considered to match if any elements are returned by the XPath evaluation.
Value - the body value to match.
Action - the actions for the row: move row up, move row down, delete row.
Add row Adds a new row for the currently selected tab.

You can find further details on request matching here: WireMock request matching.

Response details

The response details section shows what the response of the mock will be:

ekkoproxy mock response details

The fields and functions of this part of the mock management view are:

Field Description
Status The HTTP response status for this mock.
Status Message The HTTP response status message.
HEADERS The headers tab allows for entering one or more response headers.

Name - the name of the response header.
Value - the response header value.
Action - the actions for the row: move row up, move row down, delete row.
Add row Adds a new row for the response headers.
BODY The HTTP response body.
Base64 If checked the response body should be base64 encoded.
Templating If checked the response body can contain Handlebars template code e.g. {{request.path.[0]}}.
UPDATE MOCK The Update Mock button will be available if a mock is selected in the mocks table allowing for the mock details to tbe edited and saved.

Note when updating a mock the change will not affect running proxies until these are stopped and started again.
ADD NEW MOCK The Add New Mock button will create a new mock from the mock details.

Note when adding a mock the new mock will not be available to running proxies until these are stopped and started again.

For further information on WireMock please refer to the WireMock documentation.

JDBC mocking

JDBC ResultSet objects can be mocked with JSON responses by adding a mock for the particular JDBC request URL / command path. The command path is comprised of the JDBC object name followed by the method called on it e.g. /PreparedStatement/executeQuery. To setup a mock for this command path the proxy's mock path needs to be prefixed to it e.g. /sqlrequest/PreparedStatement/executeQuery assuming the mock path was /sqlrequest when you created the proxy. The JDBC commands are treated as HTTP POST requests with the SQL query as the request body and any SQL parameters as headers. The headers will have the SQL parameter index as key and the parameter value as the header value. This means you can setup mocks with different Body Patterns and/or Header matchers to respond with different results depending on the SQL query itself. The below screenshot shows a mock for the same.

ekkoproxy WireMock JDBC example

ResultSet schema

To mock a ResultSet response you have to provide the response in JSON format following the below schema.

{
    "type": "object",
    "title": "The JDBC resultset schema",
    "description": "Contains the column metadata along with the actual row data.",
    "required": [
        "cols",
        "rows"
    ],
    "properties": {
        "cols": {
            "type": "array",
            "description": "The cols property contains the JDBC ResultSetMetaData information.",
            "items": {
                "type": "object",
                "description": "Contains the column metadata items.",
                "required": [
                    "catalogName",
                    "className",
                    "displaySize",
                    "name",
                    "precision",
                    "scale",
                    "schemaName",
                    "tableName",
                    "type",
                    "typeName"
                ],
                "properties": {
                    "catalogName": {
                        "type": "string",
                        "description": "The designated column's table's catalog name."
                    },
                    "className": {
                        "type": "string",
                        "description": "The fully-qualified name of the Java class whose instances are manufactured if the
                                        method ResultSet.getObject is called to retrieve a value from the column."
                    },
                    "displaySize": {
                        "type": "integer",
                        "description": "The designated column's normal maximum width in characters."
                    },
                    "name": {
                        "type": "string",
                        "description": "The designated column's name."
                    },
                    "precision": {
                        "type": "integer",
                        "description": "The designated column's specified column size."
                    },
                    "scale": {
                        "type": "integer",
                        "description": "The designated column's number of digits to right of the decimal point."
                    },
                    "schemaName": {
                        "type": "string",
                        "description": "The designated column's table's schema."
                    },
                    "tableName": {
                        "type": "string",
                        "description": "The designated column's table name."
                    },
                    "type": {
                        "type": "integer",
                        "description": "The designated column's SQL type."
                    },
                    "typeName": {
                        "type": "string",
                        "description": "The designated column's database-specific type name."
                    }
                }
            }
        },
        "rows": {
            "type": "array",
            "description": "The actual row data as per columns described in the cols property.",
            "items": {}
        }
    }
}

ResultSet example

The below shows a ResultSet JSON example response in full.

{
  "cols": [
    {
      "catalogName": "",
      "className": "java.lang.String",
      "displaySize": 15,
      "name": "GROUP_CODE",
      "precision": 15,
      "scale": 0,
      "schemaName": "",
      "tableName": "",
      "type": 12,
      "typeName": "VARCHAR2"
    },
    {
      "catalogName": "",
      "className": "java.lang.String",
      "displaySize": 50,
      "name": "GROUP_CODE_DESCRIPTION",
      "precision": 50,
      "scale": 0,
      "schemaName": "",
      "tableName": "",
      "type": 12,
      "typeName": "VARCHAR2"
    },
    {
      "catalogName": "",
      "className": "java.math.BigDecimal",
      "displaySize": 22,
      "name": "LOOKUP_ID",
      "precision": 10,
      "scale": 0,
      "schemaName": "",
      "tableName": "",
      "type": 2,
      "typeName": "NUMBER"
    },
    {
      "catalogName": "",
      "className": "java.math.BigDecimal",
      "displaySize": 22,
      "name": "LOOKUP_TYPE",
      "precision": 6,
      "scale": 0,
      "schemaName": "",
      "tableName": "",
      "type": 2,
      "typeName": "NUMBER"
    },
    {
      "catalogName": "",
      "className": "java.lang.String",
      "displaySize": 50,
      "name": "LOOKUP_VALUE",
      "precision": 50,
      "scale": 0,
      "schemaName": "",
      "tableName": "",
      "type": 12,
      "typeName": "VARCHAR2"
    }
  ],
  "rows": [
    [
      "FOO_BAR",
      "foo bar desc",
      1401,
      19203,
      "foo bar value"
    ],
    [
      "BAR_FOO",
      "bar foo desc",
      1395,
      null,
      "BAR_FOO_VALUE"
    ],
    [
      "HUBBA",
      "Hubba bubba",
      98372,
      null,
      "HUBBA_BUBBA Value"
    ],
    [
      "Ekko Proxy",
      "Service virtualization",
      59071,
      199,
      "EKKO"
    ],
    [
      "Tools",
      "Ekko tools",
      75987,
      null,
      "The best"
    ]
  ]
}
< Go Back