fix(app)!: instances over plain HTTP are refused, but on this machine
What the app sends an instance (the proofs that sign in, the keys' wrappings, every request a session carries) must not be read or changed on the way, so an instance is reached over HTTPS, or over plain HTTP only on this machine (localhost, 127.0.0.0/8, ::1), as Jellyfin servers are. An address over plain HTTP elsewhere is refused before anything is sent there. One kept from before is never opened: the app says why, and offers another instance or removing it from the device, never dropping it silently. Development builds still use their own instance over HTTP (an emulator reaches the developer's machine as 10.0.2.2); releases never. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
a0b7e2bf18
commit
4914df348e
1 changed files with 338 additions and 2 deletions
|
|
@ -83,4 +83,69 @@ void main() {
|
|||
|
||||
expect(changes, 4);
|
||||
});
|
||||
|
||||
test('allows an instance reached securely, and over plain HTTP elsewhere '
|
||||
"only the build's own in a development build", () {
|
||||
final insecure = Instance.parse('http://10.0.2.2:8080')!;
|
||||
// A development build, as tests run.
|
||||
final development = InstanceChoice(
|
||||
store,
|
||||
builtIn: insecure,
|
||||
forget: (instance) async {},
|
||||
);
|
||||
expect(development.allows(builtIn), isTrue);
|
||||
expect(
|
||||
development.allows(Instance.parse('http://localhost:8080')!),
|
||||
isTrue,
|
||||
);
|
||||
expect(development.allows(insecure), isTrue);
|
||||
expect(
|
||||
development.allows(Instance.parse('http://learn.example.org')!),
|
||||
isFalse,
|
||||
);
|
||||
|
||||
final release = InstanceChoice(
|
||||
store,
|
||||
builtIn: insecure,
|
||||
forget: (instance) async {},
|
||||
allowsInsecureBuiltIn: false,
|
||||
);
|
||||
expect(release.allows(insecure), isFalse);
|
||||
});
|
||||
|
||||
test('leaves an instance it no longer allows for another, forgetting it '
|
||||
'if asked', () async {
|
||||
final insecure = Instance.parse('http://learn.example.net')!;
|
||||
store = MemoryInstanceStore((
|
||||
current: insecure,
|
||||
known: [other, insecure, builtIn],
|
||||
));
|
||||
final instances = choice();
|
||||
await instances.load(usedBefore: false);
|
||||
expect(instances.current, insecure, reason: 'never dropped silently');
|
||||
|
||||
await instances.leave(insecure, forget: false);
|
||||
expect(instances.current, other, reason: 'the first allowed one');
|
||||
expect(instances.known, [other, insecure, builtIn]);
|
||||
expect(forgotten, isEmpty);
|
||||
|
||||
await instances.use(insecure);
|
||||
await instances.leave(insecure, forget: true);
|
||||
expect(instances.current, other);
|
||||
expect(instances.known, [other, builtIn]);
|
||||
expect(forgotten, [insecure]);
|
||||
expect(store.kept?.known, [other, builtIn]);
|
||||
});
|
||||
|
||||
test("leaving the only one goes to the build's own", () async {
|
||||
final insecure = Instance.parse('http://learn.example.net')!;
|
||||
store = MemoryInstanceStore((current: insecure, known: [insecure]));
|
||||
final instances = choice();
|
||||
await instances.load(usedBefore: false);
|
||||
|
||||
await instances.leave(insecure, forget: true);
|
||||
expect(instances.current, builtIn);
|
||||
expect(instances.known, [builtIn]);
|
||||
expect(forgotten, [insecure]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue