X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fsecurity%2FLoginManagerTest.php;h=f26cd1eb8635c0bd21f8f4ab68043b7569562ddf;hb=4adeffd7f427580bba6f7656360850d4460c1f1d;hp=fad09992ea094cde3b7bb2f49a9840fac8a486c1;hpb=704637bfebc73ada4b800b35c457e9fe56ad3567;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/security/LoginManagerTest.php b/tests/security/LoginManagerTest.php index fad09992..f26cd1eb 100644 --- a/tests/security/LoginManagerTest.php +++ b/tests/security/LoginManagerTest.php @@ -84,10 +84,7 @@ class LoginManagerTest extends TestCase $this->globals = &$GLOBALS; unset($this->globals['IPBANS']); - $this->session = [ - 'expires_on' => time() + 100, - 'ip' => $this->clientIpAddress, - ]; + $this->session = []; $this->sessionManager = new SessionManager($this->session, $this->configManager); $this->loginManager = new LoginManager($this->globals, $this->configManager, $this->sessionManager); @@ -281,12 +278,18 @@ class LoginManagerTest extends TestCase */ public function testCheckLoginStateStaySignedInWithInvalidToken() { + // simulate a previous login + $this->session = [ + 'ip' => $this->clientIpAddress, + 'expires_on' => time() + 100, + ]; $this->loginManager->generateStaySignedInToken($this->clientIpAddress); $this->cookie[LoginManager::$STAY_SIGNED_IN_COOKIE] = 'nope'; $this->loginManager->checkLoginState($this->cookie, $this->clientIpAddress); - $this->assertFalse($this->loginManager->isLoggedIn()); + $this->assertTrue($this->loginManager->isLoggedIn()); + $this->assertTrue(empty($this->session['username'])); } /** @@ -300,6 +303,8 @@ class LoginManagerTest extends TestCase $this->loginManager->checkLoginState($this->cookie, $this->clientIpAddress); $this->assertTrue($this->loginManager->isLoggedIn()); + $this->assertEquals($this->login, $this->session['username']); + $this->assertEquals($this->clientIpAddress, $this->session['ip']); } /**