bbyars/mountebank

View on GitHub
src/views/docs/api/contracts/imposter.ejs

Summary

Maintainability
Test Coverage
<pre id='imposter-specification'><code>{
<span id='imposter-port'><%- indent(2) %>&quot;port&quot;: 4545,</span>
<span id='imposter-protocol'><%- indent(2) %>&quot;protocol&quot;: &quot;https&quot;,</span>
<span id='imposter-name'><%- indent(2) %>&quot;name&quot;: &quot;imposter contract service&quot;,</span>
<span id='imposter-recordRequests'><%- indent(2) %>&quot;recordRequests&quot;: &quot;true&quot;,</span>
<span id='imposter-numberOfRequests' class='response'><%- indent(2) %>&quot;numberOfRequests&quot;: &quot;1&quot;,</span>
<span id='imposter-key'><%- indent(2) %>&quot;key&quot;: &quot;-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCrvse04YkxtVGagyvGJCsvv7LTfLK5uR/ZIJKDYCnuF+BqBzM4\nlko8O39vx+Lz9FfF11Xl+CN1aY37YurLYOle3dC/qslSbQDe2TJN7lcVHVssePvc\nO5IExpvNFV5LYtmyCMKJHxpnIprv/trUso5obqzzXhFVPV9SQbFH/snInwIDAQAB\nAoGARywlqLD6YO4qJiULw+4DM6N2oSwBCPRN3XYhIW59kdy1NFtNf7rQgsuJUTJ9\nu+lbYnKNd2LwltyqaS4h7Sx5KRhpFNmMpyVsBf5J2q3fbfmrsXt+emY7XhVTc1NV\nizUWYyxCoTTeMWvN/6NYpPV0lSxq7jMTFVZrWQUMqJclxpECQQDTlGwALtAX1Y8u\nGKsEHPkoq9bhHA5N9WAboQ4LQCZVC8eBf/XH//2iosYTXRNgII2JLmHmmxJHo5iN\nJPFMbnoHAkEAz81osJf+yHm7PBBJP4zEWZCV25c+iJiPDpj5UoUXEbq47qVfy1mV\nDqy2zoDynAWitU7PeHyZ8ozfyribPoR2qQJAVmvMhXKZmvKnLivzRpXTC9LMzVwZ\nV6x/Wim5w8yrG5fZIMM0kEG2xwR3pZch/+SsCzl/0aLLn6lp+VT6nr6NZwJBAMxs\nHrvymoLvNeDtiJFK0nHliXafP7YyljDfDg4+vSYE0R57c1RhSQBJqgBV29TeumSw\nJes6cFuqeBE+MAJ9XxkCQDdUdhnA8HHQRNetqK7lygUep7EcHHCB6u/0FypoLw7o\nEUVo5KSEFq93UeMr3B7DDPIz3LOrFXlm7clCh1HFZhQ=\n-----END RSA PRIVATE KEY-----&quot;,</span>
<span id='imposter-cert'><%- indent(2) %>&quot;cert&quot;: &quot;-----BEGIN CERTIFICATE-----\nMIIB6TCCAVICCQCZgxbBD0CG4zANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKU29tZS1TdGF0ZTEVMBMGA1UEChMMVGhvdWdodFdvcmtzMB4X\nDTEzMTIyOTE2NDAzN1oXDTE0MDEyODE2NDAzN1owOTELMAkGA1UEBhMCVVMxEzAR\nBgNVBAgTClNvbWUtU3RhdGUxFTATBgNVBAoTDFRob3VnaHRXb3JrczCBnzANBgkq\nhkiG9w0BAQEFAAOBjQAwgYkCgYEAq77HtOGJMbVRmoMrxiQrL7+y03yyubkf2SCS\ng2Ap7hfgagczOJZKPDt/b8fi8/RXxddV5fgjdWmN+2Lqy2DpXt3Qv6rJUm0A3tky\nTe5XFR1bLHj73DuSBMabzRVeS2LZsgjCiR8aZyKa7/7a1LKOaG6s814RVT1fUkGx\nR/7JyJ8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQCPhixeKxIy+ftrfPikwjYo1uxp\ngQ18FdVN1pbI//IIx1o8kJuX8yZzO95PsCOU0GbIRCkFMhBlqHiD9H0/W/GvWzjf\n7WFW15lL61y/kH1J0wqEgoaMrUDjHZvKVr0HrN+vSxHlNQcSNFJ2KdvZ5a9dhpGf\nXOdprCdUUXzSoJWCCg==\n-----END CERTIFICATE-----&quot;,</span>
<span id='imposter-mutualAuth'><%- indent(2) %>&quot;mutualAuth&quot;: false,</span>
<span id='imposter-defaultResponse'><%- indent(2) %>&quot;defaultResponse&quot;: {
    &quot;statusCode&quot;: 400,
    &quot;body&quot;: &quot;Bad Request&quot;,
    &quot;headers&quot;: {}
  },</span>
<span id='imposter-stubs'><%- indent(2) %>&quot;stubs&quot;: [</span>
    {
<span id='imposter-stubs-responses'><%- indent(6) %>&quot;responses&quot;: [</span>
        {
<span id='imposter-stubs-responses-is'><%- indent(10) %>&quot;is&quot;: {
            &quot;statusCode&quot;: 201,
            &quot;headers&quot;: {
              &quot;Location&quot;: &quot;http://example.com/resource&quot;
            },
            &quot;body&quot;: &quot;The time is ${TIME}&quot;,
            &quot;_mode&quot;: &quot;text&quot;
          },</span>
<span id='imposter-stubs-responses-repeat'><%- indent(10) %>&quot;repeat&quot;: 3,</span>
<span id='imposter-stubs-behaviors'><%- indent(10) %>&quot;behaviors&quot;: [</span>
<span id='imposter-stubs-behaviors-wait'><%- indent(12) %>{ &quot;wait&quot;: 500 },</span>
<span id='imposter-stubs-behaviors-decorate'><%- indent(12) %>{ &quot;decorate&quot;: &quot;config => { config.response.body = config.response.body.replace('${TIME}', 'now'); }&quot; },</span>
<span id='imposter-stubs-behaviors-shellTransform'><%- indent(12) %>{ &quot;shellTransform&quot;: &quot;transformResponse&quot; },</span>
<span id='imposter-stubs-behaviors-copy'><%- indent(12) %>{
              &quot;copy&quot;: {
                &quot;from&quot;: &quot;body&quot;,
                &quot;into&quot;: &quot;${NAME}&quot;,
                &quot;using&quot;: {
                  &quot;method&quot;: &quot;xpath&quot;,
                  &quot;selector&quot;: &quot;//test:name&quot;,
                  &quot;ns&quot;: { &quot;test&quot;: &quot;http://example.com/test&quot; }
                }
              }
            },</span>
<span id='imposter-stubs-behaviors-lookup'><%- indent(12) %>{
              &quot;lookup&quot;: {
                &quot;key&quot;: {
                  &quot;from&quot;: { &quot;headers&quot;: &quot;If-Modified-Since&quot; },
                  &quot;using&quot;: {
                    &quot;method&quot;: &quot;regex&quot;,
                    &quot;selector&quot;: &quot;(\\w+), (\\d+) (\\w+) (\\d+)&quot;,
                    &quot;options&quot;: { &quot;ignoreCase&quot;: true, &quot;multiline&quot;: true }
                  },
                  &quot;index&quot;: 2
                },
                &quot;fromDataSource&quot;: {
                  &quot;csv&quot;: {
                    &quot;path&quot;: &quot;values.csv&quot;,
                    &quot;keyColumn&quot;: &quot;month&quot;,
                    &quot;delimiter&quot;: &quot;,&quot;
                  }
                },
                &quot;into&quot;: &quot;${row}&quot;
              }
            }</span>
          ]
        },
        {
<span id='imposter-stubs-responses-proxy'><%- indent(10) %>&quot;proxy&quot;: {</span>
<span id='imposter-stubs-responses-proxy-to'><%- indent(12) %>&quot;to&quot;: &quot;https://www.somesite.com:3000&quot;,</span>
<span id='imposter-stubs-responses-proxy-mode'><%- indent(12) %>&quot;mode&quot;: &quot;proxyAlways&quot;,</span>
<span id='imposter-stubs-responses-proxy-key'><%- indent(12) %>&quot;key&quot;: &quot;-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCrvse04YkxtVGagyvGJCsvv7LTfLK5uR/ZIJKDYCnuF+BqBzM4\nlko8O39vx+Lz9FfF11Xl+CN1aY37YurLYOle3dC/qslSbQDe2TJN7lcVHVssePvc\nO5IExpvNFV5LYtmyCMKJHxpnIprv/trUso5obqzzXhFVPV9SQbFH/snInwIDAQAB\nAoGARywlqLD6YO4qJiULw+4DM6N2oSwBCPRN3XYhIW59kdy1NFtNf7rQgsuJUTJ9\nu+lbYnKNd2LwltyqaS4h7Sx5KRhpFNmMpyVsBf5J2q3fbfmrsXt+emY7XhVTc1NV\nizUWYyxCoTTeMWvN/6NYpPV0lSxq7jMTFVZrWQUMqJclxpECQQDTlGwALtAX1Y8u\nGKsEHPkoq9bhHA5N9WAboQ4LQCZVC8eBf/XH//2iosYTXRNgII2JLmHmmxJHo5iN\nJPFMbnoHAkEAz81osJf+yHm7PBBJP4zEWZCV25c+iJiPDpj5UoUXEbq47qVfy1mV\nDqy2zoDynAWitU7PeHyZ8ozfyribPoR2qQJAVmvMhXKZmvKnLivzRpXTC9LMzVwZ\nV6x/Wim5w8yrG5fZIMM0kEG2xwR3pZch/+SsCzl/0aLLn6lp+VT6nr6NZwJBAMxs\nHrvymoLvNeDtiJFK0nHliXafP7YyljDfDg4+vSYE0R57c1RhSQBJqgBV29TeumSw\nJes6cFuqeBE+MAJ9XxkCQDdUdhnA8HHQRNetqK7lygUep7EcHHCB6u/0FypoLw7o\nEUVo5KSEFq93UeMr3B7DDPIz3LOrFXlm7clCh1HFZhQ=\n-----END RSA PRIVATE KEY-----&quot;,</span>
<span id='imposter-stubs-responses-proxy-cert'><%- indent(12) %>&quot;cert&quot;: &quot;-----BEGIN CERTIFICATE-----\nMIIB6TCCAVICCQCZgxbBD0CG4zANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKU29tZS1TdGF0ZTEVMBMGA1UEChMMVGhvdWdodFdvcmtzMB4X\nDTEzMTIyOTE2NDAzN1oXDTE0MDEyODE2NDAzN1owOTELMAkGA1UEBhMCVVMxEzAR\nBgNVBAgTClNvbWUtU3RhdGUxFTATBgNVBAoTDFRob3VnaHRXb3JrczCBnzANBgkq\nhkiG9w0BAQEFAAOBjQAwgYkCgYEAq77HtOGJMbVRmoMrxiQrL7+y03yyubkf2SCS\ng2Ap7hfgagczOJZKPDt/b8fi8/RXxddV5fgjdWmN+2Lqy2DpXt3Qv6rJUm0A3tky\nTe5XFR1bLHj73DuSBMabzRVeS2LZsgjCiR8aZyKa7/7a1LKOaG6s814RVT1fUkGx\nR/7JyJ8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQCPhixeKxIy+ftrfPikwjYo1uxp\ngQ18FdVN1pbI//IIx1o8kJuX8yZzO95PsCOU0GbIRCkFMhBlqHiD9H0/W/GvWzjf\n7WFW15lL61y/kH1J0wqEgoaMrUDjHZvKVr0HrN+vSxHlNQcSNFJ2KdvZ5a9dhpGf\nXOdprCdUUXzSoJWCCg==\n-----END CERTIFICATE-----&quot;,</span>
<span id='imposter-stubs-responses-proxy-ciphers'><%- indent(12) %>&quot;ciphers&quot;: &quot;RC4-MD5&quot;,</span>
<span id='imposter-stubs-responses-proxy-secureProtocol'><%- indent(12) %>&quot;secureProtocol&quot;: &quot;TLSv1_1_method&quot;,</span>
<span id='imposter-stubs-responses-proxy-passphrase'><%- indent(12) %>&quot;passphrase&quot;: &quot;LetMeIn!&quot;,</span>
<span id='imposter-stubs-responses-proxy-addWaitBehavior'><%- indent(12) %>&quot;addWaitBehavior&quot;: &quot;true&quot;,</span>
<span id='imposter-stubs-responses-proxy-addDecorateBehavior'><%- indent(12) %>&quot;addDecorateBehavior&quot;: &quot;(request, response) => { response.body = response.body.replace('${TIME}', 'now'); }&quot;,</span>
<span id='imposter-stubs-responses-proxy-predicateGenerators'><%- indent(12) %>&quot;predicateGenerators&quot;: [
              {
                &quot;matches&quot;: {
                  &quot;path&quot;: true
                },
                &quot;caseSensitive&quot;: true,
                &quot;except&quot;: &quot;^The^&quot;,
                &quot;jsonpath&quot;: {
                  &quot;selector&quot;: &quot;$..book&quot;
                },
                &quot;xpath&quot;: {
                  &quot;selector&quot;: &quot;//book/@title&quot;,
                  &quot;ns&quot;: {
                    &quot;isbn&quot;: &quot;http://schemas.isbn.org/ns/1999/basic.dtd&quot;
                  }
                },
                &quot;inject&quot;: &quot;function (config) { return []; }&quot;,
                &quot;ignore&quot;: { &quot;query&quot;: &quot;startDate&quot; }
              }
            ],</span>
<span id='imposter-stubs-responses-proxy-injectHeaders'><%- indent(12) %>&quot;injectHeaders&quot;: {
              &quot;X-Custom-Header&quot;: &quot;Served by mountebank&quot;
            }</span>
          }
        },
        {
<span id='imposter-stubs-responses-inject'><%- indent(10) %>&quot;inject&quot;: &quot;function (config) { config.callback({ body: 'It worked!' }); }&quot;</span>
        }
      ],
<span id='imposter-stubs-predicates'><%- indent(6) %>&quot;predicates&quot;: [</span>
        {
<span id='imposter-stubs-predicates-0-equals'><%- indent(10) %>&quot;equals&quot;: {
            &quot;body&quot;: &quot;value&quot;
          },</span>
<span id='imposter-stubs-predicates-0-caseSensitive'><%- indent(10) %>&quot;caseSensitive&quot;: true,</span>
<span id='imposter-stubs-predicates-0-except'><%- indent(10) %>&quot;except&quot;: &quot;^The &quot;,</span>
<span id='imposter-stubs-predicates-0-jsonpath'><%- indent(10) %>&quot;jsonpath&quot;: {
            &quot;selector&quot;: &quot;$..book&quot;
          },</span>
<span id='imposter-stubs-predicates-0-xpath'><%- indent(10) %>&quot;xpath&quot;: {
            &quot;selector&quot;: &quot;//book/@title&quot;,
            &quot;ns&quot;: {
              &quot;isbn&quot;: &quot;http://schemas.isbn.org/ns/1999/basic.dtd&quot;
            }</span>
          }
        },
        {
<span id='imposter-stubs-predicates-1-inject'><%- indent(10) %>&quot;inject&quot;: &quot;function (config) { return config.request.body.length &lt; 100; }&quot;</span>
        }
      ],
<span id='imposter-stubs-matches' class='response'><%- indent(6) %>&quot;matches&quot;: [
        {
          &quot;timestamp&quot;: &quot;2014-01-09T02:30:31.043Z&quot;,
          &quot;request&quot;: {
            &quot;requestFrom&quot;: &quot;::ffff:127.0.0.1:60523&quot;,
            &quot;method&quot;: &quot;POST&quot;,
            &quot;path&quot;: &quot;/imposters&quot;,
            &quot;query&quot;: {},
            &quot;headers&quot;: {
              &quot;accept&quot;: &quot;text/plain&quot;,
              &quot;host&quot;: &quot;localhost:4545&quot;,
              &quot;content-type&quot;: &quot;application/xml&quot;,
              &quot;connection&quot;: &quot;keep-alive&quot;,
              &quot;transfer-encoding&quot;: &quot;chunked&quot;
            },
            &quot;body&quot;: &quot;&lt;books&gt;&lt;book title='The value' /&gt;&lt;/books&gt;&quot;
          },
          &quot;response&quot;: {
            &quot;statusCode&quot;: 201,
            &quot;headers&quot;: {
              &quot;Location&quot;: &quot;http://example.com/resource&quot;
            },
            &quot;body&quot;: &quot;The time is now&quot;,
            &quot;_mode&quot;: &quot;text&quot;
          }
        }
      ]
    }
  ],</span>
<span id='imposter-endOfRequestResolver'><%- indent(2) %>&quot;endOfRequestResolver&quot;: {
    &quot;inject&quot;: &quot;function (config) { return config.request.length &gt;= 100; }&quot;</span>
  },
<span id='imposter-requests' class='response'><%- indent(2) %>&quot;requests&quot;: [
    {
      &quot;timestamp&quot;: &quot;2014-01-09T02:30:31.043Z&quot;,
      &quot;requestFrom&quot;: &quot;::ffff:127.0.0.1:60523&quot;,
      &quot;method&quot;: &quot;POST&quot;,
      &quot;path&quot;: &quot;/imposters&quot;,
      &quot;query&quot;: {},
      &quot;headers&quot;: {
        &quot;accept&quot;: &quot;text/plain&quot;,
        &quot;host&quot;: &quot;localhost:4545&quot;,
        &quot;content-type&quot;: &quot;text/plain&quot;,
        &quot;connection&quot;: &quot;keep-alive&quot;,
        &quot;transfer-encoding&quot;: &quot;chunked&quot;
      },
      &quot;body&quot;: &quot;Just checking&quot;
    }
  ],</span>
<span id='imposter-_links' class='response'><%- indent(2) %>&quot;_links&quot;: {
    &quot;self&quot;: {
      &quot;href&quot;: &quot;http://localhost:2525/imposters/4545&quot;</span>
    }
  }
}
</code></pre>