mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-11 19:34:02 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
// Bearer tokens are checked against sha256 hashes in the tokens file, re-read
|
|
// per request so revoking a line takes effect without a restart; the Host
|
|
// check admits loopback and the public proxy name only.
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'mcp_harness.dart';
|
|
|
|
void main() {
|
|
late McpHarness h;
|
|
|
|
setUp(() async {
|
|
h = McpHarness();
|
|
await h.start();
|
|
});
|
|
tearDown(() => h.dispose());
|
|
|
|
const ok = 'Bearer ${McpHarness.token}';
|
|
|
|
test('a listed token is admitted', () async {
|
|
expect(await h.rawInitialize({'authorization': ok}), 200);
|
|
});
|
|
|
|
test('no token or a wrong token is refused', () async {
|
|
expect(await h.rawInitialize({}), anyOf(401, 403));
|
|
expect(
|
|
await h.rawInitialize({'authorization': 'Bearer nope'}),
|
|
anyOf(401, 403),
|
|
);
|
|
});
|
|
|
|
test('removing the line revokes without a restart', () async {
|
|
h.tokens.writeAsStringSync('# revoked\n');
|
|
expect(await h.rawInitialize({'authorization': ok}), anyOf(401, 403));
|
|
});
|
|
|
|
test('a missing tokens file admits nobody', () async {
|
|
h.tokens.deleteSync();
|
|
expect(await h.rawInitialize({'authorization': ok}), anyOf(401, 403));
|
|
});
|
|
|
|
test('the proxy host is admitted, a foreign host is not', () async {
|
|
expect(
|
|
await h.rawInitialize({
|
|
'authorization': ok,
|
|
'host': 'todo.kuhy.duckdns.org',
|
|
'origin': 'https://todo.kuhy.duckdns.org',
|
|
}),
|
|
200,
|
|
);
|
|
expect(
|
|
await h.rawInitialize({'authorization': ok, 'host': 'evil.example'}),
|
|
anyOf(400, 403),
|
|
);
|
|
});
|
|
}
|