MockSmart is a simple to use, Ubuntu based appliance that enables you to mock REST based API responses. In fact, you can quickly mock any REST based api and consume it from any of your favourite automation products or development environments. As long as it can make REST requests and handle REST responses, MockSmart is for you.

 

Why?

I spend a lot of time creating automated workflows for clients. A common occurence is that the API for one of their systems isn’t available to me to test against. This is usually because they don’t have a replica of their live environment for testing and development purposes. At other times I find myself having to develop to tight timescales where the endpoint isn’t yet even available! Either way, I have some automation tooling to use and an API guide, swagger spec etc, but no real endpoint. So I decided I wanted a way to mock REST based webservices. There are quite a few mock based solutions out there, but I didn’t like the way they worked or the investment in configuration. To me, they were really good, but for my use cases they just couldn’t be dynamic enough.

 

Approach

I decided that the only way I would get what I wanted was to create my own Mock server solution. And it had to be smart. In fact, it had to be so smart, that it would allow me to ‘mock the smarts’ – hence the name, MockSmart !

I wanted to ensure that the solution was very dynamic. The majority of mocking solutions have you build out response files within the filesystem. Not – very – dynamic ! Instead I opted for a very different approach. I decided to pass the response I wanted to receive back from my mocked system as an entry in the requests header.  [ editor: I’ll let that sink in for a minute ]

Check out the diagram below. Along with the response you want to receive (the response body content for a GET request for example) you specify the HTTP status code (for example 200, 403, 404 etc). Optionally, you can also specify a delay (in seconds) that MockSmart will wait before returning a response (enabling you mock scenerios with timeouts for example).

[ editor: Make sure your ResponseBody is either text or json. if it is json, minify it! ]

Solution Makeup

I have  a background on software development so pulled the soluton together utilising Visual Studio, C# and ASP.Net running on .Net Core. I chose Ubuntu because I was most familiar with that flavour of Linux.

 

Can You Use It?

Of course you can. Before I provide you the download link there are some things I should tell you

  1. You use this at your own risk. I accept absolutely no liability for anything negative coming from its use
  2. I will however accept any and all praise if you find it useful 🙂

 

How Do I Install It?

  1. Once you have downloaded the zip file, extract the contents
  2. Import the OVF file into your favourite virtual solution (VMware Workstation, VMware vSphere for example). Make sure the NIC is connected where you want it and boot the VM
  3. Complete the Ubuntu setup, specifying keyboard layout details and create a user account to use [editor: if you want to set an IP address you can do this in the GUI at the end; by default it will pick up a DHCP address]
  4. Point a web browser at <appliance_ip_address> and accept the warning about the https certificate
  5. A web page will load. The appliance is now ready to use! You can check if the actual mocking service is running correctly by navigating to the following address in your web browser   <appliance_ip_address>/api/support. If all is well, you should see some text in the browser window

 

What About Support?

This is free you don’t get support! Just kidding. Ok, well sort of. There is no official support however I will try to help if I can.

Should you have any issues then please email me at bugs.mocksmart@automationpro.co.uk

If you have ideas for new features, improvements or just general inquiries, email me at mocksmart@automationpro.co.uk

 

What’s Next?

Im going to make a few packs for you to download over the coming month. The first one will be for VMware vRO, demonstrating how to use the appliance when developing workflows. In the meantime, try out the appliance. And remember, you can mock any REST based API with this.

paul_davey

CIO at Sonar, Automation Practice Lead at Xtravirt and guitarist in The Waders. Loves IT, automation, programming, music