diff options
author | Edmund von der Burg <evdb@mysociety.org> | 2013-09-06 17:11:27 +0100 |
---|---|---|
committer | Edmund von der Burg <evdb@mysociety.org> | 2013-09-10 15:40:08 +0100 |
commit | 2e4970688c9b48dbd4761587fd169fdb14b9af89 (patch) | |
tree | d4af99a7505b53f756712b1405dbf6f22a4f036d /perllib/FixMyStreet/TestMech.pm | |
parent | a08ee186f6e9658ac6b0927e012904427729392e (diff) |
Fix a bug in TestMech->log_in_ok that scrambeled the users password.
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index e91c6a1d6..be8f004a5 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -87,8 +87,8 @@ sub log_in_ok { my $user = $mech->create_user_ok($email); - # store the old password and then change it - my $old_password = $user->password; + # remember the old password and then change it to a known one + my $old_password = $user->password || ''; $user->update( { password => 'secret' } ); # log in @@ -99,7 +99,19 @@ sub log_in_ok { $mech->logged_in_ok; # restore the password (if there was one) - $user->update( { password => $old_password } ) if $old_password; + if ($old_password) { + + # Use store_column and then make_column_dirty to bypass the filters that + # would hash the password, otherwise the password required ito log in + # would be the hash of the previous one. + $user->store_column("password", $old_password); + $user->make_column_dirty("password"); + $user->update(); + + # Belt and braces, check that the password has been correctly saved. + die "password not correctly restored after log_in_ok" + if $user->password ne $old_password; + } return $user; } @@ -296,7 +308,7 @@ sub extract_location { $meta = $mech->extract_problem_meta; -Returns the problem meta information ( submitted by, at etc ) from a +Returns the problem meta information ( submitted by, at etc ) from a problem report page =cut |