File: mysql323.t

package info (click to toggle)
libauthen-passphrase-perl 0.008-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 380 kB
  • ctags: 169
  • sloc: perl: 1,932; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download | duplicates (5)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use warnings;
use strict;

use Test::More tests => 59;

BEGIN { use_ok "Authen::Passphrase::MySQL323"; }

my $ppr = Authen::Passphrase::MySQL323->new(passphrase => "wibble");
ok $ppr;
is $ppr->hash, "\x1d\x1a\x1e\x8f\x50\xfe\xa4\xe3";
is $ppr->hash_hex, "1d1a1e8f50fea4e3";

my %pprs;
my $i = 0;
while(<DATA>) {
	chomp;
	s/([^ \n]+) *//;
	my $hash_hex = $1;
	my $hash = pack("H*", $hash_hex);
	$ppr = Authen::Passphrase::MySQL323
		->new(($i++ & 1) ? (hash => $hash) : (hash_hex => $hash_hex));
	ok $ppr;
	is $ppr->hash_hex, lc($hash_hex);
	is $ppr->hash, $hash;
	eval { $ppr->passphrase }; isnt $@, "";
	eval { $ppr->as_crypt }; isnt $@, "";
	eval { $ppr->as_rfc2307 }; isnt $@, "";
	$pprs{$_} = $ppr;
}

foreach my $rightphrase (sort keys %pprs) {
	my $ppr = $pprs{$rightphrase};
	foreach my $passphrase (sort keys %pprs) {
		ok ($ppr->match($passphrase) xor $passphrase ne $rightphrase);
	}
}

1;

__DATA__
5030573512345671
606717756665BCE6 0
606717496665BCBA 1
7c786c222596437b foo
6873f3091d7dad18 supercalifragilisticexpialidocious