bestowinc/darkroom

A contract testing tool built in Rust using the filmReel format

0 or greater for making gRPC requests

Darkroom

A contract testing tool built in Rust using the filmReel format.


Sample request:

usr.cut.json:

// Cut: the data sharing system allowing one Frame to pass messages to the next Frame
{"HTTP_ENDPOINT": "/create_user"}

usr.01s.createuser.fr.json:

// Frame: the JSON file where input an output expectations are set
{
  "protocol": "HTTP",                      // protocol: the declared communication protocol
  "cut": {                                 // cut: declare what variables should be pulled "from" and pushed "to" `usr.cut.json`
    "from": ["HTTP_ENDPOINT"],             // pull the HTTP_ENDPOINT "from" `usr.cut.json`
    "to": {                                // push the USER_ID found in .response.body.msg "to" `usr.cut.json`
      "USER_ID": "'response'.'body'.'msg'"
    }
  },
  "request": {                             // request object
    "body": {                              // request body
      "email": "[email protected]"
    },
    "uri": "POST ${HTTP_ENDPOINT}"         // request uri: HTTP_ENDPOINT will be replaced by "/create_user"
  },
  "response": {                            // response object
    "body": {                              // response body
      "msg": "created user: ${USER_ID}"    // USER_ID will be stored if there is a match for the surrounding values
    },
    "status": 200                          // expected response status code
  }
}

Installation

  • Simple: cargo install darkroom
  • Clone with submodules: git clone --recurse-submodules -j8 https://github.com/Bestowinc/darkroom

 

For gRPC requests: Darkroom 0.3 or greater requires grpcurl v1.6.0 or greater for making gRPC requests.

Usage:

dark:

Usage: dark [<address>] [-v] [-H <header>] [--cut-out <file>] [-i] [--tls] [--proto-dir <dir...>] [-p <file...>] <command> [<args>]

Darkroom: .

Options:
  -v, --verbose     enable verbose output
  -H, --header      fallback header passed to the specified protocol
  --cut-out         output of final cut file
  -i, --interactive interactive frame sequence transitions
  --tls             enable TLS (automatically inferred for HTTP/S)
  --proto-dir       the path to a directory from which proto sources can be
                    imported, for use with --proto flags.
  -p, --proto       pass proto files used for payload forming
  --help            display usage information

Commands:
  version           Returns CARGO_PKG_VERSION
  take              Takes a single frame, emitting the request then validating
                    the returned response
  record            Attempts to play through an entire Reel sequence running a
                    take for every frame in the sequence
  man               return a given manual entry
  vrecord           Attempts to play through an entire VirtualReel sequence
                    running a take for every frame in the sequence

Examples:
  Step through the httpbin test in [-i]nteractive mode:
      $ dark -i record ./test_data post
  Echo the origin `${IP}` that gets written to the cut register from the httpbin.org POST request:
      $ dark --cut-out >(jq .IP) take ./test_data/post.01s.body.fr.json
  Run the post reel in a v-reel setup:
      $ dark vrecord ./test_data/post.vr.json

Notes:
  Use `dark man` for details on filmReel, the JSON format.

Examples:

# step through the httpbin test in [-i]nteractive mode
dark -i record ./test_data post
# to fail at the third httpbin frame, set a timeout of two seconds
dark --interactive record ./test_data post --timeout 2
# multiple merge cuts can be used, with values being overridden left to right (right will have newer values)
dark --interactive record ./test_data post --cut ./test_data/post.cut.json '{"NEW":"value"}' '{"NEWER": "value", "NEW":"overridden"}'
# echo the origin "${IP}" that gets written to the cut register from the httpbin.org POST response
dark --cut-out >(jq .IP) take ./test_data/post.01s.body.fr.json --cut ./test_data/post.cut.json
# create a stripe token using the public Stripe API key
dark --verbose --cut-out >(jq) record ./test_data stripe_token
# create a stripe subscription preceding it with the stripe_token flow
dark --cut-out >(jq) record ./test_data stripe_subscription --component './test_data&stripe_token'

CHANGELOG

Please see the CHANGELOG for a release history.

Versions

Find the latest versions by id

v0.8.0 - Mar 24, 2022

What's Changed

New Contributors

Full Changelog: https://github.com/Bestowinc/darkroom/compare/0.7.0...v0.8.0

0.7.0 - May 28, 2021

  • added dark man command for additional documentation, can be excluded from build with the --no-default-features flag
  • added dark vreel command to support virtual reels allowing mixing of arbitrary cuts and frames in a chosen order: dark vrecord ./test_data/post.vr.json
  • added partial and unordered response validations to filmreel
  • implemented subset of jql for mutable selections of the resposne json the jql library can be included with the --features=filmreel/full_jql flag
  • an empty body in the request is now appropriately represented as a missing body key rather than "body": {}
  • take and record can now accept a mixture of filepaths and json strings: dark take ./test_data/post.01s.body.fr.json '{"new":"value"}' ./test_data/post.cut.json
  • dark take command simplified, if --cut not provided, will try to look for a cut file in the same directory as the given frame json

0.7.0-a - May 02, 2021

  • implemented validations with partial comparison property
  • an empty body in the request is now appropriately represented as a missing body key rather than "body": {}
  • introduced own selector engine to do in-place mutations for validations rather than using jql

0.6.0 - Jan 05, 2021

  • added --import-path for dark --proto arguments specifying paths for proto definition lookup
  • added dark record --duration to display total time elapsed in a record session

0.5.0 - Dec 15, 2020

  • timestamps are added to recordings: dark record record ./test_data post --timestamp
  • 30 sec default timeout can now be overridden: dark record record ./test_data post --timeout 2
  • reel sequence numbers are now checked for duplicates

0.5.0-a - Dec 09, 2020

  • timestamps are added to recordings: dark record record ./test_data post --timestamp
  • 30 sec default timeout can now be overridden: dark record record ./test_data post --timeout 2

0.4.0 - Aug 24, 2020

  • range added to recordings: dark record --range "<start_u32>:<end_u32>" ./dir/ my_reel_name

0.3.3-b - Aug 17, 2020

  • "request"["form"] request building URL functionality moved to "request"["query"]
  • "request"["form"] now properly bulids the form data of the HTTP request

0.3.3-a - Jul 31, 2020

  • Added grpcurl error propagation

0.3.2 - Jul 06, 2020

  • request retry attempts now include a process_response comparison
  • ToTakeHiddenColouredJson is now a generic trait
  • ToStringHidden is now a generc trait
  • moved styler out of take.rs and into lib.rs

0.3.1 - Jun 25, 2020

  • frame response body is now optional

0.3.0 - Jun 09, 2020

  • removed YAML deserialization now that grpcurl properly emits JSON errors
  • added retry attempts to frame requests: {"request":{"attempts": {"times": 5, "ms": 500}}}

0.2.4 - May 12, 2020

  • Non-verbose mode for None error hotfix

0.2.3 - May 12, 2020

  • Added component reel support, component reels are generate as a prelude to the provided reel dark record --component "<dir>&<reel_name>" ./dir/ my_reel_name
  • Added anyhow error handling
  • dark --cut-out can now be returned on a failed record or take

0.2.2 - May 07, 2020

0.2:

  • HTTP support
  • Full json object storage and retrieval, the cut register is no longer a flat associative array, strings are still used to map to JSON objects for templating
  • Variable discarding: ${lowercase} variables will only be kept around for the duration of the frame
  • Headers and entrypoints can be stored and read on a per JSON frame basis
  • SOPS/json secrets support

0.2.1:

  • Added hidden variable support, hidden variables are defined with a leading underscore: ${_HIDDEN}
  • Added dark version command
  • moved common parameters into the main dark command to be shared across subcommands

0.2.2:

  • Hotfix for cut output panic

0.1.2 - Feb 26, 2020

  • Added proto path support

Information - Updated Oct 11, 2021

Stars: 12
Forks: 1
Issues: 2

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically

Rust Greatest JSON weapon is Serde with over 4.4K stars on github and a massive developer community. This is considered a core Rust library for every developer to learn in BRC's opinion

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically

Rust 버전 JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

Rust 버전 JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

SIMD JSON for Rust  

Rust port of extremely fast serde compatibility

SIMD JSON for Rust  

JSON-E Rust data-struct paramter crate for lightweight embedded content with objects and much more

What makes JSON-e unique is that it extensive documentation and ease of use

JSON-E Rust data-struct paramter crate for lightweight embedded content with objects and much more
JSON

111

A Rust JSON5 serializer and deserializer which speaks Serde

Deserialize a JSON5 string with from_str

A Rust JSON5 serializer and deserializer which speaks Serde

Rust JSON Parser Benchmark

Download and Generate JSON Data

Rust JSON Parser Benchmark

Read JSON values quickly - Rust JSON Parser

AJSON get json value with specified path, such as project

Read JSON values quickly - Rust JSON Parser

Rust actix json request example

Send a json request to actix, and parse it

Rust actix json request example
JSON

140

json_typegen - Rust types from JSON samples

json_typegen is a collection of tools for generating types from

json_typegen - Rust types from JSON samples

Rust JSON parsing benchmarks

This project aims to provide benchmarks to show how various JSON-parsing libraries in the Rust programming language perform at various JSON-parsing tasks

Rust JSON parsing benchmarks

A tiny command line tool written in rust to print json data as a formatted...

A tiny command line tool written in rust to print json data as a formatted table

A tiny command line tool written in rust to print json data as a formatted...

Rust RPC client for Bitcoin Core JSON-RPC

rust-jsonrpc and makes it easier to talk to the Bitcoin JSON-RPC interface

Rust RPC client for Bitcoin Core JSON-RPC
Facebook Instagram Twitter GitHub Dribbble
Privacy