]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/database.t
Release File-KDBX 0.906
[chaz/p5-File-KDBX] / t / database.t
index 8bed335b351ef60e87d4f2d71ae6ff15b7b8de5a..8b26f6aac3d5ef9f6103934b8a6a9334c2ca50e7 100644 (file)
@@ -8,10 +8,11 @@ use FindBin qw($Bin);
 use lib "$Bin/lib";
 use TestCommon;
 
+use File::KDBX::Constants qw(:cipher :version);
 use File::KDBX;
 use File::Temp qw(tempfile);
 use Test::Deep;
-use Test::More;
+use Test::More 1.001004_001;
 use Time::Piece;
 
 subtest 'Create a new database' => sub {
@@ -29,6 +30,14 @@ subtest 'Create a new database' => sub {
 
     $entry->remove;
     ok $kdbx->_has_implicit_root, 'Removing group makes the root group implicit again';
+
+    cmp_ok $kdbx->version, '==', KDBX_VERSION_3_1, 'Default KDBX file version is 3.1';
+    is $kdbx->cipher_id, CIPHER_UUID_AES256, 'Cipher of new database is AES256';
+    cmp_ok length($kdbx->encryption_iv), '==', 16, 'Encryption IV of new databse is 16 bytes';
+
+    my $kdbx2 = File::KDBX->new(version => KDBX_VERSION_4_0);
+    is $kdbx2->cipher_id, CIPHER_UUID_CHACHA20, 'Cipher of new v4 database is ChaCha20';
+    cmp_ok length($kdbx2->encryption_iv), '==', 12, 'Encryption IV of new databse is 12 bytes';
 };
 
 subtest 'Clone' => sub {
@@ -49,7 +58,7 @@ subtest 'Clone' => sub {
     my @objects = $copy->objects->each;
     subtest 'Cloned objects refer to the cloned database' => sub {
         plan tests => scalar @_;
-        for my $object (@objects) {
+        for my $object (@_) {
             my $object_kdbx = eval { $object->kdbx };
             is $object_kdbx, $copy, 'Object: ' . $object->label;
         }
@@ -133,7 +142,7 @@ subtest 'Recycle bin' => sub {
 
     is $kdbx->entries->size, 1, 'Database is not empty';
     is $kdbx->entries(searching => 1)->size, 0, 'Database has no entries if searching';
-    cmp_ok $bin->entries_deeply->size, '==', 1, 'Recycle bin has an entry';
+    cmp_ok $bin->all_entries->size, '==', 1, 'Recycle bin has an entry';
 
     $entry->recycle_or_remove;
     is $kdbx->entries->size, 0, 'Remove entry if it is already in the recycle bin';
This page took 0.023158 seconds and 4 git commands to generate.