11@Tags (['kdbx4' ])
2+ library ;
3+
24import 'dart:io' ;
35
46import 'package:kdbx/kdbx.dart' ;
@@ -22,15 +24,19 @@ void main() {
2224 test ('bubb' , () async {
2325 final data = await File ('test/keepassxcpasswords.kdbx' ).readAsBytes ();
2426 final file = await kdbxFormat.read (
25- data, Credentials (ProtectedValue .fromString ('asdf' )));
27+ data,
28+ Credentials (ProtectedValue .fromString ('asdf' )),
29+ );
2630 final firstEntry = file.body.rootGroup.entries.first;
2731 final pwd = firstEntry.getString (KdbxKeyCommon .PASSWORD )! .getText ();
2832 expect (pwd, 'MyPassword' );
2933 });
3034 test ('Reading kdbx4_keeweb' , () async {
3135 final data = await File ('test/kdbx4_keeweb.kdbx' ).readAsBytes ();
3236 final file = await kdbxFormat.read (
33- data, Credentials (ProtectedValue .fromString ('asdf' )));
37+ data,
38+ Credentials (ProtectedValue .fromString ('asdf' )),
39+ );
3440 final firstEntry = file.body.rootGroup.entries.first;
3541 final pwd = firstEntry.getString (KdbxKeyCommon .PASSWORD )! .getText ();
3642 expect (pwd, 'def' );
@@ -56,24 +62,32 @@ void main() {
5662 }
5763 });
5864 test ('Binary Keyfile' , () async {
59- final data =
60- await File ('test/keyfile/BinaryKeyFilePasswords.kdbx' ).readAsBytes ();
61- final keyFile =
62- await File ('test/keyfile/binarykeyfile.key' ).readAsBytes ();
63- final file = await kdbxFormat.read (data,
64- Credentials .composite (ProtectedValue .fromString ('asdf' ), keyFile));
65+ final data = await File (
66+ 'test/keyfile/BinaryKeyFilePasswords.kdbx' ,
67+ ).readAsBytes ();
68+ final keyFile = await File (
69+ 'test/keyfile/binarykeyfile.key' ,
70+ ).readAsBytes ();
71+ final file = await kdbxFormat.read (
72+ data,
73+ Credentials .composite (ProtectedValue .fromString ('asdf' ), keyFile),
74+ );
6575 expect (file.body.rootGroup.entries, hasLength (1 ));
6676 });
6777 test ('Reading chacha20' , () async {
6878 final data = await File ('test/chacha20.kdbx' ).readAsBytes ();
6979 final file = await kdbxFormat.read (
70- data, Credentials (ProtectedValue .fromString ('asdf' )));
80+ data,
81+ Credentials (ProtectedValue .fromString ('asdf' )),
82+ );
7183 expect (file.body.rootGroup.entries, hasLength (1 ));
7284 });
7385 test ('Reading aes-kdf' , () async {
7486 final data = await File ('test/aeskdf.kdbx' ).readAsBytes ();
7587 final file = await kdbxFormat.read (
76- data, Credentials (ProtectedValue .fromString ('asdf' )));
88+ data,
89+ Credentials (ProtectedValue .fromString ('asdf' )),
90+ );
7791 expect (file.body.rootGroup.entries, hasLength (1 ));
7892 }, skip: 'Takes tooo long, too many iterations.' );
7993 });
@@ -91,20 +105,26 @@ void main() {
91105 final saved = await kdbx.save ();
92106
93107 final loadedKdbx = await kdbxFormat.read (
94- saved, Credentials (ProtectedValue .fromString ('asdf' )));
108+ saved,
109+ Credentials (ProtectedValue .fromString ('asdf' )),
110+ );
95111 _logger.fine ('Successfully loaded kdbx $loadedKdbx ' );
96112 File ('test_v4x.kdbx' ).writeAsBytesSync (saved);
97113 });
98114 test ('Reading it' , () async {
99115 final data = await File ('test/test_v4x.kdbx' ).readAsBytes ();
100116 final file = await kdbxFormat.read (
101- data, Credentials (ProtectedValue .fromString ('asdf' )));
117+ data,
118+ Credentials (ProtectedValue .fromString ('asdf' )),
119+ );
102120 _logger.fine ('successfully read ${file .body .rootGroup .name }' );
103121 });
104122 test ('write chacha20' , () async {
105123 final data = await File ('test/chacha20.kdbx' ).readAsBytes ();
106124 final file = await kdbxFormat.read (
107- data, Credentials (ProtectedValue .fromString ('asdf' )));
125+ data,
126+ Credentials (ProtectedValue .fromString ('asdf' )),
127+ );
108128 expect (file.body.rootGroup.entries, hasLength (1 ));
109129 _createEntry (file, file.body.rootGroup, 'user1' , 'LoremIpsum' );
110130
@@ -132,7 +152,11 @@ void main() {
132152}
133153
134154KdbxEntry _createEntry (
135- KdbxFile file, KdbxGroup group, String username, String password) {
155+ KdbxFile file,
156+ KdbxGroup group,
157+ String username,
158+ String password,
159+ ) {
136160 final entry = KdbxEntry .create (file, group);
137161 group.addEntry (entry);
138162 entry.setString (KdbxKeyCommon .USER_NAME , PlainValue (username));
0 commit comments