halkyon/packages/halkyon_base_server/test/unit/offered_ways_test.dart
Tizian 「ティツィアーン」 42d06f7ee8
feat(base): signing in with SimpleLogin through the register (ADR 0020, step 2)
The `simpleLogin` endpoint on halkyon_oidc's SimpleLogin preset: `begin`
for the app and platform (the state's marker for the forwarding page), at
most 30 an hour per network; `complete` with SimpleLogin's code, signed out
a session for the account with that SimpleLogin ID, signed in SimpleLogin
added to the caller's account, who becomes identified and anonymous no
longer. Someone new gets no account yet: their identity waits 30 minutes
under the attempt's ID (D16), with a handle suggested from their name,
`anna_mueller` (D17), for the sign-up of step 3.

The register alone holds the instance's SimpleLogin app
(`simpleLoginClientId`, `simpleLoginClientSecret`) and exchanges codes; a
member asks it for both steps and issues its own session. `SIGN_IN_WAYS`
says which ways the register offers, the instance's basics and the ways
in carry `simpleLogin`, GitHub links nobody more where SimpleLogin is
offered, and Learn's and Todo's pruning forgets the unfinished sign-ins
hourly. No migration: the tables are halkyon_oidc's, already in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-24 09:17:48 +02:00

32 lines
1 KiB
Dart

import 'package:halkyon_base_server/base.dart';
import 'package:test/test.dart';
// SIGN_IN_WAYS (ADR 0020, 1): the ways in an operator offers.
void main() {
test('unset or empty, every way whose keys are there', () {
expect(offeredWaysFrom(null), isNull);
expect(offeredWaysFrom(''), isNull);
expect(offeredWaysFrom(' '), isNull);
});
test('names one way or both, by commas or spaces, whatever their case', () {
expect(offeredWaysFrom('simplelogin'), {OfferedWay.simpleLogin});
expect(offeredWaysFrom('password'), {OfferedWay.password});
expect(offeredWaysFrom('password, SimpleLogin'), {
OfferedWay.password,
OfferedWay.simpleLogin,
});
expect(offeredWaysFrom('simplelogin password'), hasLength(2));
});
test('refuses a way it does not know, so the server stops as it starts', () {
for (final value in ['github', 'simplelogin,email', 'passwords']) {
expect(
() => offeredWaysFrom(value),
throwsA(isA<StateError>()),
reason: value,
);
}
});
}