File: IsBadPasswordForUNIX.t

package info (click to toggle)
libdata-password-perl 1.12-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 123; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,297 bytes parent folder | download | duplicates (6)
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
46
47
48
49
50
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
use Test::More qw(no_plan);

use Data::Password qw(IsBadPasswordForUNIX $MAXLEN @DICTIONARIES); 

ok(1,'Module Loaded');

eval {
	$_=getpwnam('IsBadPassword');
	};

my $have_getpwnam = $@ ? 0 :1;

my %tests = qw(BlaBla 1 blabla 0 cleaner 0 qwerTy 0 
   aB1234 0 xxxZZZ 1 xxxxZZ 0 
   Abramson 0 
   noboXX 1 MAxLEN1288457 0 MAXlen12r45f7 1
);
my $have_dic =0;
my $dic_name = '';

#@DICTIONARIES = undef;
@DICTIONARIES = qw(t/words words);
foreach (@DICTIONARIES){
	if (-r $_ && /words$/) {
	 	$have_dic = 1;
		$dic_name=$_;
		last;
	 };
}

ok($have_dic eq 1,"Dictionary '$dic_name' loaded");

SKIP: {
   skip 'No getpwnam on this platform',scalar(keys(%tests)) unless $have_getpwnam;
   $tests{Abramson} = $have_dic ? 0 : 1;

   while (my ($pass, $good) = each %tests) {
        $MAXLEN = $pass eq 'MAXlen12r45f7' ? 0 : 8;	
	my $reason = IsBadPasswordForUNIX('IsBadPassword',$pass) || '';
	my $got = $reason ? 0 : 1;
	ok($got eq $good,"$pass: $reason");
   }
}