TestHarnessAuthMixin<T extends ApplicationChannel> class Null safety

Use methods from this class to test applications that use AuthServer for authentication & authorization.

This class is mixed in to your TestHarness subclass to provide test utilities for applications that use OAuth2.

Methods from this class add client identifiers and authenticate users for the purpose of executing authenticated requests in your tests.

You must override authServer to return your application's AuthServer service, and application to return your harness' application.

This mixin is typically used with TestHarnessORMMixin and package:aquedart/managed_auth. Invoke addClient in TestHarnessORMMixin.seed to add OAuth2 clients that will survive TestHarnessORMMixin.resetData.

    class Harness extends TestHarness<MyChannel>
      with TestHarnessManagedAuthMixin<MyChannel>, TestHarnessORMMixin {
        Agent publicAgent;

        @override
        AuthServer get authServer => channel.authServer;

        @override
        Application<T> get application => channel.application;

        Future seed() async {
          // Create a new OAuth2 client that users can authenticate with
          publicAgent = await addClient("com.public.client");
        }
    }
Implemented types

Constructors

TestHarnessAuthMixin()

Properties

agent Agent?
The default Agent that makes requests to the application being tested.
read / write, inherited
application Application<T>?
The application being tested. [...]
read-only, inherited
authServer AuthServer?
Must override to return authServer of application under test. [...]
read-only
channel → T
The channel of the running application. [...]
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
options ApplicationOptions
Application options for the application being tested. [...]
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addClient(String id, {String? secret, String? redirectUri, List<String>? allowedScope}) Future<Agent>
Creates a new OAuth2 client identifier and returns an Agent that makes requests on behalf of that client. [...]
afterStart() Future
Override this method to provide post-startup behavior for the application under test. [...]
inherited
beforeStart() Future
Override this method to provide configuration for the application under test. [...]
inherited
install({bool restartForEachTest = false}) → void
Installs this handler to automatically start before tests begin running, [...]
inherited
loginUser(Agent fromAgent, String username, String password, {List<String>? scopes}) Future<Agent>
Authenticates a user for username and password. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
onSetUp() Future
Override this method to register a setUp closure. [...]
inherited
onTearDown() Future
Override this method to register a tearDown closure. [...]
inherited
start() Future
Initializes a test application and starts it. [...]
inherited
stop() Future
Stops the test application from running. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited