File: 06-length-limit.t

package info (click to toggle)
libcrypt-pbkdf2-perl 0.160410-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 156 kB
  • ctags: 45
  • sloc: perl: 589; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!perl
use strict;
use warnings;

use Test::More;
use Test::Fatal;
use Crypt::PBKDF2;

my $pbkdf2 = Crypt::PBKDF2->new(
  length_limit => 8
);

my $hash;

is exception { $hash = $pbkdf2->generate("12345678") }, undef, "doesn't die on generate with valid length";
is exception {
  is $pbkdf2->validate($hash, "12345678"), 1, "hash validates"
}, undef, "doesn't die on validate with valid length";

like exception { $hash = $pbkdf2->generate("123456789") }, qr/length limit/, "dies on generate with too long pw";
like exception {
  is $pbkdf2->validate($hash, "123456789"), 1, "hash validates"
}, qr/length limit/, "dies on validate with too long pw";

done_testing;