as method

GisilaTestClient as(
  1. Principal principal
)

A client authenticated as principal. The app's authenticator must be a TestAuthenticator.

Implementation

GisilaTestClient as(Principal principal) {
  final auth = _authenticator;
  if (auth is! TestAuthenticator) {
    throw StateError('GisilaTestClient.as() needs '
        'AppConfig(authenticator: TestAuthenticator(...)); the app uses '
        '${auth?.runtimeType ?? 'no GisilaApp'}. Use withToken() with a '
        'real token instead.');
  }
  return withToken(auth.tokenFor(principal));
}