mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-17 23:05:07 +01:00
main was red on file length, the noqa ban, codespell, test naming and dart coverage; this change touches every one of those jobs. - sickdays: set_enabled is keyword-only; the panel test splits in two with shared probes; the sync wire format moves to DOCS-sync.md. - earned_time: _focus types the project as a Protocol, no noqa; the gate-maturity section moves to DOCS-maturity.md; codespell knows the `checkin` event name. - focus_project: real fixes for every noqa (local-day clocks, typed fakes, logged broad catches, split helpers). The public API that focus-guard calls keeps its signatures; their PLR0913 exemption lives in pyproject with the reason, not in noqa. - crdt-sync: pylint gets nacl/argon2, docstrings, and allows the public E2eLayout.of; _blobs moves to _e2e_blobs.py. - crdt_sync_dart: Argon2Params and the header errors move to e2e_params.dart (re-exported); tests split and reach 100% lines. - sql_drills: test helpers get a leading underscore, as in earned_time. Todo: fda71ed1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
/// EncryptingStore forwards what it does not seal to the inner store.
|
|
library;
|
|
|
|
import 'package:crdt_sync/crdt_sync.dart';
|
|
import 'package:glados/glados.dart' show Random;
|
|
import 'package:test/test.dart';
|
|
|
|
import 'e2e_fakes.dart';
|
|
|
|
const _prefix = 'todo-sync/notes';
|
|
const _revs = 'todo-sync/revs';
|
|
|
|
Future<E2eKey> _key(MemoryRemote remote, [String passphrase = 'pw']) =>
|
|
unlockE2e(
|
|
store: remote,
|
|
pathPrefix: _prefix,
|
|
passphrase: passphrase,
|
|
params: cheapArgon,
|
|
random: Random(1),
|
|
);
|
|
|
|
void main() {
|
|
test('paths outside the prefix pass through untouched', () async {
|
|
final remote = MemoryRemote();
|
|
final store = EncryptingStore(
|
|
remote,
|
|
await _key(remote),
|
|
pathPrefix: _prefix,
|
|
);
|
|
await store.putFileText('other/x', '{"a":1}', message: 'm');
|
|
expect(remote.files['other/x'], '{"a":1}');
|
|
expect(await store.getFileText('other/x'), '{"a":1}');
|
|
expect(await store.getFileText('$_prefix/none/log.json'), isNull);
|
|
});
|
|
|
|
group('delegation', () {
|
|
test('bulk reads forward when the inner store has them', () async {
|
|
final remote = MemoryRemote({'$_revs/a': 'r'});
|
|
final store = EncryptingStore(
|
|
remote,
|
|
await _key(remote),
|
|
pathPrefix: _prefix,
|
|
);
|
|
expect(await store.getStringMap(_revs), {'a': 'r'});
|
|
});
|
|
|
|
test('bulk reads degrade to "fetch everything" without them', () async {
|
|
final remote = MemoryRemote({'$_revs/a': 'r'});
|
|
final store = EncryptingStore(
|
|
PlainRemote(remote),
|
|
await _key(remote),
|
|
pathPrefix: _prefix,
|
|
);
|
|
expect(await store.getStringMap(_revs), isEmpty);
|
|
});
|
|
|
|
test('list, delete, access and close reach the inner store', () async {
|
|
final remote = MemoryRemote({'$_prefix/a/log.json': '{}'});
|
|
final store = EncryptingStore(
|
|
remote,
|
|
await _key(remote),
|
|
pathPrefix: _prefix,
|
|
);
|
|
expect(await store.listDirectory(_prefix), ['a']);
|
|
await store.deleteFile('$_prefix/a/log.json', message: 'm');
|
|
expect(remote.files.containsKey('$_prefix/a/log.json'), isFalse);
|
|
expect(await store.canAccessRemote(), isTrue);
|
|
store.close();
|
|
expect(remote.closed, isTrue);
|
|
});
|
|
});
|
|
}
|