zeroclickinfo-goodies/t/Password.t

63 lines
2.0 KiB
Perl
Raw Permalink Normal View History

2014-07-24 13:13:54 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2014-07-24 13:13:54 -07:00
use DDG::Test::Goodie;
zci answer_type => 'pw';
zci is_cached => 0;
2014-07-24 13:13:54 -07:00
2016-05-22 14:14:58 -07:00
sub build_test {
2016-05-23 09:34:36 -07:00
my ($chars, $strength) = @_;
2016-05-23 14:09:36 -07:00
return test_zci(re(qr/^.{$chars} \(random password\)/), structured_answer => {
2016-05-23 09:34:36 -07:00
data => {
2016-05-23 14:09:36 -07:00
title => re(qr/^.{$chars}$/),
2016-05-23 09:34:36 -07:00
subtitle => "Random password: $chars characters, $strength strength"
},
templates => {
group => 'text'
}
});
2016-05-22 14:14:58 -07:00
}
2014-07-24 13:13:54 -07:00
ddg_goodie_test(
[qw( DDG::Goodie::Password)],
2016-05-23 04:53:27 -07:00
'pw 15 average' => build_test(15, 'average'),
'password normal 15' => build_test(15, 'average'),
'random pw 15 AVG' => build_test(15, 'average'),
'pwgen strong 25' => build_test(25, 'high'),
'password 25 hard' => build_test(25, 'high'),
'Password High 25' => build_test(25, 'high'),
# Example queries
2016-05-23 04:53:27 -07:00
'random password' => build_test(8, 'average'),
'password strong 15' => build_test(15, 'high'),
'pw' => build_test(8, 'average'),
2015-09-22 14:54:08 -07:00
# Add some triggers (issue #1565)
2016-05-23 04:53:27 -07:00
'generate password' => build_test(8, 'average'),
'generate strong password' => build_test(8, 'high'),
'generate random password' => build_test(8, 'average'),
'password generator' => build_test(8, 'average'),
'random password generator' => build_test(8, 'average'),
'random strong password' => build_test(8, 'high'),
'random password 16 characters' => build_test(16, 'average'),
'create random password' => build_test(8, 'average'),
'strong random password' => build_test(8, 'high'),
'random password strong 15' => build_test(15, 'high'),
2014-12-14 08:44:53 -08:00
'password 65' => undef,
2015-07-16 08:56:58 -07:00
'random password weak 5' => undef,
'password 5 EaSy' => undef,
'password low 5' => undef,
'generate generate password' => undef,
'password pw' => undef,
'password fortissimo' => undef,
'nice random password' => undef,
'excavate strong password' => undef,
'not another strong pw' => undef,
'generator' => undef,
'potatoe generator' => undef
2014-07-24 13:13:54 -07:00
);
2016-05-16 06:18:04 -07:00
done_testing