]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/security/LoginManagerTest.php
Merge pull request #1182 from ArthurHoaro/feature/session-protection-stay-login
[github/shaarli/Shaarli.git] / tests / security / LoginManagerTest.php
index f26cd1eb8635c0bd21f8f4ab68043b7569562ddf..7b0262b32c128871841cf9d98aaf83e129ffacca 100644 (file)
@@ -2,7 +2,8 @@
 namespace Shaarli\Security;
 
 require_once 'tests/utils/FakeConfigManager.php';
-use \PHPUnit\Framework\TestCase;
+
+use PHPUnit\Framework\TestCase;
 
 /**
  * Test coverage for LoginManager
@@ -259,6 +260,20 @@ class LoginManagerTest extends TestCase
         );
     }
 
+    /**
+     * Generate a token depending on the user credentials with session protected disabled
+     */
+    public function testGenerateStaySignedInTokenSessionProtectionDisabled()
+    {
+        $this->configManager->set('security.session_protection_disabled', true);
+        $this->loginManager->generateStaySignedInToken($this->clientIpAddress);
+
+        $this->assertEquals(
+            sha1($this->passwordHash . $this->salt),
+            $this->loginManager->getStaySignedInToken()
+        );
+    }
+
     /**
      * Check user login - Shaarli has not yet been configured
      */