aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/auth.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-10-25 15:01:56 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-10-30 15:16:02 +0000
commit03390054664ca11ce1db178dff5065ce8f545925 (patch)
tree519f103ba47bf2017344e6ce8aadc0eb292cea27 /t/app/controller/auth.t
parent0a48f7e50d4157adc5a6888285f7f07bade5d20f (diff)
Fix password reset on 2FA accounts.
Diffstat (limited to 't/app/controller/auth.t')
-rw-r--r--t/app/controller/auth.t23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index cc40bd2b0..652a4b293 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -343,4 +343,27 @@ subtest "Test enforced two-factor authentication" => sub {
};
};
+subtest "Check two-factor log in by email works" => sub {
+ use Auth::GoogleAuth;
+ my $auth = Auth::GoogleAuth->new;
+ my $code = $auth->code;
+
+ my $user = FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
+ $user->set_extra_metadata('2fa_secret', $auth->secret32);
+ $user->update;
+
+ $mech->clear_emails_ok;
+ $mech->get_ok('/auth');
+ $mech->submit_form_ok({
+ fields => { username => $test_email, password_register => $test_password },
+ button => 'sign_in_by_code',
+ }, "log in by email");
+
+ my $link = $mech->get_link_from_email;
+ $mech->get_ok($link);
+ $mech->content_contains('Please generate a two-factor code');
+ $mech->submit_form_ok({ with_fields => { '2fa_code' => $code } }, "provide correct 2FA code" );
+ $mech->logged_in_ok;
+};
+
done_testing();