From 9974b10cd70114331938927417fad1560022bca1 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Tue, 18 Aug 2020 14:31:04 +0200 Subject: [PATCH] improve test for kdbx4 --- dart_test.yaml | 3 +++ test/icon/kdbx_customicon_test.dart | 3 +-- test/internal/test_utils.dart | 4 ++++ test/kdbx_history_test.dart | 3 +-- test/kdbx_upgrade_test.dart | 11 ++++++++--- 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 dart_test.yaml diff --git a/dart_test.yaml b/dart_test.yaml new file mode 100644 index 0000000..d89c09d --- /dev/null +++ b/dart_test.yaml @@ -0,0 +1,3 @@ +tags: + kdbx3: {} + kdbx4: {} diff --git a/test/icon/kdbx_customicon_test.dart b/test/icon/kdbx_customicon_test.dart index d6462f2..c0c8582 100644 --- a/test/icon/kdbx_customicon_test.dart +++ b/test/icon/kdbx_customicon_test.dart @@ -1,10 +1,9 @@ -import 'package:logging_appenders/logging_appenders.dart'; import 'package:test/test.dart'; import '../internal/test_utils.dart'; void main() { - PrintAppender.setupLogging(); + TestUtil.setupLogging(); test('load custom icons from file', () async { final file = await TestUtil.readKdbxFile('test/icon/icontest.kdbx'); final entry = file.body.rootGroup.entries.first; diff --git a/test/internal/test_utils.dart b/test/internal/test_utils.dart index 12735af..f81d671 100644 --- a/test/internal/test_utils.dart +++ b/test/internal/test_utils.dart @@ -5,12 +5,16 @@ import 'dart:typed_data'; import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:kdbx/kdbx.dart'; import 'package:logging/logging.dart'; +import 'package:logging_appenders/logging_appenders.dart'; final _logger = Logger('test_utils'); class TestUtil { static final keyTitle = KdbxKey('Title'); + static void setupLogging() => + PrintAppender.setupLogging(stderrLevel: Level.WARNING); + static KdbxFormat kdbxFormat() { Argon2.resolveLibraryForceDynamic = true; return KdbxFormat(Argon2FfiFlutter(resolveLibrary: (path) { diff --git a/test/kdbx_history_test.dart b/test/kdbx_history_test.dart index 5df2dac..3dad37f 100644 --- a/test/kdbx_history_test.dart +++ b/test/kdbx_history_test.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:kdbx/kdbx.dart'; -import 'package:logging_appenders/logging_appenders.dart'; import 'package:quiver/core.dart'; import 'package:test/test.dart'; @@ -47,7 +46,7 @@ class StreamExpect { } void main() { - PrintAppender.setupLogging(); + TestUtil.setupLogging(); group('test history for values', () { test('check history creation', () async { final file = await TestUtil.readKdbxFile('test/keepass2test.kdbx'); diff --git a/test/kdbx_upgrade_test.dart b/test/kdbx_upgrade_test.dart index 4f6c4ee..6f31d08 100644 --- a/test/kdbx_upgrade_test.dart +++ b/test/kdbx_upgrade_test.dart @@ -1,11 +1,11 @@ +import 'package:kdbx/kdbx.dart'; import 'package:kdbx/src/kdbx_header.dart'; -import 'package:logging_appenders/logging_appenders.dart'; import 'package:test/test.dart'; import 'internal/test_utils.dart'; void main() { - PrintAppender.setupLogging(); + TestUtil.setupLogging(); group('Test upgrade from v3 to v4', () { final format = TestUtil.kdbxFormat(); test('Read v3, write v4', () async { @@ -16,6 +16,11 @@ void main() { final v4 = await TestUtil.saveAndRead(file); expect(v4.header.version, KdbxVersion.V4); await TestUtil.saveTestOutput('kdbx4upgrade', v4); + }, tags: 'kdbx3'); + test('kdbx4 is the new default', () async { + final file = + format.create(Credentials(ProtectedValue.fromString('asdf')), 'test'); + expect(file.header.version, KdbxVersion.V4); }); - }); + }, tags: ['kdbx4']); }