diff options
Diffstat (limited to 't')
-rw-r--r-- | t/20-app-raps2-password.t | 58 | ||||
-rw-r--r-- | t/29-app-raps2.t | 11 |
2 files changed, 69 insertions, 0 deletions
diff --git a/t/20-app-raps2-password.t b/t/20-app-raps2-password.t new file mode 100644 index 0000000..7e36358 --- /dev/null +++ b/t/20-app-raps2-password.t @@ -0,0 +1,58 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +use Test::More tests => 13; + +my $pw; +my $salt = 'abcdefghijklmnop'; +my $pass = 'something'; + +use_ok('App::Raps2::Password'); + +$pw = App::Raps2::Password->new(); +is($pw, undef, 'new() missing salt and passphrase'); + +$pw = App::Raps2::Password->new(salt => $salt); +is($pw, undef, 'new() missing passphrase'); + +$pw = App::Raps2::Password->new(passphrase => $pass); +is($pw, undef, 'new() missing salt'); + +$pw = App::Raps2::Password->new( + passphrase => $pass, + salt => 'abcdefghijklmno', +); +is($pw, undef, 'new() salt one too short'); + +$pw = App::Raps2::Password->new( + passphrase => $pass, + salt => $salt . 'z', +); +is($pw, undef, 'new() salt one too long'); + +$pw = App::Raps2::Password->new( + passphrase => $pass, + salt => $salt, +); +isa_ok($pw, 'App::Raps2::Password'); + +$pw = App::Raps2::Password->new( + cost => 8, + salt => $salt, + passphrase => $pass, +); + +isa_ok($pw, 'App::Raps2::Password'); + +is($pw->decrypt('53616c7465645f5f80d8c367e15980d43ec9a6eabc5390b4'), 'quux', + 'decrypt okay'); + +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'); + +ok($pw->verify($pw->crypt('truth')), 'crypt->verify okay') diff --git a/t/29-app-raps2.t b/t/29-app-raps2.t new file mode 100644 index 0000000..28fe4fc --- /dev/null +++ b/t/29-app-raps2.t @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; + +use Test::More tests => 2; + +use_ok('App::Raps2'); + +my $r2 = App::Raps2->new(); +isa_ok($r2, 'App::Raps2'); |