File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
tests/TestCase/Controller/Component Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,10 @@ public function stopImpersonating()
445445 */
446446 public function isImpersonating (): bool
447447 {
448+ if (!$ this ->getIdentity ()) {
449+ return false ;
450+ }
451+
448452 $ service = $ this ->getImpersonationAuthenticationService ();
449453 $ controller = $ this ->getController ();
450454
Original file line number Diff line number Diff line change @@ -731,13 +731,17 @@ public function testIsImpersonating()
731731 $ this ->request ->getSession ()->write ('AuthImpersonate ' , $ impersonator );
732732 $ this ->service ->authenticate ($ this ->request );
733733 $ request = $ this ->request
734- ->withAttribute ('authentication ' , $ this ->service );
734+ ->withAttribute ('authentication ' , $ this ->service )
735+ ->withAttribute ('identity ' , new Identity ($ impersonated ));
735736 $ controller = new Controller ($ request , $ this ->response );
736737 $ registry = new ComponentRegistry ($ controller );
737738 $ component = new AuthenticationComponent ($ registry );
738739
739740 $ result = $ component ->isImpersonating ();
740741 $ this ->assertTrue ($ result );
742+
743+ $ component ->logout ();
744+ $ this ->assertFalse ($ component ->isImpersonating ());
741745 }
742746
743747 /**
You can’t perform that action at this time.
0 commit comments