restSessionAppTest function
The test of the requests of the users of the session that the CLI keeps in
its app_tests/rest_session, for the apps with the REST role and the auth
role, whichever modules provide them, that among accepts, or all of them,
in each mode of the auth role. It runs the start-up of the app, and each
request in real time in a widget test:
- a request of the user of an account carries the token of the session, and one without an account what the mode of the app says;
- after a sign-out, a request carries no token of the user who left;
- requests that a server refuses at the same time share one refresh, and each repeats once;
- a refresh that fails for the network is the reason
network, and a session that ended on the server isunauthorized, with nobody signed in; - a request of one user does not repeat as the next user;
- a second 401 is
unauthorized, and signs nobody out.
It is a test of the REST role, whose template reads the token of the
session. It reads the mode of the app from authMode of the app, so the
matrix fills in nothing, and it uses the helpers of the test of the auth
role, which every such app has. It has no probe for the start check: nobody
can sign in on a device.
Implementation
Future<MatrixAppTest> restSessionAppTest({
bool Function(MatrixApp app)? among,
}) async =>
MatrixAppTest(
'${await appTestsDirectoryOf('smf_flutter_cli')}/rest_session',
appliesTo: (app) =>
app.hook!.presentRoles.containsAll({restRole, authRole}) &&
(among?.call(app) ?? true),
roles: {restRole},
);