@@ -507,25 +507,21 @@ public function testUnsuccessfulLoginAttempts() {
507507
508508 /* UNSUCCESSFUL ATTEMPTS WITH WRONG PASSWORD FOR EXISTING USER ARE LOGGED */
509509 $ this ->doTestLoginForm ('testuser@example.com ' , 'wrongpassword ' );
510- $ attempt = DataObject::get_one ('LoginAttempt ' , array (
511- '"LoginAttempt"."Email" ' => 'testuser@example.com '
512- ));
513- $ this ->assertTrue (is_object ($ attempt ));
514- $ member = DataObject::get_one ('Member ' , array (
515- '"Member"."Email" ' => 'testuser@example.com '
516- ));
510+ $ attempt = LoginAttempt::getByEmail ('testuser@example.com ' )->first ();
511+ $ this ->assertInstanceOf ('LoginAttempt ' , $ attempt );
512+ $ member = Member::get ()->filter ('Email ' , 'testuser@example.com ' )->first ();
517513 $ this ->assertEquals ($ attempt ->Status , 'Failure ' );
518- $ this ->assertEquals ($ attempt ->Email , 'testuser@example.com ' );
514+ $ this ->assertEmpty ($ attempt ->Email ); // Doesn't store potentially sensitive data
515+ $ this ->assertEquals ($ attempt ->EmailHashed , sha1 ('testuser@example.com ' ));
519516 $ this ->assertEquals ($ attempt ->Member (), $ member );
520517
521518 /* UNSUCCESSFUL ATTEMPTS WITH NONEXISTING USER ARE LOGGED */
522519 $ this ->doTestLoginForm ('wronguser@silverstripe.com ' , 'wrongpassword ' );
523- $ attempt = DataObject::get_one ('LoginAttempt ' , array (
524- '"LoginAttempt"."Email" ' => 'wronguser@silverstripe.com '
525- ));
526- $ this ->assertTrue (is_object ($ attempt ));
520+ $ attempt = LoginAttempt::getByEmail ('wronguser@silverstripe.com ' )->first ();
521+ $ this ->assertInstanceOf ('LoginAttempt ' , $ attempt );
527522 $ this ->assertEquals ($ attempt ->Status , 'Failure ' );
528- $ this ->assertEquals ($ attempt ->Email , 'wronguser@silverstripe.com ' );
523+ $ this ->assertEmpty ($ attempt ->Email ); // Doesn't store potentially sensitive data
524+ $ this ->assertEquals ($ attempt ->EmailHashed , sha1 ('wronguser@silverstripe.com ' ));
529525 $ this ->assertNotNull (
530526 $ this ->loginErrorMessage (), 'An invalid email returns a message. '
531527 );
@@ -536,15 +532,14 @@ public function testSuccessfulLoginAttempts() {
536532
537533 /* SUCCESSFUL ATTEMPTS ARE LOGGED */
538534 $ this ->doTestLoginForm ('testuser@example.com ' , '1nitialPassword ' );
539- $ attempt = DataObject::get_one ('LoginAttempt ' , array (
540- '"LoginAttempt"."Email" ' => 'testuser@example.com '
541- ));
535+ $ attempt = LoginAttempt::getByEmail ('testuser@example.com ' )->first ();
542536 $ member = DataObject::get_one ('Member ' , array (
543537 '"Member"."Email" ' => 'testuser@example.com '
544538 ));
545- $ this ->assertTrue ( is_object ( $ attempt) );
539+ $ this ->assertInstanceOf ( ' LoginAttempt ' , $ attempt );
546540 $ this ->assertEquals ($ attempt ->Status , 'Success ' );
547- $ this ->assertEquals ($ attempt ->Email , 'testuser@example.com ' );
541+ $ this ->assertEmpty ($ attempt ->Email ); // Doesn't store potentially sensitive data
542+ $ this ->assertEquals ($ attempt ->EmailHashed , sha1 ('testuser@example.com ' ));
548543 $ this ->assertEquals ($ attempt ->Member (), $ member );
549544 }
550545
0 commit comments