Every account signs in with SimpleLogin or a password now, so GitHub goes from the module, the shared app package, Learn and Todo, ahead of ADR 0017's GITHUB_SIGN_IN_ENDS. - halkyon_base: no `gitHubSignIn` endpoint, GitHub identity provider or GitHub refusals; no `githubClientId`/`githubClientSecret`, no `GITHUB_SIGN_IN_ENDS` and no `forgetGitHubAccounts`; the register loses `account-with-github`. `SignInWays.gitHub`, the basics' `gitHubClientId` and `gitHubSignInEnds`, and `PasswordRefusal`'s `signInAgain` and `noAddress` go. A first password takes a code mailed to the person's own address; an account without one sets none (`wrongCredentials`). - Learn's server: `instance.info()` without `gitHubClientId`, the pruning without GitHub, and `minimumAppBuild` 24, as builds up to 23 (v0.20.0) require `SignInWays.gitHub`: the server deploys with the release of build 24. - halkyon_app: no GitHub button or problems on the start screen, no password offered after a GitHub sign-in, and `ServerpodAuthGateway` without the browser half only GitHub used (`(client, base:)`). The account section offers a first password only to an account with an address. `LoopbackWebAuth` and the apps' schemes stay, SimpleLogin's ways back. - Learn's Profile lists no GitHub; the texts go (English, German). - Serverpod's `serverpod_auth_idp_github_account` stays, as its migrations make it; a row goes with its account, and ADR 0020's D36 gives operators the SQL to delete those left. - deploy/: compose.yaml and .env.example without GitHub. The READMEs, AGENTS.md files and ADR 0017 amended. BREAKING CHANGE: builds up to 23 can't read the instance's answers about an account's ways in; minimumAppBuild is 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
120 lines
3.7 KiB
Dart
120 lines
3.7 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:halkyon_app/halkyon_app.dart';
|
|
import 'package:halkyon_base_client/halkyon_base_client.dart';
|
|
import 'package:halkyon_oidc_flutter/halkyon_oidc_flutter.dart'
|
|
show OidcRefusal, OidcRefusedException;
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/testing.dart';
|
|
|
|
/// [refusal] as an instance sends it: named by its module.
|
|
String sent(SerializableException refusal) => jsonEncode({
|
|
'className': switch (refusal) {
|
|
EmailSignInRefusedException() => 'halkyon_base.EmailSignInRefusedException',
|
|
PasswordRefusedException() => 'halkyon_base.PasswordRefusedException',
|
|
OidcRefusedException() => 'halkyon_oidc.OidcRefusedException',
|
|
_ => throw ArgumentError.value(refusal),
|
|
},
|
|
'data': (refusal as SerializableModel).toJson(),
|
|
});
|
|
|
|
void main() {
|
|
test("reads the refusals an instance sends under halkyon_base's name, as "
|
|
"an app's own generated protocol does", () {
|
|
final protocol = BaseProtocol();
|
|
|
|
expect(
|
|
protocol.decodeWithType(
|
|
sent(
|
|
EmailSignInRefusedException(reason: EmailSignInRefusal.wrongCode),
|
|
),
|
|
),
|
|
isA<EmailSignInRefusedException>().having(
|
|
(refusal) => refusal.reason,
|
|
'reason',
|
|
EmailSignInRefusal.wrongCode,
|
|
),
|
|
);
|
|
expect(
|
|
protocol.decodeWithType(
|
|
sent(
|
|
PasswordRefusedException(reason: PasswordRefusal.wrongCredentials),
|
|
),
|
|
),
|
|
isA<PasswordRefusedException>().having(
|
|
(refusal) => refusal.reason,
|
|
'reason',
|
|
PasswordRefusal.wrongCredentials,
|
|
),
|
|
);
|
|
});
|
|
|
|
test("reads OpenID Connect's refusals under its own module's name, which "
|
|
"halkyon_base's SimpleLogin passes on", () {
|
|
expect(
|
|
BaseProtocol().decodeWithType(
|
|
sent(OidcRefusedException(reason: OidcRefusal.unknownAttempt)),
|
|
),
|
|
isA<OidcRefusedException>().having(
|
|
(refusal) => refusal.reason,
|
|
'reason',
|
|
OidcRefusal.unknownAttempt,
|
|
),
|
|
);
|
|
});
|
|
|
|
test("calls halkyon_base's endpoints at the instance, and passes its "
|
|
'refusals on as themselves', () async {
|
|
final asked = <String>[];
|
|
final client = BaseClient(
|
|
'https://learn.example.org/',
|
|
httpClientOverride: MockClient((request) async {
|
|
asked.add(request.url.toString());
|
|
return switch (request.url.path) {
|
|
'/halkyon_base.instance/basics' => http.Response(
|
|
jsonEncode(
|
|
InstanceBasics(
|
|
app: 'learn',
|
|
emailSignIn: true,
|
|
sourceCodeUrl: 'https://code.example.org/learn',
|
|
minimumAppBuild: 21,
|
|
dataLocation: 'EU',
|
|
).toJson(),
|
|
),
|
|
200,
|
|
),
|
|
'/halkyon_base.passwordSignIn/begin' => http.Response(
|
|
sent(
|
|
PasswordRefusedException(
|
|
reason: PasswordRefusal.tooManyAttempts,
|
|
),
|
|
),
|
|
400,
|
|
),
|
|
_ => http.Response('', 404),
|
|
};
|
|
}),
|
|
);
|
|
addTearDown(client.close);
|
|
|
|
final basics = await client.modules.instance.basics();
|
|
expect(basics.emailSignIn, isTrue);
|
|
expect(basics.minimumAppBuild, 21);
|
|
expect(basics.dataLocation, 'EU');
|
|
await expectLater(
|
|
client.modules.passwordSignIn.begin(address: 'anna@example.org'),
|
|
throwsA(
|
|
isA<PasswordRefusedException>().having(
|
|
(refusal) => refusal.reason,
|
|
'reason',
|
|
PasswordRefusal.tooManyAttempts,
|
|
),
|
|
),
|
|
);
|
|
expect(asked, [
|
|
'https://learn.example.org/halkyon_base.instance/basics',
|
|
'https://learn.example.org/halkyon_base.passwordSignIn/begin',
|
|
]);
|
|
});
|
|
}
|