diff options
author | Chris Mytton <self@hecticjeff.net> | 2013-09-13 12:12:14 +0100 |
---|---|---|
committer | Chris Mytton <self@hecticjeff.net> | 2013-09-13 12:12:14 +0100 |
commit | b44f9edab53f59fb442e5ee4db28cb25408c652c (patch) | |
tree | e7cd62bd148a5332e1ec625dda6c3bc6b09ceb62 /perllib/FixMyStreet/TestMech.pm | |
parent | 2099ac31a4410f2cf8e1c7d31dc35cdd9ac1e070 (diff) | |
parent | 94ac7786132a538a5742ba325eb7fe9eff89cfc9 (diff) |
Merge branch 'master' into oxfordshire-usability-recommendations
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 |