Browse Source
* upstream: (21 commits) Fixes #1643: Added default value for `Captcha::options` Fixes #1654: Fixed the issue that a new message source object is generated for every new message being translated Allow dash char in ActionColumn’s button names. Added SecurityTest. fixed functional test when enablePrettyUrl is false. fixed composer.json minor doc fix. Fixes #1634: Use masked CSRF tokens to prevent BREACH exploits Use better random CSRF token. GII unique indexes avoid autoIncrement columns updated debug retry params. Added sleep(). Added unit test for ActiveRecord::updateAttributes(). Fixes #1641: Added `BaseActiveRecord::updateAttributes()` Fixed #1504: Debug toolbar isn't loaded successfully in some environments when xdebug is enabled Mongo README.md updated. Fixes #1611: Added `BaseActiveRecord::markAttributeDirty()` Number validator was missing Fixes #1638: prevent table names from being enclosed within curly brackets twice. Unique indexes rules for single columns into array ...tags/2.0.0-beta
24 changed files with 309 additions and 51 deletions
@ -1,8 +1,4 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
// create an application instance to support URL creation before running any test |
||||||
require(__DIR__ . '/../../config/web.php'), |
Yii::createObject(require(__DIR__ . '/../../web/index-test-functional.php')); |
||||||
require(__DIR__ . '/../../config/codeception/functional.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\web\Application($config); |
|
||||||
|
@ -0,0 +1,43 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace yiiunit\framework\helpers; |
||||||
|
|
||||||
|
use yiiunit\TestCase; |
||||||
|
use yii\helpers\Security; |
||||||
|
|
||||||
|
class SecurityTest extends TestCase |
||||||
|
{ |
||||||
|
public function testPasswordHash() |
||||||
|
{ |
||||||
|
$password = 'secret'; |
||||||
|
$hash = Security::generatePasswordHash($password); |
||||||
|
$this->assertTrue(Security::validatePassword($password, $hash)); |
||||||
|
$this->assertFalse(Security::validatePassword('test', $hash)); |
||||||
|
} |
||||||
|
|
||||||
|
public function testHashData() |
||||||
|
{ |
||||||
|
$data = 'known data'; |
||||||
|
$key = 'secret'; |
||||||
|
$hashedData = Security::hashData($data, $key); |
||||||
|
$this->assertFalse($data === $hashedData); |
||||||
|
$this->assertEquals($data, Security::validateData($hashedData, $key)); |
||||||
|
$hashedData[strlen($hashedData) - 1] = 'A'; |
||||||
|
$this->assertFalse(Security::validateData($hashedData, $key)); |
||||||
|
} |
||||||
|
|
||||||
|
public function testEncrypt() |
||||||
|
{ |
||||||
|
$data = 'known data'; |
||||||
|
$key = 'secret'; |
||||||
|
$encryptedData = Security::encrypt($data, $key); |
||||||
|
$this->assertFalse($data === $encryptedData); |
||||||
|
$decryptedData = Security::decrypt($encryptedData, $key); |
||||||
|
$this->assertEquals($data, $decryptedData); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue