Browse Source

improve test for kdbx4

pull/3/head
Herbert Poul 4 years ago
parent
commit
9974b10cd7
  1. 3
      dart_test.yaml
  2. 3
      test/icon/kdbx_customicon_test.dart
  3. 4
      test/internal/test_utils.dart
  4. 3
      test/kdbx_history_test.dart
  5. 11
      test/kdbx_upgrade_test.dart

3
dart_test.yaml

@ -0,0 +1,3 @@
tags:
kdbx3: {}
kdbx4: {}

3
test/icon/kdbx_customicon_test.dart

@ -1,10 +1,9 @@
import 'package:logging_appenders/logging_appenders.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import '../internal/test_utils.dart'; import '../internal/test_utils.dart';
void main() { void main() {
PrintAppender.setupLogging(); TestUtil.setupLogging();
test('load custom icons from file', () async { test('load custom icons from file', () async {
final file = await TestUtil.readKdbxFile('test/icon/icontest.kdbx'); final file = await TestUtil.readKdbxFile('test/icon/icontest.kdbx');
final entry = file.body.rootGroup.entries.first; final entry = file.body.rootGroup.entries.first;

4
test/internal/test_utils.dart

@ -5,12 +5,16 @@ import 'dart:typed_data';
import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:argon2_ffi_base/argon2_ffi_base.dart';
import 'package:kdbx/kdbx.dart'; import 'package:kdbx/kdbx.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';
final _logger = Logger('test_utils'); final _logger = Logger('test_utils');
class TestUtil { class TestUtil {
static final keyTitle = KdbxKey('Title'); static final keyTitle = KdbxKey('Title');
static void setupLogging() =>
PrintAppender.setupLogging(stderrLevel: Level.WARNING);
static KdbxFormat kdbxFormat() { static KdbxFormat kdbxFormat() {
Argon2.resolveLibraryForceDynamic = true; Argon2.resolveLibraryForceDynamic = true;
return KdbxFormat(Argon2FfiFlutter(resolveLibrary: (path) { return KdbxFormat(Argon2FfiFlutter(resolveLibrary: (path) {

3
test/kdbx_history_test.dart

@ -1,7 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:kdbx/kdbx.dart'; import 'package:kdbx/kdbx.dart';
import 'package:logging_appenders/logging_appenders.dart';
import 'package:quiver/core.dart'; import 'package:quiver/core.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
@ -47,7 +46,7 @@ class StreamExpect<T> {
} }
void main() { void main() {
PrintAppender.setupLogging(); TestUtil.setupLogging();
group('test history for values', () { group('test history for values', () {
test('check history creation', () async { test('check history creation', () async {
final file = await TestUtil.readKdbxFile('test/keepass2test.kdbx'); final file = await TestUtil.readKdbxFile('test/keepass2test.kdbx');

11
test/kdbx_upgrade_test.dart

@ -1,11 +1,11 @@
import 'package:kdbx/kdbx.dart';
import 'package:kdbx/src/kdbx_header.dart'; import 'package:kdbx/src/kdbx_header.dart';
import 'package:logging_appenders/logging_appenders.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'internal/test_utils.dart'; import 'internal/test_utils.dart';
void main() { void main() {
PrintAppender.setupLogging(); TestUtil.setupLogging();
group('Test upgrade from v3 to v4', () { group('Test upgrade from v3 to v4', () {
final format = TestUtil.kdbxFormat(); final format = TestUtil.kdbxFormat();
test('Read v3, write v4', () async { test('Read v3, write v4', () async {
@ -16,6 +16,11 @@ void main() {
final v4 = await TestUtil.saveAndRead(file); final v4 = await TestUtil.saveAndRead(file);
expect(v4.header.version, KdbxVersion.V4); expect(v4.header.version, KdbxVersion.V4);
await TestUtil.saveTestOutput('kdbx4upgrade', 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']);
} }

Loading…
Cancel
Save