theredfish/grillon

Grillon offers an elegant and natural way to approach end-to-end HTTP API testing in Rust

Elegant, intuitive and expressive API

Grillon

.

  • Built-in testing functions
  • Extensible

Please note that the API is subject to a lot of changes until the v1.0.0.

  • API doc
  • Changelog

Getting started

This example enables the optional diff feature and uses Tokio as asynchronous runtime. Generally, testing libs are used in unit or integration tests. You can declare grillon as a dev-dependency.

Add grillon to Cargo.toml

[dev-dependencies]
grillon = { version = "0.3.0", features = ["diff"] }
tokio = { version = "1", features = ["macros"] }

Then use grillon :

use grillon::{
    header::{HeaderValue, CONTENT_TYPE},
    json, Grillon, StatusCode, Result
};

#[tokio::test]
async fn end_to_end_test() -> Result<()> {
    Grillon::new("http://jsonplaceholder.typicode.com")?
        .post("posts")
        .payload(json!({
            "title": "foo",
            "body": "bar",
            "userId": 1
        }))
        .assert()
        .await
        .status_success()
        .assert_fn(|assert| {
            assert!(!assert.headers.is_empty());
            assert!(assert.status == StatusCode::CREATED);
            assert!(assert.json.is_some());

            println!("Json response : {:#?}", assert.json);
        })
        .status(StatusCode::CREATED)
        .headers_exist(vec![(
            CONTENT_TYPE,
            HeaderValue::from_static("application/json; charset=utf-8"),
        )])
        .body(json!({
            "id": 101,
        }));

    Ok(())
}
Issues

Collection of the latest Issues

theredfish

theredfish

Comment Icon0

Add an additional assertion for the response time.

Just like the body, we will need different predicates. Not all predicates are compatible with the functions. For example Predicate::Matches for the body assertion doesn't make sense to check the response time. We will need to apply different predicate scopes, for example a predicate module :

Connected to #17

theredfish

theredfish

Comment Icon0

For the moment we only support StatusCode which is a bit restrictive. Ideally we should support different types :

This will allow us to also convert int to StatusCode.

Now this could be a turning point for the library. Just like Tower, we could have a library that is

protocol agnostic, but is designed around a request / response pattern

theredfish

theredfish

Comment Icon1

For the moment we're only supporting a BodyExactMatcher which is not really convenient. Ideally we would like to match with different predicates :

  • is
  • is not
  • contains
  • does not contain
  • matches (Regex)
  • does not match (Regex)
  • jsonpath (json path expression)

Example of API usage :

  • body(Predicate::Is, json!({"id": 101})
  • body(Predicate::Is, r#"{"id": 101}"#)
  • body(Predicate::JsonPath, "$.store.book[0].title")
  • body(Predicate::Matches, Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+"))
theredfish

theredfish

Comment Icon0

Just like for #10 add a built-in function for multipart response body in Response returning an Option<Multipart> struct.

theredfish

theredfish

Comment Icon0

For the moment grillon only supports json bodies, Extend the built-in functions with an html function in Response that returns an Option<String> (or a struct allowing to parse html content maybe).

theredfish

theredfish

Comment Icon0

By using an existing Rust library we can easily extend the built-ins assertion functions with one for validating the json schema.

Versions

Find the latest versions by id

v0.3.0 - Jan 25, 2022

What's Changed

Full Changelog: https://github.com/theredfish/grillon/compare/v0.2.0...v0.3.0

v0.2.0 - Jan 23, 2022

What's Changed

Full Changelog: https://github.com/theredfish/grillon/compare/v0.1.0...v0.2.0

v0.1.0 - Dec 10, 2021

What's Changed

New Contributors

Full Changelog: https://github.com/theredfish/grillon/commits/v0.1.0

Information - Updated Jul 18, 2022

Stars: 16
Forks: 2
Issues: 6

When you need to pretend you are a REST API, but you're really not

Facade is a Rust-based HTTP transformation layer to seamlessly convert REST calls into GraphQL calls for piecemeal API migrations

When you need to pretend you are a REST API, but you're really not

When you need to pretend you are a REST API, but you're really not

Vostok is a Rust-Based HTTP Transformation Layer To Seamlessly Convert REST Calls Into GraphQL Calls For Piecemeal API Migrations

When you need to pretend you are a REST API, but you're really not

Eve-rs is a middleware-based rust http framework which is inspired from ExpressJS framework

Let's create a demo application using eve-rs, using an intuative approach to get a better understanding of the framework

Eve-rs is a middleware-based rust http framework which is inspired from ExpressJS framework

Rust Urbit HTTP API

This library wraps the Urbit ship http interface exposing it as an easy-to-use Rust crate

Rust Urbit HTTP API

HTTP Server with Rust

Rust http server from scratch

HTTP Server with Rust

ehttp: a minimal Rust HTTP client for both native and WASM

If you want to do HTTP requests and are targetting both native and web (WASM), then this is the crate for you!

ehttp: a minimal Rust HTTP client for both native and WASM

Here lies my attempt to create a multi thread webserver based off of Rust and...

Here lies my attempt to create a multi thread webserver based off of Rust and using HTTP and TCP networking protocols :)

Here lies my attempt to create a multi thread webserver based off of Rust and...

rust-http-server

Multithread HTTP Server developed with Rust

rust-http-server

Based on the webserver of the rust documentation

This is just a small project for me to learn more about Rust and the HTTP protocol

Based on the webserver of the rust documentation

A Rust HTTP server for Python applications

Granian is currently in early-stage development

A Rust HTTP server for Python applications
Facebook Instagram Twitter GitHub Dribbble
Privacy