-
Notifications
You must be signed in to change notification settings - Fork 16
Mockpy architecture
At a high level, mockpy consists of the following classes:
-
MappingItemsManager
is initialised with a directory of YAML configuration files. It uses these YAML files to create a list ofMappingItem
. -
MappingItem
is the class representation of a one YAML configuration file. After parsing a config file, it creates aMappingRequest
and aMappingResponse
instances. -
MappingRequest
represents an http request. It has method to match the url, header and body of the received request. -
MappingResponse
represents an http response. It has methods to construct an http response with a status, headers and a body.
Mockpy has two modes of operation, standalone, and mitm proxy.
When mockpy is run in the standalone mode, it creates a local server using cherrypy web framework. Under this mode of operation, the client application needs to point to this locally hosted mock server (http://127.0.0.1:9090 by default). The http requests received by this mock server are matched in the same manner described in the previous section.
mockpy
proxy mode of operation creates a proxy server at a port 9090
(configurable). It then alter the Mac OSX proxy settings to forward the HTTP/HTTPS requests to this proxy server. mockpy
proxy server will intercept all of the http requests; If the request matches one of the configuration files (read the previous section), it will be handled by the proxy server to return a mock response based on the config file. If it does not match, then the http request will be forwarded by the proxy to the original destination.