0.01
No commit activity in last 3 years
No release in over 3 years
http proxy with api for modifying requests passing through
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies
 Project Readme

Liquid Proxy

Build status Gem Version

Overview

Http proxy that you can instruct via api to inject arbitrary headers into requests passing through.

Why? I needed it to recreate parts of live infrustructure in test environment (namely, the app under test was behind the proxy that takes care of authenticating users and passes on its checks in the form of http header).

Usage

This is a ruby gem and it requires ruby >= 1.9.2.

# Gemfile
gem 'liquid-proxy'

The following example shows usage with cucumber/capybara/selenium:

# env.rb
require 'capybara'
require 'selenium-webdriver'
require 'liquid-proxy'
    
LiquidProxy.start(port: 9889)
    
Capybara.configure do |config|
  config.default_driver = :selenium
  config.run_server     = false
  config.app_host       = "http://test.example.com"
end
        
Capybara.register_driver :selenium do |app|
  profile       = Selenium::WebDriver::Firefox::Profile.new
  profile.proxy = Selenium::WebDriver::Proxy.new(http: 'localhost:9889', type: :manual)

  Capybara::Selenium::Driver.new(app, profile: profile)
end

# let tests start clean
Before do
  LiquidProxy.headers_to_inject.clear
end

Then in step definitions you can:

# set headers to inject
LiquidProxy.headers_to_inject = {'Foo' => 'Bar', 'Accept' => 'Cash'}
    
# add to headers to inject
LiquidProxy.headers_to_inject['X_HACKERY'] = 'BOOM'
    
# clear headers to inject
LiquidProxy.headers_to_inject.clear

Standalone usage

If you are not using ruby, it is possible to run liquid-proxy as a standalone process and controll it via REST api:

# install
bash$ gem install liquid-proxy

# start
bash$ liquid-proxy 8998

# add headers
bash$ curl --data-binary '{"Foo":"Bar","Accept":"Cash"}' http://localhost:8998

# clear headers
bash$ curl -X DELETE http://localhost:8998

Author

Artem Avetisyan