🟪 DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.

Overview

DeepfakeHTTP – Your 100% static dynamic backend

License MIT Version 1.0.5 Powered by Tommy


DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.

What are people using it for?
  • Creating the product POC or demo before even starting out with the backend
  • REST, GraphQL, and other APIs prototyping and testing
  • Hiding critical enterprise infrastructure behind a simple static facade
  • Hacking and fine-tuning HTTP communications on both server and client sides

Features

  • No dependencies
  • No installation
  • No configuration files
  • Single-file executable

Command Line Interface (CLI)

java -jar df.jar [options] [dump1.txt] [dump2.txt] ...

Options:
        --help           print help message
        --info           print dump files statistics as JSON
        --requests       print dump requests as JSON
        --port           TCP port number, default: 8080
        --collect <file> append live request/response dumps to file
        --no-log         disable request/response console logging
        --no-etag        disable ETag optimization
        --no-watch       disable watch dump files for changes

Prerequisites

  • Java 15 or above

Get started

  1. Download the latest release of df.jar
  2. Copy-paste the content of the dump example to the file dump-sample.txt:
    GET /api/customer/123 HTTP/1.1
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "id": 123,
        "fname": "John",
        "lname": "Doe",
        "email": ["[email protected]", "[email protected]"]
    }
    
  3. Start the server from command line:
    java -jar df.jar dump-sample.txt
    
  4. Use a browser to check whether the server is running: http://localhost:8080/api/customer/123
For more examples see: APPENDIX B.

How does it work?

  1. Got client request
  2. Search dump entries (request-response pairs) for appropriate entry by matching all specified request parts:
    method, URI, headers, and body
  3. If entry is found, the server generates a corresponded response and sends it to the client
  4. If entry is not found, the server search dump entries for response with status 400 (Bad request).
  5. If entry is found, the server send entry to the client
  6. If entry is not found, the server sends status 400 with no body.
That's all.

Supports

  • asynchronous requests and responses
  • scriptable response body
  • all HTTP methods
  • multi-line and multi-value headers
  • OpenAPI-styled templates in paths
  • wildcards ( * and ? with escape / ) in query string and header values
  • templates in response body
  • response body fetching from external sources like URLs, local files, and data URI
  • per entry user-defined request and response delays
  • comments in dumps
  • live request/response collection
  • watching dump files for changes
  • ETag optimization

License

The DeepfakeHTTP is released under the MIT license.




APPENDIX A.
Optional response headers

Header Description
X-Body-Type

Tells the server what the content type (media type) of the body content actually is. Value of this header has same rules as value of standard HTTP Content-Type header.

This header is useful when you want to use binary data, template or script as a response body.

Examples:

📎 A response body is a character data (default).
No X-Body-Type header is needed.

HTTP/1.1 200 OK
Content-Type: application/json

{"id": 5, "name": "John Doe"}

📎 Get a response body from a remote server.
Body type is text/uri-list (RFC 2483)

HTTP/1.1 200 OK
Content-Type: application/json
X-Body-Type: text/uri-list

http://example.com/api/car/1234.json

📎 Get a response body from a file.
Body type is text/uri-list (RFC 2483)

HTTP/1.1 200 OK
Content-Type: image/jpeg
X-Body-Type: text/uri-list

file:///home/john/photo.jpeg

📎 Get a response body from a data URI.
Body type is text/uri-list (RFC 2483)

HTTP/1.1 200 OK
Content-Type: image/gif
X-Body-Type: text/uri-list

data:image/gif;base64,R0lGODlhAQABAIAAAP...

📎 Get a response body from a template.
Body type is text/template. Useful for forms processing.

HTTP/1.1 200 OK
Content-Type: text/html
X-Body-Type: text/template

<!DOCTYPE html>
<html lang="en">
    <body>
        <h1>Hello, ${fname[0]} ${lname[0]}!</h1>
    </body>
</html>
X-Request-Delay

Request delay (in milliseconds).

Example:
# Two seconds request delay.

HTTP/1.1 200 OK
X-Request-Delay: 2000

{"id": 5, "name": "John Doe"}
X-Response-Delay

Response delay (in milliseconds).

Example:
# Two seconds response delay.

HTTP/1.1 200 OK
X-Response-Delay: 2000

{"id": 5, "name": "John Doe"}
NOTE:  Optional response headers will not be sent to clients.

APPENDIX B.
Dump examples


Example 1.

# Comments are welcome! :)
# Please don't miss a single carriage return between headers and body!

GET /form.html HTTP/1.1

# Fake HTML file :)
HTTP/1.1 200 OK

<!DOCTYPE html>
<html lang="en">
<body>
    <form action="/add_user.php" method="POST">
        <label for="fname">First name:</label><input type="text" name="fname"><br><br>
        <label for="lname">Last name: </label><input type="text" name="lname"><br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>


POST /add_user.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded

# Fake PHP file :)
HTTP/1.1 200 OK
Content-Type: text/html
X-Body-Type: text/template

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Hello, ${fname[0]} ${lname[0]}!</h1>
</body>
</html>

Example 2.

#
# First request-response entry
#

# Client request
GET /api/customer/5 HTTP/1.1
Accept-Language: ru;*

# Server response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": 5,
    "name": "Джон Доу"
}


#
# Second request-response entry
#

# Client request
GET /api/customer/5 HTTP/1.1

# Server response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": 5,
    "name": "John Doe"
}

Example 3.

#
# Work with HTML forms (1)
#

GET /form.html HTTP/1.1

HTTP/1.1 200 OK

<!DOCTYPE html>
<html lang="en">
<body>
    <form action="/action_page.php" method="POST">
        <label for="fname">First name:</label><input type="text" name="fname"><br><br>
        <label for="lname">Last name: </label><input type="text" name="lname"><br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>


POST /action_page.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded

HTTP/1.1 200 OK
Content-Type: text/html
X-Body-Type: text/template

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Hello, ${fname[0]} ${lname[0]}!</h1>
</body>
</html>

Example 4.

#
# Work with HTML forms (2)
#

GET /form.html HTTP/1.1

HTTP/1.1 200 OK

<!DOCTYPE html>
<html lang="en">
<body>
    <form action="/action_page.php" method="POST">
        <label for="fname">First name:</label><input type="text" name="fname"><br><br>
        <label for="lname">Last name: </label><input type="text" name="lname"><br><br>
        <p>Only first name 'John' and last name 'Doe' are supported.<br>
        Expected output is: Hello, John Doe!,<br>
        or HTTP status 400 Bad request if first name is not 'John' or last name is not 'Doe'.
        </p><br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>


POST /action_page.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded

fname=John&lname=Doe

HTTP/1.1 200 OK
Content-Type: text/html
X-Body-Type: text/template

<!DOCTYPE html>
<body>
    <h1>Hello, ${fname[0]} ${lname[0]}!</h1>
</body>
</html>
Issues
  • Website's down

    Website's down

    The website returns a 404

    documentation 
    opened by virejdasani 4
  • How to configure https to work?

    How to configure https to work?

    Hi! When I start the project, I have an notice saying that "The Apache Tomcat Native library which allows using OpenSSL was not found on the java." This is no problem for me (it's a little bit anoying that it prints mt entire path after that, but no problem)

    But the real problem is when I try to point to my dfHttp as if it used https, so using "https://localhost:8080" instead of "http://localhost:8080" when this happens, it print an error and a stacktrace. I guess that this is not so intuitive for who is using image

    documentation question 
    opened by LuccaPrado 2
  • Feature Suggestion: Traffic interceptor

    Feature Suggestion: Traffic interceptor

    Hi, I really liked this project. I think that the "collect" mode could be more useful if it was somehow connected to some tunnel like (https://github.com/mukatee/java-tcp-tunnel), so the user could start the DeepfakeHTTP using collect to automatically generate requests and true responses from the server. I think that this would be really useful for testing some systems without depending on third party APIs/sites every time.

    enhancement 
    opened by LuccaPrado 1
  • Feature suggestion: reflect request

    Feature suggestion: reflect request

    I came across this as a testing tool. It's nice, thanks. Another testing desire I have occasionally is to run a one line webserver temporarily that just responds with a complete description of the request it received. A request mirror. To test both the construction of and transport of requests I guess. Wonder if this is a nice tool to add that too, or if another exists that I've not found.

    enhancement 
    opened by bernd-wechner 4
Releases(v1.0.6)
  • v1.0.6(Sep 9, 2021)

    • New CLI arg: --openapi-path (serve OpenAPI client at specified context path)
    • New CLI arg: --openapi-title (provide custom OpenAPI spec title)
    • New CLI arg: --print-requests (print dump requests to stdout)
    • New CLI arg: --print-info (print dump files statistics to stdout)
    • New CLI arg: --print-openapi (print OpenAPI specification to stdout)
    • New CLI arg: --format <json|yaml> (set output format for print-* options, default: json)
    • New CLI arg: --pretty (enable prettyprint for print-* options)
    • Minor bug fixes
    • Minor code enhancements
    • Documentation updated
    • Release on top of Tommy v10.0.8
    Source code(tar.gz)
    Source code(zip)
    df-1.0.6.jar(26.18 MB)
  • v1.0.5(Sep 2, 2021)

  • v1.0.4(Sep 2, 2021)

  • v1.0.3(Aug 31, 2021)

  • v1.0.2(Aug 21, 2021)

🔌 Simple library to manipulate HTTP requests/responses and capture network logs made by the browser using selenium tests without using any proxies

Simple library to manipulate HTTP requests and responses, capture the network logs made by the browser using selenium tests without using any proxies

Sudharsan Selvaraj 25 Sep 15, 2021
A headless browser written in Java.

A headless browser written in Java.

Osiris-Team 76 Sep 15, 2021
the mock backend for frontend applications

mockend the "mock backend" for Single Page Applications (SPAs) / Progressive Web Applications (PWAs). mockend was used to implement the "unidirectiona

Adam Bien 12 Jul 2, 2021
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

pact-jvm JVM implementation of the consumer driven contract library pact. From the Ruby Pact website: Define a pact between service consumers and prov

Pact Foundation 871 Sep 10, 2021
A browser automation framework and ecosystem.

Selenium Selenium is an umbrella project encapsulating a variety of tools and libraries enabling web browser automation. Selenium specifically provide

Selenium 21.7k Sep 18, 2021
Easy Setup Stub Server

Moco Moco is an easy setup stub framework. Latest Release 1.1.0 More details in Release Notes User Voice Let me know if you are using Moco. Join Moco

Zheng Ye 3.8k Sep 9, 2021
Layout and functional testing framework for websites

Galen Framework master: Galen is an open-source tool for testing layout and responsive design of web applications. It is also a powerfull functional t

Galen Framework 1.4k Aug 25, 2021
🎉Back end module of Sonic UI automation testing platform. Sonic-UI自动化测试平台后端模块。

?? Sonic UI automation testing platform. English | 简体中文 Background What is sonic ? Nowadays, automation testing, remote control and other technologies

Eason 13 Sep 13, 2021
Test if a request/response matches a given raml definition

raml-tester Test if a request/response matches a given raml definition. Versioning Version Contents 0.8.x Stable version, uses RAML parser 0.8.x and s

Stefan Niederhauser 70 May 19, 2021
The Enterprise-ready testing and specification framework.

Spock Framework Spock is a BDD-style developer testing and specification framework for Java and Groovy applications. To learn more about Spock, visit

Spock Framework 3k Sep 15, 2021
Clojure bindings for the Chromium Embedded Framework

clj-cef Clojure bindings for the Chromium Embedded Framework Dependency: Rationale From https://bitbucket.org/chromiumembedded/cef/src/master/ Some us

Adrian 35 Jul 4, 2021
XMLUnit for Java 2.x

XMLUnit for Java 2.x XMLUnit is a library that supports testing XML output in several ways. XMLUnit 2.x is a complete rewrite of XMLUnit and actually

XMLUnit 242 Sep 7, 2021
A tool for mocking HTTP services

WireMock - a web service test double for all occasions Key Features HTTP response stubbing, matchable on URL, header and body content patterns Request

Tom Akehurst 4.6k Sep 20, 2021
Enabling Test Automation in Java

SeLion Enabling Test Automation in Java SeLion builds on top of TestNG and Selenium to provide a set of capabilities that get you up and running with

PayPal 262 Sep 10, 2021
Cucumber DSL for testing RESTful Web Services

cukes-rest takes simplicity of Cucumber and provides bindings for HTTP specification. As a sugar on top, cukes-rest adds steps for storing and using r

C.T.Co 96 Jun 28, 2021
Threat Emulation and Red Teaming Framework.

The Remote Hacker Probe is a Remote Access and Post Exploitation Framework coded in C++/Java. Installation & Usage Download Java 11+. Most preferrably

QuantumCored 87 Sep 14, 2021
A Minestom extension that opens the port that the Minestom server is running on!

OpenPortStom A project that uses weupnp to forward the port for you when starting your server, it will also attempt to close the port. Yes this is a s

null 3 Sep 14, 2021
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

Testcontainers Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium we

null 5.2k Sep 14, 2021
Brings the popular ruby faker gem to Java

Java Faker This library is a port of Ruby's faker gem (as well as Perl's Data::Faker library) that generates fake data. It's useful when you're develo

DiUS Computing Pty Ltd 2.8k Sep 16, 2021