Lightweight service virtualization/API simulation tool for developers and testers

Overview

Hoverfly

Circle CI Documentation Status Join the chat at https://gitter.im/SpectoLabs/hoverfly

API simulations for development and testing

Hoverfly is a lightweight, open source API simulation tool. Using Hoverfly, you can create realistic simulations of the APIs your application depends on.

  • Replace slow, flaky API dependencies with realistic, re-usable simulations
  • Simulate network latency, random failures or rate limits to test edge-cases
  • Extend and customize with any programming language
  • Export, share, edit and import API simulations
  • CLI and native language bindings for Java
  • REST API
  • Lightweight, high-performance, run anywhere
  • Apache 2 license

Hoverfly is developed and maintained by SpectoLabs.

Quickstart

Hoverfly Cloud

Hoverfly Cloud - API simulations as a service. Sign up here.

Contributing

Contributions are welcome!

To contribute, please:

  1. Fork the repository
  2. Create a feature branch on your fork
  3. Commit your changes, and create a pull request against Hoverfly's master branch
  4. In your pull request, include details regarding your change, i.e
    1. why you made it
    2. how to test it
    3. any information about testing you have performed

To read more about forking model, check out this link: forking workflow.

Setup for local development

Build

  1. Install Go. You should follow the download and installation instructions for your OS from official Go website. If you have installed Go before using either apt-get or homebrew, you should uninstall those first.

  2. Clone the hoverfly project:

    git clone https://github.com/SpectoLabs/hoverfly.git
    # or: git clone https://github.com/<your_username>/hoverfly.git
  3. Finally you can run the build

    cd hoverfly
    make build 

Notice the binaries are in the target directory.

Test

You should be able to execute all unit and functional tests with:

make test

Some middleware tests may fail if you don't have ruby and python setup in your environment. If you are using Mac, you can install them with Homebrew:

brew install ruby
brew install python

License

Apache License version 2.0 See LICENSE for details.

(c) SpectoLabs 2017.

Comments
  • Help on Hoverfly GUI  localhost:8888

    Help on Hoverfly GUI localhost:8888

    Please help me what to do next. As I am beginner to this topic. I just logged in the GUI. But not getting any tab to explore more on it. Thanks in advance !!!

    image

    documentation 
    opened by MohitIndian 42
  • add bodyFile to response part of pair

    add bodyFile to response part of pair

    Hey! I'm working on https://github.com/SpectoLabs/hoverfly/issues/815 and decided to make a PR so you can tell me if I'm on the right track. Tests pass locally, not sure why they are not run on CI here.

    I'll add new tests and update docs after successful review.

    Thanks.

    opened by ns3777k 41
  • Runtime error: invalid memory address or nil pointer reference

    Runtime error: invalid memory address or nil pointer reference

    From last couple of days, hoverfly has been crashing continuously and intermittently with following error logs:

    panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0xfc90f]

    goroutine 1103 [running]: panic(0x4bed00, 0xc82000c0b0) /usr/local/go/src/runtime/panic.go:481 +0x3e6 github.com/SpectoLabs/hoverfly/core.(_Hoverfly).captureRequest(0xc820163340, 0x0, 0x55bd50, 0x0, 0x0) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:313 +0x12cf github.com/SpectoLabs/hoverfly/core.(_Hoverfly).processRequest(0xc820163340, 0xc82064e1c0, 0xc82002aab8, 0x1) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/hoverfly.go:203 +0xb6 github.com/SpectoLabs/hoverfly/core.NewProxy.func2(0xc82064e1c0, 0xc820bb2000, 0xc820bb2000, 0x1) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/proxy.go:51 +0x2a github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.FuncReqHandler.Handle(0xc820da36e0, 0xc82064e1c0, 0xc820bb2000, 0xc5001, 0xc820b4a0a0) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/actions.go:19 +0x30 github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.(_ReqProxyConds).Do.func1(0xc82064e1c0, 0xc820bb2000, 0x11, 0x2f3501) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/dispatcher.go:200 +0x141 github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.FuncReqHandler.Handle(0xc8207869e0, 0xc82064e1c0, 0xc820bb2000, 0x0, 0x0) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/actions.go:19 +0x30 github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.(_ProxyHttpServer).filterRequest(0xc820014400, 0xc82064e1c0, 0xc820bb2000, 0xc82064e1c0, 0x0) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/proxy.go:56 +0xc7 github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.(_ProxyHttpServer).handleHttps.func1(0xa2ef00, 0xc820894060, 0xc82086a000, 0xc820bb2000, 0xc820cca1c0, 0xc820014400) /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/https.go:184 +0x891 created by github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy.(_ProxyHttpServer).handleHttps /home/ubuntu/.go_workspace/src/github.com/SpectoLabs/hoverfly/core/vendor/github.com/rusenask/goproxy/https.go:236 +0xe7a

    bug 
    opened by subodhbrahmi 28
  • Hoverfly could not execute this middleware

    Hoverfly could not execute this middleware

    I'm facing below error while using Java as middleware. Hoverfly could not execute this middleware

    Following is the command I'm trying to start. hoverctl middleware --binary java --script C:\tmp\Test.class

    Is Java as middleware supported? Am I using the command incorrectly? or any issue with Java version?

    hoverfly 
    opened by KvMadan 25
  • want to check the status of real service

    want to check the status of real service

    First want to check the status of real service if service is up then hoverfly should be goes into capture mode but status of real service is down then hoverfly should be goes into simulation mode how can we do this.

    feature request 
    opened by antika08 17
  • Incompatibility when proxying CORS/Ajax solution

    Incompatibility when proxying CORS/Ajax solution

    To reproduce with the fantastic http://todobackend.com/ comparison portal's test harness:

    git clone [email protected]:moredip/todo-backend-py.git 
    cd todo-backend-py/
    pip install web.py 
    hoverctl start
    hoverctl mode capture
    python todo-backend.py 
    

    In a browser, setup the proxy server to point to hoverfly. BUT change the excludes section. It probably says "don't proxy localhost". We don't want that, we want to hoverfly to explicitly record that. Instead we want to exclude the test harness from being captured - so change the 'don't-proxy' to be todobackend.com instead of localhost.

    Then in the same browser window, open http://todobackend.com/specs/index.html?http://localhost:8080 to run the test harness.

    Should take 2 seconds and be all 'green' suggesting that the test harness thinks the backend conforms to spec.

    It isn't though - the thing takes a couple of minutes because of timeouts, and is a bunch of failing tests.

    If you take out the browsers proxy changes (to facilitate hoverfly) then everything passes as expected.

    Note: there are many tens of implementations on http://todobackend.com/ but the web.py one I chose doesn't need a database setup (it's doing it all in memory) and is therefore easy to use. Be aware though that the author set up web.py incorrectly, and you might need to find the python process in ps aux to kill it if control-c isn't responding.

    opened by paul-hammant 17
  • Simulate stateful behaviour in Hoverfly

    Simulate stateful behaviour in Hoverfly

    We have debated how to handle state in Hoverfly but have held off as we need concrete use-cases. Bear in mind that we believe middleware will support stateful behaviour but do acknowledge that we perhaps need to add better support and guiadance.

    If you have opinions, one way or another please comment here (or add a reference). We are particularly looking for:

    • good use-cases, i.e. what tests are difficult or impossible without stateful behaviour
    • examples that demonstrate whether there needs to be some different support for unit, integration and end-to-end tests
    • what features should be supported in the language bindings such as Hoverfly Java?
    • are there specific features that should be added to allow middleware to support stateful behaviour?
    feature request hoverfly 
    opened by JohnFDavenport 16
  • unable to use hoverfly with firefox / https

    unable to use hoverfly with firefox / https

    Getting hoverfly to work as a proxy for http connections with firefox was quite simple. However, I'm unable to get it to work as a proxy for firefox with https connections. I have no idea where to even start with the debugging.

    I added the certificate to my system with the following commands:

     $ sudo cp ca.pem /usr/local/share/ca-certificates/hoverfly.crt
     $ sudo update-ca-certificates
    

    In firefox, I went into the preferences for connection settings and manually set a proxy using "localhost" and port 8500. I added the ca.pem certificate, also through the preferences panel.

    I started hoverfly with the following:

    $ ./hoverfly_linux_amd64  --capture -v
    

    When I go to https://yahoo.com the page says "Secure Connection Failed" and this is what I see on stdout:

    $ ./hoverfly_linux_amd64  --capture -v
    {"databaseName":"requests.db","level":"info","msg":"Initiating database","time":"2016-02-25T09:14:48-06:00"}
    {"level":"debug","msg":"new counter created, registration successful","time":"2016-02-25T09:14:48-06:00"}
    {"Destination":".","Mode":"capture","ProxyPort":"8500","level":"info","msg":"Proxy prepared...","time":"2016-02-25T09:14:48-06:00"}
    {"AdminPort":"8888","level":"info","msg":"Admin interface is starting...","time":"2016-02-25T09:14:48-06:00"}
    [negroni] listening on :8888
    2016/02/25 09:14:52 [001] INFO: Running 2 CONNECT handlers
    2016/02/25 09:14:52 [001] INFO: on 0th handler: &{2 <nil> 0x570300} yahoo.com:443
    2016/02/25 09:14:52 [001] INFO: Assuming CONNECT is TLS, mitm proxying it
    2016/02/25 09:14:52 [001] INFO: signing for yahoo.com
    2016/02/25 09:14:52 [001] WARN: Cannot handshake client yahoo.com:443 remote error: bad certificate
    

    Are there extra or different configuration steps I need to take?

    opened by boakley 16
  • Hoverfly as http proxy

    Hoverfly as http proxy

    Hi, hoverfly looks amazing but i'm failing trying to set it up as a proxy to modify the response for certain urls.

    My python script is the same to the one here https://www.specto.io/service-virtualization-modifying-traffiic/

    But I don't get it works.

    ./hoverfly --modify --middleware="./myscript"

    I expect modify all HTTP GET responses but when I use any browser every response is not customized.

    bug 
    opened by rchampa 16
  • Slow import

    Slow import

    I have a large export file (~500Mb). Starting hoverfly with "hoverfly -import simulation.json" takes around 2 hours for me:( I did a profiling and that what I see in pprof top:

          flat  flat%   sum%        cum   cum%
     14.73mins 11.62% 11.62%  91.20mins 71.95%  reflect.deepValueEqual
      7.59mins  5.99% 17.61%   8.91mins  7.03%  runtime.ifaceeq
      7.08mins  5.59% 23.20%  26.54mins 20.94%  runtime.mallocgc
      5.57mins  4.39% 27.59%   5.57mins  4.39%  runtime.memmove
      4.92mins  3.88% 31.47%   8.48mins  6.69%  runtime.strequal
      4.84mins  3.82% 35.29%  12.81mins 10.11%  runtime.mapassign
      4.49mins  3.54% 38.84%   5.84mins  4.61%  runtime.heapBitsSetType
      4.32mins  3.40% 42.24%   9.85mins  7.77%  runtime.scanobject
      4.06mins  3.20% 45.44%   4.06mins  3.20%  reflect.Value.Type
      3.21mins  2.53% 47.98%   3.21mins  2.53%  runtime.memclrNoHeapPointers
    

    This lead me to the function AddPair in core/models/simulation.go, that is doing DeepEqual check for each pair adding to the simulation. I think its need to be optimized! When I add a new function "AddPairWithoutDuplicateCheck" and use it in core/import.go instead "AddPair" then import of the same file took few seconds.

    opened by aosavitski 15
  • Xpath matcher cannot match on XML with namespace prefix

    Xpath matcher cannot match on XML with namespace prefix

    I have a sample xml file, for which I am trying to match request body with xpathMatch. I have validated the xpath in an online tool "https://www.freeformatter.com/xpath-tester.html" and I was able to get a correct match . However when I put the same xpath in hovefly it's throwing an error. "There was an error when matching Got error: Could not find a match for request, create or record a valid matcher first! "

    Please find attached the sample xml & xpath used. Sample_xml_xpath.txt let me know if I am missing any thing.

    bug help wanted 
    opened by brijeshps 15
Releases(v1.3.7)
Lightweight selfhosted Firefox Send alternative without public upload

Gokapi Available for: Bare Metal Docker About Gokapi is a lightweight server to share files, which expire after a set amount of downloads or days. It

Marc Ole Bulling 402 Sep 18, 2022
Professional lightweight testing mini-framework for Go.

is Professional lightweight testing mini-framework for Go. Easy to write and read Beautifully simple API with everything you need: is.Equal, is.True,

Mat Ryer 1.5k Sep 18, 2022
Lightweight HTTP mocking in Go (aka golang)

httpmock This library builds on Go's built-in httptest library, adding a more mockable interface that can be used easily with other mocking tools like

null 78 Aug 11, 2022
A basic lightweight HTTP client for Go with included mock features.

A basic lightweight HTTP client for Go with included mock features. Features Support almost all http method like G

Andres Mijares 1 May 2, 2022
Package has tool to generate workload for vegeta based kube-api stress tests.

Package has tool to generate workload for vegeta based kube-api stress tests.

Mikhail Sakhnov 0 Nov 22, 2021
go-wrk - a HTTP benchmarking tool based in spirit on the excellent wrk tool (https://github.com/wg/wrk)

go-wrk - an HTTP benchmarking tool go-wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CP

Tal Sliwowicz 590 Sep 16, 2022
ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format. This service can then simply be consumed by any client to get the expected response.

Sumit Tokkar 3 Mar 2, 2021
Vitaly Berg 7 Aug 10, 2021
Simple auth service for testing purposes

Auth mock service Simple auth service for testing purposes. Based on https://github.com/stefanprodan/podinfo Credentials: { "username": "username-ro

Kajetan 0 Oct 5, 2021
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Fortio (Φορτίο) 2.7k Oct 2, 2022
End-to-end HTTP and REST API testing for Go.

httpexpect Concise, declarative, and easy to use end-to-end HTTP and REST API testing for Go (golang). Basically, httpexpect is a set of chainable bui

Victor Gaydov 2k Oct 1, 2022
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.

?? Playwright for API reference | Example recipes Playwright is a Go library to automate Chromium, Firefox and WebKit with a single API. Playwright is

Max Schmitt 936 Sep 26, 2022
This repository includes consumer driven contract test for provider, unit test and counter api.

This repository includes consumer driven contract test for provider, unit test and counter api.

Ahmet Zümberoğlu 0 Feb 1, 2022
A next-generation testing tool. Orion provides a powerful DSL to write and automate your acceptance tests

Orion is born to change the way we implement our acceptance tests. It takes advantage of HCL from Hashicorp t o provide a simple DSL to write the acceptance tests.

Wesovi Labs 45 Aug 31, 2022
Stress testing and benchmarking tool for the NEAR EVM

evm-bully --- stress testing and benchmarking tool for the NEAR EVM

Project Aurora 28 May 30, 2022
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Tomás Senart 20.2k Oct 1, 2022
Plow is a high-performance HTTP benchmarking tool with real-time web UI and terminal displaying

Plow is a HTTP(S) benchmarking tool, written in Golang. It uses excellent fasthttp instead of Go's default net/http due to its lightning fast performance.

ddc 3.2k Sep 23, 2022
Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Michael Henriksen 4.8k Sep 25, 2022
Ritchie CLI is an open-source tool that allows to create, store and share any kind of automation, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡

Table of contents 1. About 2. Getting Started i. Installation ii. Initialize rit locally iii. Add your first formulas repository iv. Run the Hello Wor

ZUP IT INNOVATION 563 Sep 29, 2022