File: 05ambiguous.t

package info (click to toggle)
libstring-mkpasswd-perl 0.05-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 140 kB
  • ctags: 22
  • sloc: perl: 272; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Test::More tests => 3;

use constant ITERATIONS => 100; # sufficiently large to overcome probability
our $AMBIGUOUS = 'o01ilvwc|_\-.,:;\[\](){}'; # keys of String::MkPasswd::IS_AMBIGUOUS in regex form

BEGIN { use_ok('String::MkPasswd') };

my $password;

subtest 'Test distributed passwords with "-noambiguous" enabled' => sub {
	plan tests => ITERATIONS;
	for ( my $i = 0; $i < ITERATIONS; $i++ ) {
		$password = String::MkPasswd::mkpasswd( -dist => 1, -noambiguous => 1 );
		ok( $password !~ /[$AMBIGUOUS]/, 'Distributed password contains no ambiguous characters');
	}
};

subtest 'Test non-distributed passwords with "-noambiguous" enabled' => sub {
	plan tests => ITERATIONS;
	for ( my $i = 0; $i < ITERATIONS; $i++ ) {
		$password = String::MkPasswd::mkpasswd( -dist => 0, -noambiguous => 1 );
		ok( $password !~ /[$AMBIGUOUS]/, 'Non-distributed password contains no ambiguous characters');
	}
};