X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-File-KDBX;a=blobdiff_plain;f=t%2Fhmac-block.t;h=75b467c98691201b32eb9e704697e96e99060eb0;hp=bff3d5edc4a225b53f2026bb8e63d53a48f6d635;hb=1b913e5c8826cae2355b0076ec5701aa3ce63c63;hpb=b30990a507ef30b6f5b6fcb799a2759632c77ff0 diff --git a/t/hmac-block.t b/t/hmac-block.t index bff3d5e..75b467c 100644 --- a/t/hmac-block.t +++ b/t/hmac-block.t @@ -8,10 +8,9 @@ use TestCommon qw(:no_warnings_test); use File::KDBX::Util qw(can_fork); use IO::Handle; +use PerlIO::via::File::KDBX::HmacBlock; use Test::More; -BEGIN { use_ok 'PerlIO::via::File::KDBX::HmacBlock' } - my $KEY = "\x01" x 64; { @@ -31,22 +30,6 @@ my $KEY = "\x01" x 64; is $plaintext, $expected_plaintext, 'HMAC-block just a little bit'; } -subtest 'Error handling' => sub { - pipe(my $read, my $write) or die "pipe failed: $!\n"; - - PerlIO::via::File::KDBX::HmacBlock->push($read, key => $KEY); - - print $write 'blah blah blah'; - close($write) or die "close failed: $!"; - - is $read->error, 0, 'Read handle starts out fine'; - my $data = do { local $/; <$read> }; - is $read->error, 1, 'Read handle can enter and error state'; - - like $PerlIO::via::File::KDBX::HmacBlock::ERROR, qr/failed to read HMAC/i, - 'Error object is available'; -}; - SKIP: { skip 'Tests require fork' if !can_fork; @@ -72,4 +55,20 @@ SKIP: { waitpid($pid, 0) or die "wait failed: $!\n"; } +subtest 'Error handling' => sub { + pipe(my $read, my $write) or die "pipe failed: $!\n"; + + PerlIO::via::File::KDBX::HmacBlock->push($read, key => $KEY); + + print $write 'blah blah blah'; + close($write) or die "close failed: $!"; + + is $read->error, 0, 'Read handle starts out fine'; + my $data = do { local $/; <$read> }; + is $read->error, 1, 'Read handle can enter and error state'; + + like $PerlIO::via::File::KDBX::HmacBlock::ERROR, qr/failed to read HMAC/i, + 'Error object is available'; +}; + done_testing;