Digits Sandbox

Digits wants to simplify your testing by providing the Digits Sandbox.

Developers can use the Digits Sandbox to test Authentication, Find Friends and Invite Friends without a network connection and mock both success and error states. Now you can add Digits tests on CI or test your Digits flows as often as you want without triggering rate limits, requiring a legitimate test phone number, creating test contacts, or requiring a manual code entry step.

Getting Started

By default, the Sandbox immediately triggers your completion callback with a success result.

This is done by making the request to enable/disable Sandbox mode:

Digits.enableSandbox();

In Digits’ Authentication, we return a dummy user’s auth token. Note: This token is not a valid token, and any requests to the Digits service using this token will fail.

For the Find Friends workflow, we provide a Contacts Upload flow that will bypass uploading your contacts to the service. When you lookup matches, the Sandbox returns two matching friend ids. Note: These ids are not valid user ids, and should not be preserved as legitimate contacts outside of development.

See our sample app’s Digits Main Activity and the toggleSandboxButton for an example.

Advanced

The Advanced Sandbox allows you to step through the various Digits workflows, and pre-define responses from the Digits service.

We have provided com.digits.sdk.android.MockApiInterface to get you started. It mocks out the requests to the Digits service, following the happy path in all cases, and the Authentication flow returns a dummy user’s auth token. In the case of Find Friends, we provide two pages of friend matches, to simulate the paging workflow. Note: This token is not a valid token, and any requests to the Digits service using this token will fail. Also, the user ids returned are not valid user ids, and should not be preserved as legitimate contacts outside of development.

Feel free to extend com.digits.sdk.android.ApiInterface to provide specific canned data and/or auth tokens. Once you have your mock interface, create a new com.digits.sdk.android.SandboxConfig and update your Digits instance:

public class MyApiInterfaceImpl extends ApiInterface {
  public void account(String phoneNumber,
                      String numericPin,
                      Callback<DigitsUser> cb) {
    // ...
  }
}

SandboxConfig mySandbox = new SandboxConfig(true, SandboxConfig.Mode.ADVANCED, new MyApiInterfaceImpl())
Digits.setSandboxConfig(mySandbox);

Now when you enable/disable Sandbox, MyApiInterfaceImpl will be used to mock the workflow responses.

See our sample app’s Digits Main Activity for examples of the SandboxConfig.