utils/crdt_sync_dart/test/encrypting_store_bulk_test.dart
Krzysztof kuhy Rudnicki c29d0989dd Clear inherited CI debt in the Python libs
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>
2026-11-16 08:58:01 +01:00

54 lines
1.5 KiB
Dart

/// EncryptingStore.getStringMap on a data dir that also holds non-log
/// entries and unreadable ones.
library;
import 'package:crdt_sync/crdt_sync.dart';
import 'package:test/test.dart';
import 'e2e_fakes.dart';
const _old = 'settings-sync';
void main() {
final layout = E2eLayout.of(_old);
Future<E2eKey> key(RemoteStore remote) => unlockE2e(
store: remote,
pathPrefix: layout.prefix,
passphrase: 'pw',
params: cheapArgon,
e2ePath: layout.e2ePath,
);
EncryptingStore open(
MemoryRemote remote,
E2eKey k, {
bool acceptPlaintext = true,
}) => EncryptingStore(
remote,
k,
pathPrefix: layout.prefix,
revsPath: layout.revsPath,
e2ePath: layout.e2ePath,
acceptPlaintext: acceptPlaintext,
);
test('the header inside the prefix passes through undecrypted', () async {
final remote = MemoryRemote();
final store = open(remote, await key(remote));
final log = encodeLog(logOf({'a': 'secret'}));
await store.putFileText('${layout.prefix}/node.json', log, message: 'm');
final map = await store.getStringMap(layout.prefix);
expect(map['e2e'], remote.files[layout.e2ePath]);
expect(map['node.json'], log);
});
test('an unreadable entry is dropped from the bulk read', () async {
final remote = MemoryRemote();
final store = open(remote, await key(remote), acceptPlaintext: false);
remote.files['${layout.prefix}/old.json'] = encodeLog(logOf({'a': 'x'}));
final map = await store.getStringMap(layout.prefix);
expect(map.containsKey('old.json'), isFalse);
});
}