minix

minix

别烦我,正在追查宇宙大爆炸的嫌疑犯!

linux universal http mock testing tool

The work process requires verifying the basic functionality of microservices to ensure they are functioning properly. However, due to poor software engineering design and heavy coupling of microservices, it is not possible to construct separate test scenarios. Therefore, interface-level mocking is necessary. Previously, a microservice was written to simulate the response of the counterpart microservice. However, this method was cumbersome, so the following tool was conceived.

By using iptables for NAT and intercepting and tampering with the data flow using mitmproxy, the goal of mocking services can be achieved. Currently, mocking of RESTful interfaces is supported.

Architecture#

Without naughtymonkey:

Service A (1.1.1.1) --> Service B (2.2.2.2:8888) receives requests

Service A (1.1.1.1) <-- Service B (2.2.2.2:8888) returns responses

With naughtymonkey:

Service A (1.1.1.1) --> Service B network card (iptables) --> naughtymonkey (3.3.3.3:8080) --> Service B (2.2.2.2:8888)

Service A (1.1.1.1) <-- Service B network card (iptables) <-- naughtymonkey (3.3.3.3:8080) responses can be tampered with <-- Service B (2.2.2.2:8888) returns responses

  1. Execute monkeyagent.sh on Service B to configure iptables rules and pass all data flows from Service A to naughtymonkey.
  2. Configure the intercepted URL addresses on the naughtymonkey interface. Only URLs that match will be intercepted.
  3. Configure interception and tampering tasks on the naughtymonkey interface. When a request that matches the conditions arrives, it will be returned according to the data flow specified in the task.

Dependencies#

  1. Naughtymonkey relies on MongoDB, so MongoDB needs to be deployed.
  2. Python3 is required, along with many dependent packages. Please add any missing packages as needed.

GitHub address: https://github.com/flyfire100/naughtymonkey

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.