All Projects → finestructure → Rester

finestructure / Rester

Licence: MIT license
A command line tool to test (REST) APIs

Programming Languages

swift
15916 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Rester

bow-openapi
🌐 Functional HTTP client generator from an OpenAPI/Swagger specification.
Stars: ✭ 47 (+11.9%)
Mutual labels:  swift-package-manager, http-client
Hoppscotch
👽 Open source API development ecosystem https://hoppscotch.io
Stars: ✭ 34,569 (+82207.14%)
Mutual labels:  http-client, testing-tools
libashttp
A C++ async HTTP client library to use in asynchronous applications while communicating with REST services.
Stars: ✭ 51 (+21.43%)
Mutual labels:  http-client
chclient
Fast http client for SELECT queries in clickhouse
Stars: ✭ 44 (+4.76%)
Mutual labels:  http-client
SwiftGradients
Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Stars: ✭ 15 (-64.29%)
Mutual labels:  swift-package-manager
hackipy
Hacking, pen-testing, and cyber-security related tools built with Python.
Stars: ✭ 26 (-38.1%)
Mutual labels:  testing-tools
centra
Core Node.js HTTP client
Stars: ✭ 52 (+23.81%)
Mutual labels:  http-client
Testcase-Generator
⚡️ Handy script for HackerRank, HackerEarth and CodeChef TCs Generation.
Stars: ✭ 85 (+102.38%)
Mutual labels:  testing-tools
pytest-localstack
Pytest plugin for local AWS integration tests
Stars: ✭ 66 (+57.14%)
Mutual labels:  testing-tools
heroshi
Heroshi – open source web crawler.
Stars: ✭ 51 (+21.43%)
Mutual labels:  http-client
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-26.19%)
Mutual labels:  swift-package-manager
cucumber-steps
🥒 Quick start for testing with Cucumber.js
Stars: ✭ 15 (-64.29%)
Mutual labels:  testing-tools
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (-52.38%)
Mutual labels:  testing-tools
csweet
demo how to use C++ in Swift 3.1/4.0
Stars: ✭ 12 (-71.43%)
Mutual labels:  swift-package-manager
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-45.24%)
Mutual labels:  testing-tools
tribble
Coverage based JVM Fuzz testing tool.
Stars: ✭ 16 (-61.9%)
Mutual labels:  testing-tools
swift-outdated
A swift subcommand for displaying when your dependencies (SwiftPM or Xcode) are out of date
Stars: ✭ 158 (+276.19%)
Mutual labels:  swift-package-manager
carina-demo
Carina demo project.
Stars: ✭ 40 (-4.76%)
Mutual labels:  testing-tools
Ether
A Command-Line Interface for the Swift Package Manager
Stars: ✭ 86 (+104.76%)
Mutual labels:  swift-package-manager
cljs-test-display
Visual display for ClojureScript tests.
Stars: ✭ 106 (+152.38%)
Mutual labels:  testing-tools

Rester

Build Status codecov Twitter: @_sa_s

Rester is a command line tool to test HTTP APIs. It processes declaratively written request descriptions as a test script, executing and validating the requests as specified.

For instance, a description like the following:

# basic.yml
requests:
  basic:
    url: https://httpbin.org/anything
    validation:
      status: 200

is processed as follows:

asciicast

Rester currently supports:

  • Request methods: GET, POST, PUT, DELETE
  • Variable substitution
  • Post data with respective encoding
    • JSON
    • query parameters
    • forms
    • multipart
  • Sending headers
  • Using response values as substitution variables
  • Batch file processing
  • Uploading and downloading of files
  • Delay between requests

See Upcoming Features for a list of what is planned for future releases.

Example request sequence

An example is worth a thousand words - this is how you can use rester to instrument API calls:

# github.yml
variables:
  BASE_URL: https://api.github.com/repos/finestructure/Rester
requests:
  releases:
    url: ${BASE_URL}/releases
    validation:
      status: 200
      json:
        # validate the first id in the list (latest release)
        # this also captures it as a variable
        0:
          id: .regex(\d+)
    log:
      # log the id to the console
      - json[0].id
  latest_release:
    # use the release id to request release details
    url: ${BASE_URL}/releases/${releases[0].id}
    validation:
      status: 200
    log:
      # log the latest release tag to the console
      - json.tag_name

Result:

asciicast

More examples

The examples directory demonstrates further uses of rester. You can also find the output these examples generate in the test snapshot directory.

A few noteworthy examples for common tasks are

  • github.yml: Use the Github API to fetch and print the latest release version of rester. Demonstrates the use of response variables and how to index into response arrays and objects as well as how to log responses.
  • multipart.yml: Performs a multipart upload of an image.

Running rester

The easiest way to run rester is via docker:

docker run --rm -t -v $PWD:/host -w /host finestructure/rester examples/github.yml

It's probably easiest to define an alias:

alias rester="docker run --rm -t -v $PWD:/host -w /host finestructure/rester"
rester examples/basic.yml

A word regarding the docker parameters:

  • --rm cleans up the container after running
  • -t attaches a tty (this helps with flushing and unicode representation)
  • -v $PWD:/host maps your current directory onto /host inside the container
  • -w /host sets that /host directory as the working directory inside the container. This way you can simply reference files relative to your working directory and they will be found at the same path inside the container.

Note that if you want to test APIs that are running on localhost, you will also want to add

  • --network host

to your docker run command. This lets the container run on the host network and allows it to see the host as localhost.

Installing rester

rester requires Swift 5. You can build and install it from source via the Swift Package Manager:

git clone https://github.com/finestructure/rester
cd rester
swift build -c release

On macOS, the easiest way to install and update rester is probably Mint:

brew install mint
mint install finestructure/rester
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].