summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-04-03 19:31:32 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-04-03 19:31:32 +0200
commitcbc81366fdd3b9f7cc19b8ce81c5b83994e91963 (patch)
tree0f87f434f12c252b50467ef3d6a578eb9a73b600 /t
parent5ee7824eb667b4d53515ebac442c53c9a94aed41 (diff)
t/20-app-raps2-password.t: Tests for ->salt()
Diffstat (limited to 't')
-rw-r--r--t/20-app-raps2-password.t54
1 files changed, 52 insertions, 2 deletions
diff --git a/t/20-app-raps2-password.t b/t/20-app-raps2-password.t
index 67bf29a..56a6f4d 100644
--- a/t/20-app-raps2-password.t
+++ b/t/20-app-raps2-password.t
@@ -3,7 +3,7 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 13;
+use Test::More tests => 19;
use Test::Exception;
my $pw;
@@ -30,6 +30,17 @@ throws_ok(
throws_ok(
sub {
+ App::Raps2::Password->new(
+ salt => $salt,
+ passphrase => q{}
+ );
+ },
+ qr{no passphrase given},
+ 'new() missing passphrase'
+);
+
+throws_ok(
+ sub {
App::Raps2::Password->new(passphrase => $pass);
},
qr{incorrect salt length},
@@ -87,4 +98,43 @@ throws_ok(
'verify: does not verify invalid hash'
);
-ok($pw->verify($pw->crypt('truth')), 'crypt->verify okay')
+ok($pw->verify($pw->crypt('truth')), 'crypt->verify okay');
+
+throws_ok(
+ sub {
+ $pw->salt();
+ },
+ qr{incorrect salt length},
+ 'salt: No argument',
+);
+
+throws_ok(
+ sub {
+ $pw->salt('');
+ },
+ qr{incorrect salt length},
+ 'salt: Empty argument',
+);
+
+throws_ok(
+ sub {
+ $pw->salt('abcdefghijklmno');
+ },
+ qr{incorrect salt length},
+ 'salt: One too short',
+);
+
+throws_ok(
+ sub {
+ $pw->salt($salt . 'z');
+ },
+ qr{incorrect salt length},
+ 'salt: One too long',
+);
+
+lives_ok(
+ sub {
+ $pw->salt($salt);
+ },
+ 'salt: Correct length',
+);