summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-04-03 16:54:40 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-04-03 16:54:40 +0200
commit3f2a49b697a6eb5ff8db78c05c65070b46bb75a6 (patch)
tree3c8597bbd372ec704d96c28f31935a6c733acfcd /t
parentc9b94ac51383501ea80e0485cba4f891dbcce3fa (diff)
Use confess instead of return undef, Test::Exception for App::Raps2::Password test
Diffstat (limited to 't')
-rw-r--r--t/20-app-raps2-password.t34
1 files changed, 17 insertions, 17 deletions
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')