File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
tests/TestCase/Authenticator Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,11 @@ public function identify(array $credentials): ArrayAccess|array|null
5656
5757 return $ result ;
5858 }
59- $ this ->_errors [$ name ] = $ identifier ->getErrors ();
59+
60+ $ errors = $ identifier ->getErrors ();
61+ if ($ errors ) {
62+ $ this ->_errors [$ name ] = $ identifier ->getErrors ();
63+ }
6064 }
6165
6266 $ this ->_successfulIdentifier = null ;
Original file line number Diff line number Diff line change @@ -112,6 +112,27 @@ public function testCredentialsEmpty()
112112 $ this ->assertEquals ([0 => 'Login credentials not found ' ], $ result ->getErrors ());
113113 }
114114
115+ public function testIdentityNotFound ()
116+ {
117+ $ identifiers = new IdentifierCollection ([
118+ 'Authentication.Password ' ,
119+ ]);
120+
121+ $ request = ServerRequestFactory::fromGlobals (
122+ ['REQUEST_URI ' => '/users/does-not-match ' ],
123+ [],
124+ ['username ' => 'non-existent ' , 'password ' => 'password ' ],
125+ );
126+
127+ $ form = new FormAuthenticator ($ identifiers );
128+
129+ $ result = $ form ->authenticate ($ request );
130+
131+ $ this ->assertInstanceOf (Result::class, $ result );
132+ $ this ->assertSame (Result::FAILURE_IDENTITY_NOT_FOUND , $ result ->getStatus ());
133+ $ this ->assertSame ([], $ result ->getErrors ());
134+ }
135+
115136 /**
116137 * testSingleLoginUrlMismatch
117138 *
You can’t perform that action at this time.
0 commit comments