Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
66 lines
2.4 KiB
Dart
66 lines
2.4 KiB
Dart
import 'package:cutdex/diagnostics/diagnostic_redactor.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('redacts nested credentials, content, paths and URLs while preserving metrics', () {
|
|
final redactor = DiagnosticRedactor();
|
|
final safe =
|
|
redactor.value({
|
|
'nested': {
|
|
'api_key': 'secret',
|
|
'accessToken': 'secret',
|
|
'prompt': 'private text',
|
|
},
|
|
'message':
|
|
'sk-12345abc Bearer abc123 https://u:p@host/path?q=secret',
|
|
'unix': '/Users/person/Media/private.mov',
|
|
'windows': r'C:\Users\person\Media\private.mov',
|
|
'inputTokens': 25,
|
|
'outputTokens': 10,
|
|
'nativeCode': '-11841',
|
|
})!
|
|
as Map;
|
|
expect(safe['nested'], {
|
|
'api_key': '[redacted]',
|
|
'accessToken': '[redacted]',
|
|
'prompt': '[redacted]',
|
|
});
|
|
expect(safe['message'], isNot(contains('abc123')));
|
|
expect(safe['message'], isNot(contains('q=secret')));
|
|
expect(safe['unix'], '[local-path]');
|
|
expect(safe['windows'], '[local-path]');
|
|
expect(safe['inputTokens'], 25);
|
|
expect(safe['outputTokens'], 10);
|
|
expect(safe['nativeCode'], '-11841');
|
|
});
|
|
|
|
test('marker fast paths preserve every existing redaction rule', () {
|
|
final redactor = DiagnosticRedactor();
|
|
final cases = {
|
|
'identifier-123': 'identifier-123',
|
|
'BEARER credential': 'Bearer [redacted]',
|
|
'sk-credential': '[redacted]',
|
|
'PASSWORD=credential': 'PASSWORD=[redacted]',
|
|
'api-key: credential': 'api-key=[redacted]',
|
|
'https://user:credential@example.com/path?q=credential':
|
|
'http[local-path]',
|
|
'credential@private.example': '[email]',
|
|
r'C:\Users\person\credential.mov': '[local-path]',
|
|
r'\\server\share\credential.mov': '[local-path]',
|
|
'/Users/person/credential.mov': '[local-path]',
|
|
};
|
|
for (final entry in cases.entries) {
|
|
expect(redactor.text(entry.key), entry.value);
|
|
}
|
|
});
|
|
|
|
test('bounds recursion, strings and lists', () {
|
|
final redactor = DiagnosticRedactor();
|
|
expect(redactor.text('x' * 10000).length, lessThan(8300));
|
|
expect(redactor.value(List.filled(10000, 1)), hasLength(2048));
|
|
final cyclic = <String, Object?>{};
|
|
cyclic['self'] = cyclic;
|
|
expect(redactor.value(cyclic).toString(), contains('[truncated]'));
|
|
});
|
|
}
|