YAML config file

The name and location of the config file is predefined:

  • File name: .grpc.mock.qa.yaml
  • Location: the root of your repository

Example config:

Examples

There is a dedicated repository that contains a collection of examples, please check it out:

File structure

# Please note:
# We use YAML terms for types definitions: scalar, sequence and mapping
# - scalar: matches a string, enum, bool, int, float, date, timestamp, duration.
# - sequence: matches an ordered list (protobuf: a repeated field).
# - mapping: matches a complex type (protobuf: a message type), or a dictionary (protobuf: a map).
---
fileVersion: v1 # constant 
serverName: <string> # unique per repository
protoFile: <string> # absolute path in your github repository

channel: # optional
  credentials: # sequence, optional
  - type: basic-auth
    user: <string | encrypted-string>
    password: <string | encrypted-string>

  - type: jwt-bearer
    authority: <string | encrypted-string>
    audience: <string | encrypted-string> # optional

  - type: ip-white-list
    allowedIps: <sequence of (string | encrypted-string)>

  - type: client-certificate
    clientCertificateThumbprints: <sequence of (string | encrypted-string)> # optional
    trustedRootCertificateFiles: <sequence of (string | encrypted-string)> # optional

calls:

- method: <string> # gRPC method name
  credentials: <sequence> # same as channel.credentials
  scenario: # optional, state-full testing
    name: <string> # case-insensitive
    requiredState: <string> # all scenarios starts with a 'started' state
    newState: <string> # optional
  request: # optional
    header: # optional
      <arbitrary-key>: <scalar> # same as equalsTo: <scalar>
      <arbitrary-key>:
        equalsTo: <scalar>
        contains: <scalar>
        startsWith: <scalar>
        endsWith: <scalar>
        matchesWildcard: <string>
        matchesRegEx: <string>
        matchesJPath: <string>
        matchesJsonFile: <string>
        matchesYamlFile: <string>
    body: <mapping> # optional, for unary calls
      equalsTo: <scalar | mapping | sequence> # optional
      contains: <scalar | mapping | sequence> # optional
      startsWith: <scalar | mapping | sequence> # optional
      endsWith: <scalar | mapping | sequence> # optional
      matchesWildcard: <string> # optional
      matchesRegEx: <string> # optional
      matchesJPath: <string> # optional
      matchesJsonFile: <string> # optional
      matchesYamlFile: <string> # optional
      ...
      <any-property>: <any-value> # shortcut to equalsTo: <any-value>
      ...
      <any-property>:
        not:
          <any-operator>
      ...
      <scalar-property>:
        equalsTo: <scalar>
        equivalentTo: <sequence> # like equalsTo, but ignores casing
        lessThan: <scalar>
        lessOrEqualsTo: <scalar>
        moreThan: <scalar>
        moreOrEqualsTo: <scalar>
        contains: <scalar>
        startsWith: <scalar>
        endsWith: <scalar>
        matchesWildcard: <string>
        matchesRegEx: <string>
        matchesJPath: <string>
        matchesJsonFile: <string>
        matchesYamlFile: <string>
      ...
      <mapping-property>:
        equalsTo: <scalar | mapping>
        equivalentTo: <sequence> # like equalsTo, but ignores an order
        contains: <scalar | mapping>
        startsWith: <scalar | mapping>
        endsWith: <scalar | mapping>
        matchesWildcard: <string>
        matchesRegEx: <string>
        matchesJPath: <string>
        matchesJsonFile: <string>
        matchesYamlFile: <string>
      ...
      <sequence-property>:
        count: <scalar | any-operator> # matches a count of elements
        equalsTo: <scalar | sequence>
        equivalentTo: <sequence> # like equalsTo, but ignores an order
        contains: <scalar | sequence>
        startsWith: <scalar | sequence>
        endsWith: <scalar | sequence>
        matchesWildcard: <string>
        matchesRegEx: <string>
        matchesJPath: <string>
        matchesJsonFile: <string>
        matchesYamlFile: <string>
    ...
    stream: <sequence> # optional, for client streaming calls
      <any-sequence-property-operator>
    ...
  response: # optional
    header: # optional
      <arbitrary-key>: <scalar>
    ...
    trailer: # optional
      <arbitrary-key>: <scalar>
    ...
    body: <mapping> # optional, for unary calls
      fromJsonFile: <string> # optional
      fromYamlFile: <string> # optional
      ...
      <any-property>:
        fromJsonFile: <string>
        fromYamlFile: <string>
      ...
      <scalar-property>: <scalar>
      <mapping-property>: <mapping>
      <sequence-property>: <sequence>
    ...
    stream: <sequence> # optional, for server streaming calls
      fromJsonFile: <string> # optional
      fromYamlFile: <string> # optional
    ...
    # https://grpc.github.io/grpc/core/md_doc_statuscodes.html
    status[Code]: <OK|CANCELLED|UNKNOWN|...> # optional, default OK
    statusDetails: <string> # optional, default empty