From 3f2a49b697a6eb5ff8db78c05c65070b46bb75a6 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 3 Apr 2011 16:54:40 +0200 Subject: Use confess instead of return undef, Test::Exception for App::Raps2::Password test --- t/20-app-raps2-password.t | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 't') diff --git a/t/20-app-raps2-password.t b/t/20-app-raps2-password.t index 7e36358..6a5f080 100644 --- a/t/20-app-raps2-password.t +++ b/t/20-app-raps2-password.t @@ -4,6 +4,7 @@ use warnings; use 5.010; use Test::More tests => 13; +use Test::Exception; my $pw; my $salt = 'abcdefghijklmnop'; @@ -11,26 +12,24 @@ my $pass = 'something'; use_ok('App::Raps2::Password'); -$pw = App::Raps2::Password->new(); -is($pw, undef, 'new() missing salt and passphrase'); +throws_ok { App::Raps2::Password->new() } qr{incorrect salt length}, + 'new() missing salt and passphrase'; -$pw = App::Raps2::Password->new(salt => $salt); -is($pw, undef, 'new() missing passphrase'); +throws_ok { App::Raps2::Password->new(salt => $salt) } qr{no passphrase given}, + 'new() missing passphrase'; -$pw = App::Raps2::Password->new(passphrase => $pass); -is($pw, undef, 'new() missing salt'); +throws_ok { App::Raps2::Password->new(passphrase => $pass) } qr{incorrect salt length}, + 'new() missing salt'; -$pw = App::Raps2::Password->new( - passphrase => $pass, - salt => 'abcdefghijklmno', -); -is($pw, undef, 'new() salt one too short'); +throws_ok { App::Raps2::Password->new( + passphrase => $pass, + salt => 'abcdefghijklmno', + ) } qr{incorrect salt length}, 'new() salt one too short'; -$pw = App::Raps2::Password->new( - passphrase => $pass, - salt => $salt . 'z', -); -is($pw, undef, 'new() salt one too long'); +throws_ok { App::Raps2::Password->new( + passphrase => $pass, + salt => $salt . 'z', + ) } qr{incorrect salt length}, 'new() salt one too long'; $pw = App::Raps2::Password->new( passphrase => $pass, @@ -53,6 +52,7 @@ is($pw->decrypt($pw->encrypt('foo')), 'foo', 'encrypt->decrypt okay'); ok($pw->verify('3lJRlaRuOGWv/z3g1DAOlcH.u9vS8Wm'), 'verify: verifies correct hash'); -ok(!$pw->verify('3lJRlaRuOGWv/z3g1DAOlcH.u9vS8WM'), 'verify: does not verify invalid hash'); +throws_ok { $pw->verify('3lJRlaRuOGWv/z3g1DAOlcH.u9vS8WM') } qr{Passwords did not match}, +'verify: does not verify invalid hash'; ok($pw->verify($pw->crypt('truth')), 'crypt->verify okay') -- cgit v1.2.3