Playing make-believe using proxy server

Playing make-believe using proxy server

Guide to using proxy server (mitmproxy) to get the response you want

Originally published at www.plightofbyte.com on March 13, 2018.

Say, you are developing a feature in an E-commerce web/mobile app. You have to show “Item is out of stock” banner on “Cart” page when an item is out of stock.

You hit an endpoint /cart and this endpoint returns you something like this.

[
  {
    "name": "SomeShoes",
    "soldOut": false,
    "price": "$50",
    "quantity": 1
  }
]

You get soldOut as true when the item is sold out. To ease out development you’d need to simulate this behaviour.

Some ways to do so could be:

  1. You add an item to cart and then login as another user to buy all the available stock. This’d simulate out of stock in the first user.
  2. You add an item to cart and then modify data or change code in backend API to make sure that item is sold out.

Both of the above approaches would work but both might require a lot of work. If those APIs are external, then you’d have next to zero control. First approach might be possible but the second approach is impossible.


What if you could hack your way and change the value of soldOut to true without any of the above methods.

Enter proxy server

A proxy server that lets you see the response from the server and modify it even before it comes to the front-end app. You can intercept the /cart API call and modify the value of soldOut to true in response.

Imagine how much time you’d save. All you wanted was to check how your sold out banner looks like when it appears, if it even does.

No one wants to change the world to make sure they get a true instead of a false.


There are many proxy servers out there that’ll let you do this, one such is mitmproxy.

mitmproxy is a free and open source tool for Windows, Linux and Mac.

As there are commands and steps about using mitmproxy I'd like to refer you to the original source for better highlighting. Click here to jump you to the next section but in the original article. Don't worry, I won't make you read all of it again.

https://www.plightofbyte.com/tools/2018/03/13/make-believe-using-proxy#installation

Feel free to leave a comment below. If you enjoyed this article, please share to help others find it.

To view or add a comment, sign in

More articles by Sumit Gupta

  • Our journey to Micro Frontend

    My team's journey explaining why, how, the problems we faced and solutions while implementing micro-frontend Originally…

    1 Comment
  • What if we do daily scrum/stand up over Slack?

    Let’s start saving time. Avoid this big & time-consuming ceremony.

  • What if we do exhaustive automation testing?

    Will the benefit of covering every possible case using automation tests justify the cost of maintaining such test…

  • Is Google the new Apple?

    With the launch of numerous devices, Google is trying to beat Apple. Is “Made by Google” making Google more like Apple?…

  • Genymotion vs Android Emulator

    Has the Android emulator improved enough to take on Genymotion Originally published at www.plightofbyte.

    3 Comments

Explore content categories