Browse Source

Fix test cases.

mscherer 5 years ago
parent
commit
0209276c1f

+ 4 - 2
tests/TestCase/Auth/DigestAuthenticateTest.php

@@ -61,12 +61,14 @@ class DigestAuthenticateTest extends TestCase
     {
         parent::setUp();
 
+        $salt = 'foo.bar';
+        Security::setSalt($salt);
         $this->Collection = $this->getMockBuilder(ComponentRegistry::class)->getMock();
         $this->auth = new DigestAuthenticate($this->Collection, [
             'realm' => 'localhost',
             'nonce' => 123,
             'opaque' => '123abc',
-            'secret' => Security::getSalt(),
+            'secret' => $salt,
             'passwordHasher' => 'ShouldNeverTryToUsePasswordHasher',
         ]);
 
@@ -511,7 +513,7 @@ DIGEST;
      */
     protected function generateNonce($secret = null, $expires = 300, $time = null)
     {
-        $secret = $secret ?: Configure::read('Security.salt');
+        $secret = $secret ?: Security::getSalt();
         $time = $time ?: microtime(true);
         $expiryTime = $time + $expires;
         $signatureValue = hash_hmac('sha256', $expiryTime . ':' . $secret, $secret);

+ 1 - 1
tests/TestCase/Auth/FormAuthenticateTest.php

@@ -282,7 +282,7 @@ class FormAuthenticateTest extends TestCase
         $PluginModel = $this->getTableLocator()->get('TestPlugin.AuthUsers');
         $user['id'] = 1;
         $user['username'] = 'gwoo';
-        $user['password'] = password_hash(Security::getSalt() . 'cake', PASSWORD_BCRYPT);
+        $user['password'] = password_hash('cake', PASSWORD_BCRYPT);
         $PluginModel->save(new Entity($user));
 
         $this->auth->setConfig('userModel', 'TestPlugin.AuthUsers');