Proxy mocks allow for selective forwarding of the original requests to other services (for instance, real ones). Use proxy mocks in conjunction with other types of mocks or response delay feature within the single workspace to simulate the behaviors that are impossible or difficult to generate on-demand with real services like long response times, specific error codes, malformed or incorrect responses, connection errors.
Also, it's possible to configure proxy mocks to:
- add (or override) original request headers before forwarding requests to the destination service. This feature may be
useful, for instance, if the target service requires Basic authentication or its behavior depends on some specific HTTP header values.
- add HTTP headers to the response returned by destination service just before it's forwarded to request originator.
- alter the path of the request before forwarding the request to the destination service. For instance, if you specify
the Target URL value of the proxy mock to
https://example.com/some_path_prefix and the original request's path is
some_path, the request will be forwarded to
The following diagram presents how proxy mocks work:
To create a proxy mock, select Proxy Mock in Create Mock view:
- Enter Target URL value. Usually, it's only hostname prepended by
https://scheme since SmartMock.io proxy logic rewrites original request path.
- (Optional) Enter the total proxy request timeout. Its maximum value is 30 seconds.
- If the destination service needs additional headers, add them by clicking Add proxy request headers and entering header name and value
- If the mock consumer needs additional headers, add them by clicking Add Response Header and entering the header name and value
- Click Save