Betamax is a tool for mocking external HTTP resources such as web services and REST APIs in your tests. The project was inspired by the VCR library for Ruby.
Groovy Java Scala
Latest commit 30f29db May 28, 2017 @cowboygneox cowboygneox Abandoning the project.
Permalink
Failed to load latest commit information.
betamax-core Removing support for external files due to the Tika dependency and be… Jan 5, 2017
betamax-junit Replace java.utils.logging with SLF4J Dec 20, 2016
betamax-specs2_2.11 Combining Configuration and ProxyConfiguration together since they pr… Jun 18, 2016
betamax-tests Refactoring the HttpsChannelInitialzier to use CertificateSniffingMit… Jan 21, 2017
config/codenarc Removed some unused classes and fixed more codenarc violations Sep 22, 2012
example Fix the example scala app to be updated with the released version 2.0.1 Jan 24, 2017
gradle Preparing for a 2.0.0 release. Jun 20, 2016
.gitignore Refactoring SSL to use a Betamax Root Certificate. Jun 17, 2016
.travis.yml Fixing uploadArchives to upload a JDK7 compatible version. Jan 4, 2017
Dockerfile-jdk7 #224 Fixing the 'sed' command that fixes the SecureRandom to be Mac-c… Jan 3, 2017
Dockerfile-jdk8 #224 Fixing the 'sed' command that fixes the SecureRandom to be Mac-c… Jan 3, 2017
LICENSE added ASL2 license Aug 22, 2011
betamax.gradle Removing support for external files due to the Tika dependency and be… Jan 5, 2017
betamax.jks Extending the life of the Betamax CA for 20 years. That should be ple… Jun 19, 2016
betamax.key Refactoring SSL to use a Betamax Root Certificate. Jun 17, 2016
betamax.p12 Extending the life of the Betamax CA for 20 years. That should be ple… Jun 19, 2016
betamax.pem Extending the life of the Betamax CA for 20 years. That should be ple… Jun 19, 2016
gradlew Updating to gradle 2.11 Feb 14, 2016
gradlew.bat Updating to gradle 2.11 Feb 14, 2016
readme.md Abandoning the project. May 28, 2017
settings.gradle Adding the first pass at a specs2 module. Feb 14, 2016
todo.md todo updates Oct 29, 2013

readme.md

βetamax Build Status Join the chat at https://gitter.im/betamaxteam/betamax

Betamax is a tool for mocking external HTTP resources in your tests. The project was inspired by the VCR library for Ruby.

This project currently has no maintainer. The ambitious 2.X release turned out to be architectually flawed, difficult to use, and even more difficult to accurately document. 2.X is essentially a failure and has been abandoned.

Documentation hosted at http://betamax.software/ is currently only for the 1.X branch and is deprecated. New documentation is being produced, but it will take some time. Please see examples in Betamax's tests and follow this readme.

In an effort to refocus the project and do some house-keeping, all relevant work has been moved to our Trello board. If you'd like to see what we're doing and where we're going with the project, please check it out!

Installation

Since 2.0.1, requires JDK7 or later.

Betamax is hosted via Sonatype and is intended to be compatible with any Maven-based build tool.

JUnit

<dependency>
  <groupId>software.betamax</groupId>
  <artifactId>betamax-junit</artifactId>
  <version>2.0.1</version>
  <scope>test</scope>
</dependency>

Specs2 Maven

<dependency>
  <groupId>software.betamax</groupId>
  <artifactId>betamax-specs2_2.11</artifactId>
  <version>2.0.1</version>
  <scope>test</scope>
</dependency>

Specs2 SBT

libraryDependencies += "software.betamax" %% "betamax-specs2" % "2.0.1" % "test"

Snapshots:

Snapshots are made after every successful build in master, so if you want the bleeding edge, you know where to get it.

SSL Configuration

JDK 7 dramatically increased the security of the JVM, making it much more difficult to exploit man-in-the-middle attacks. Because Betamax is a legitimate use of MITM, it is necessary to configure the environment to allow Betamax to do so. This will be accomplished by installing a Betamax certificate-authority into Java's cacerts which will allow Betamax to generate a mock-SSL certificate for any site.

For all environments where tests are being run, a one-time installation of the Betamax certificate into Java's cacerts is necessary.

keytool -importcert -keystore $JAVA_HOME/jre/lib/security/cacerts -file betamax.pem -alias betamax -storepass changeit -noprompt

Notes:

  1. sudo will likely be required for unix-based operating systems
  2. betamax.pem is included in the betamax-core.jar, but it's probably best to pull it from GitHub.
  3. betamax.pem shouldn't have a need to change for the foreseeable future, so this installation should last for the life of the tests.

SecureRandom requires a significant amount of entropy in order to generate random numbers, and when using SSL, Betamax stresses this aggressively. When SecureRandom fails to generate a random in a given time frame (usually around 3 seconds), a test will fail with almost no indiciation as to why, other than an SSL error occurred. It is likely best to get ahead of that issue before it becomes one, especially if your CI environment is Docker/Virtual Machine based.

To ensure SecureRandom will have adequate entropy on Unix-based systems:

sed -i -e 's/securerandom.source=file:\/dev\/random/securerandom.source=file:\/dev\/urandom/' $JAVA_HOME/jre/lib/security/java.security

Files to Ignore:

Betamax generates files with the following extensions that should not be committed to source control:

  • *.csr
  • *.cert
  • *.jks

Continuous Integration Considerations:

For Docker users, please use the JDK images hosted on Docker Hub; they have the Betamax CA installed and ready to go.

For Travis CI users, please see Betamax's .travis.yml. As of writing, sudo:required is necessary in order to install the CA. Hopefully this won't be the case in the future.

For all other CI environments, be sure to use the keytool command listed above to ensure the Betamax CA is installed.

Contributors

Betamax Team

Additional Contributions (sorted alphabetically by last name)

  • Marcin Erdmann
  • Ian Grayson
  • Russel Hart
  • Lari Hotari
  • Michal Kováč
  • David Kowis
  • Jason LeCount
  • Peter Ledbrook
  • George McIntosh
  • James Newbery
  • Ryan Schmitt
  • Michael Vorburger
  • Alex Ianus

Note: There were 3 others who didn't appropriately identify themselves via Git, and thus are not on this list.