X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2Fentry.t;h=f08b683036af4f71eed1d627bde8149a31c660a7;hb=eefcd42a336641c8927b29d12c5c59443212468f;hp=3a6267d4a4059301f1d110fef993a80261e8a6ba;hpb=4dc2a1996dfcf2dfda3c554daa2f5f59fa763494;p=chaz%2Fp5-File-KDBX diff --git a/t/entry.t b/t/entry.t index 3a6267d..f08b683 100644 --- a/t/entry.t +++ b/t/entry.t @@ -18,7 +18,7 @@ subtest 'Construction' => sub { is $entry->{username}, 'foo', 'username is in the object still'; is $entry->username, '', 'username is not the UserName string'; - like exception { $entry->kdbx }, qr/disassociated from a KDBX database/, 'Dies if disassociated'; + like exception { $entry->kdbx }, qr/disconnected/, 'Dies if disconnected'; $entry->kdbx(my $kdbx = File::KDBX->new); is $entry->kdbx, $kdbx, 'Set a database after instantiation'; @@ -30,7 +30,12 @@ subtest 'Construction' => sub { is $entry->username, 'bar', 'username is set correctly as the UserName string'; cmp_deeply $entry, noclass({ - auto_type => {}, + auto_type => { + associations => [], + data_transfer_obfuscation => 0, + default_sequence => "{USERNAME}{TAB}{PASSWORD}{ENTER}", + enabled => bool(1), + }, background_color => "", binaries => {}, custom_data => {}, @@ -128,15 +133,40 @@ subtest 'Update UUID' => sub { my $entry2 = $kdbx->add_entry(label => 'Bar'); $entry2->url(sprintf('{REF:T@I:%s} {REF:T@I:%s}', $entry1->id, lc($entry1->id))); - is $entry2->expanded_url, 'Foo Foo', 'Field reference expands' + is $entry2->expand_url, 'Foo Foo', 'Field reference expands' or diag explain $entry2->url; $entry1->uuid("\1" x 16); is $entry2->url, '{REF:T@I:01010101010101010101010101010101} {REF:T@I:01010101010101010101010101010101}', 'Replace field references when an entry UUID is changed'; - is $entry2->expanded_url, 'Foo Foo', 'Field reference expands after UUID is changed' + is $entry2->expand_url, 'Foo Foo', 'Field reference expands after UUID is changed' or diag explain $entry2->url; }; +subtest 'Auto-type' => sub { + my $kdbx = File::KDBX->new; + + my $entry = $kdbx->add_entry(title => 'Meh'); + $entry->add_auto_type_association({ + window => 'Boring Store', + keystroke_sequence => 'yeesh', + }); + $entry->add_auto_type_association({ + window => 'Friendly Bank', + keystroke_sequence => 'blah', + }); + + my $window_title = 'Friendly'; + my $entries = $kdbx->entries(auto_type => 1) + ->filter(sub { + my ($ata) = grep { $_->{window} =~ /\Q$window_title\E/i } @{$_->auto_type_associations}; + return [$_, $ata->{keystroke_sequence} || $_->auto_type_default_sequence] if $ata; + }); + cmp_ok $entries->count, '==', 1, 'Find auto-type window association'; + + (undef, my $keys) = @{$entries->next}; + is $keys, 'blah', 'Select the correct association'; +}; + done_testing;