DebugAppCheckTestHelper

public final class DebugAppCheckTestHelper


Helper class for using DebugAppCheckProviderFactory in integration tests.

Example Usage:

@RunWith(AndroidJunit4.class)
public class MyTests {
  private final DebugAppCheckTestHelper debugAppCheckTestHelper =
      DebugAppCheckTestHelper.fromInstrumentationArgs();

  @Test
  public void testWithDefaultApp() {
    debugAppCheckTestHelper.withDebugProvider(() -> {
      // Test code that requires a debug AppCheckToken
    });
  }

  @Test
  public void testWithNonDefaultApp() {
    debugAppCheckTestHelper.withDebugProvider(
        FirebaseApp.getInstance("nonDefaultApp"),
        () -> {
          // Test code that requires a debug AppCheckToken
        });
  }
}
// In build.gradle.kts
android {
  defaultConfig {
    System.getenv("FIREBASE_APP_CHECK_DEBUG_SECRET")?.let { token ->
      testInstrumentationRunnerArguments(
          mapOf("firebaseAppCheckDebugSecret" to token))
    }
  }
}

Summary

Nested types

Public methods

static @NonNull DebugAppCheckTestHelper

Creates a DebugAppCheckTestHelper instance with a debug secret obtained from InstrumentationRegistry arguments.

void

Installs a DebugAppCheckProviderFactory to the default FirebaseApp and runs the test code in runnable.

void
<E extends Throwable> withDebugProvider(
    @NonNull FirebaseApp firebaseApp,
    @NonNull DebugAppCheckTestHelper.MaybeThrowingRunnable<E> runnable
)

Installs a DebugAppCheckProviderFactory to the provided FirebaseApp and runs the test code in runnable.

Public methods

fromInstrumentationArgs

public static @NonNull DebugAppCheckTestHelper fromInstrumentationArgs()

Creates a DebugAppCheckTestHelper instance with a debug secret obtained from InstrumentationRegistry arguments.

withDebugProvider

public void <E extends Throwable> withDebugProvider(
    @NonNull DebugAppCheckTestHelper.MaybeThrowingRunnable<E> runnable
)

Installs a DebugAppCheckProviderFactory to the default FirebaseApp and runs the test code in runnable.

Throws
com.google.firebase.appcheck.debug.testing.DebugAppCheckTestHelper com.google.firebase.appcheck.debug.testing.DebugAppCheckTestHelper

withDebugProvider

public void <E extends Throwable> withDebugProvider(
    @NonNull FirebaseApp firebaseApp,
    @NonNull DebugAppCheckTestHelper.MaybeThrowingRunnable<E> runnable
)

Installs a DebugAppCheckProviderFactory to the provided FirebaseApp and runs the test code in runnable.

Throws
com.google.firebase.appcheck.debug.testing.DebugAppCheckTestHelper com.google.firebase.appcheck.debug.testing.DebugAppCheckTestHelper