Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/ema/httptester

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ema/httptester

  • v0.0.0-20200625155407-ed569e5e6df0
  • Source
  • Go
  • Socket score

Version published
Created
Source

httptester

A program to test the behavior of HTTP proxies.

Getting Started

You can install httptester as follows:

go install github.com/ema/httptester

Write a test file such as the following:

# Test a basic get request

handle "/endpoint/1" {
    expect req.method eq "GET"
    expect req.headers["User-Agent"] ~ "chrome"
    expect req.body eq ""
    tx -body "Hello world!" -header "X-HTC-Origin: true" -status 200
}

client "nemo" {
    tx -url "/endpoint/1" -method "GET" -header "User-Agent: this might look like chrome to some"
    expect resp.status ne 404
    expect resp.headers["Server"] ~ "^ATS/[0-9]\.[0-9]\.[0-9]$"
    expect resp.headers["Something-That-Should-Not-Be-Set"] eq ""
    expect resp.status eq 200
}

Save the test somewhere, for example as get.htc. Then run it with:

$ httptester -verbose get.htc
2020/06/25 16:58:27 Finished waiting for http://localhost:45521/httpTesterInternalCheck
2020/06/25 16:58:30 Finished waiting for http://localhost:34965/httpTesterInternalCheck
2020/06/25 16:58:30 Proxy started using temporary directory /tmp/runroot414268077
2020/06/25 16:58:30 Sending GET /endpoint/1
User-Agent:  this might look like chrome to some

2020/06/25 16:58:30 Exiting in 0 seconds
$ echo $?
0

Try to change some of the expect, for instance expecting the request to be a POST instead, and verify that the test fails:

$ httptester not-a-post.htc
2020/06/25 16:59:17 FAILED: "req.method eq \"POST\"" (actual="GET")
$ echo $?
1

License

This project is licensed under the Apache License - see the LICENSE file for details.

FAQs

Package last updated on 25 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc