Beispiel #1
0
 public function testCookieEncrypt()
 {
     if (!extension_loaded('mcrypt')) {
         $this->markTestSkipped('没有加载mcrypt模块,无法测试cookie加密功能');
     }
     $crypt = array('ciphers' => array(MCRYPT_RIJNDAEL_256, MCRYPT_BLOWFISH, MCRYPT_CAST_256), 'mode' => array(MCRYPT_MODE_ECB, MCRYPT_MODE_CBC, MCRYPT_MODE_CFB, MCRYPT_MODE_OFB, MCRYPT_MODE_NOFB));
     $config_default = array('token' => 'test', 'sign_salt' => 'fdajkfldsjfldsf');
     foreach ($crypt['ciphers'] as $cipher) {
         foreach ($crypt['mode'] as $mode) {
             $config = array_merge($config_default, ['request' => \Owl\Http\Request::factory(), 'response' => new \Tests\Mock\Http\Response(), 'encrypt' => ['uf43jrojfosdf', $cipher, $mode]]);
             \Tests\Mock\Cookie::getInstance()->reset();
             $handler = new \Owl\Context\Cookie($config);
             $handler->set('test', 'abc 中文');
             $handler = new \Owl\Context\Cookie(array_merge($config, ['request' => \Owl\Http\Request::factory(['cookies' => $handler->getConfig('response')->getCookies()]), 'response' => new \Tests\Mock\Http\Response()]));
             $this->assertEquals($handler->get('test'), 'abc 中文', "cipher:{$cipher} mode: {$mode} 加密解密失败");
         }
     }
 }
Beispiel #2
0
 public function __construct()
 {
     $this->cookies = \Tests\Mock\Cookie::getInstance();
 }
Beispiel #3
0
 protected function resetCookie()
 {
     \Tests\Mock\Cookie::getInstance()->reset();
 }