aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/auth.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-06-25 16:23:33 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-07-07 15:03:49 +0100
commit9a12c0dac0b7677938f33f5abb639a296adff9c5 (patch)
treea909a3cc05e1ff7cac311a075ad7453257e58879 /t/app/controller/auth.t
parentd597f5012f2db5408eb0a913a789bbe2de4d923a (diff)
Add option to check password on Have I Been Pwned.
If switched on, sends first five letters of the SHA1 hash of the entered password to HIBP's API, which then returns all matching hashes in their database of breached passwords. If we find a match, tell the user they need to pick a different password.
Diffstat (limited to 't/app/controller/auth.t')
-rw-r--r--t/app/controller/auth.t17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index 8b4b772fc..0326bbacd 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -288,6 +288,23 @@ subtest 'check common password AJAX call' => sub {
$mech->content_contains("true");
};
+subtest 'check hibp password call' => sub {
+ FixMyStreet::override_config {
+ CHECK_HAVEIBEENPWNED => 1,
+ }, sub {
+ my $lwp = Test::MockModule->new('LWP::Simple');
+ # Switch mock round from live site, so we know we're not testing live site by mistake
+ $lwp->mock(get => sub($) {
+ return '9958D0F0EE6744E7CCAFC84515FCFAD7B1B:10' if $_[0] =~ /6EF4D$/; # squirblewirble
+ return '';
+ });
+ $mech->post_ok('/auth/common_password', { password_register => 'p@ssword2' });
+ $mech->content_contains("true");
+ $mech->post_ok('/auth/common_password', { password_register => 'squirblewirble' });
+ $mech->content_contains("That password has appeared in a known");
+ };
+};
+
subtest 'test forgotten password page' => sub {
$mech->get_ok('/auth/forgot');
$mech->content_contains('Forgot password');