mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-31 17:19:59 +09:00
17515512: JanRain php-openid library included, normalization fix
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5137 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f541dd59b9
commit
658c0e6dbc
219 changed files with 41415 additions and 10 deletions
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Tests for the CryptUtil functions.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: See the COPYING file included in this distribution.
|
||||
*
|
||||
* @package OpenID
|
||||
* @author JanRain, Inc. <openid@janrain.com>
|
||||
* @copyright 2005 Janrain, Inc.
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*/
|
||||
|
||||
require_once 'PHPUnit.php';
|
||||
require_once 'Auth/OpenID/CryptUtil.php';
|
||||
|
||||
class Tests_Auth_OpenID_CryptUtil extends PHPUnit_TestCase {
|
||||
function test_length()
|
||||
{
|
||||
$cases = array(1, 10, 255);
|
||||
foreach ($cases as $length) {
|
||||
$data = Auth_OpenID_CryptUtil::getBytes($length);
|
||||
$this->assertEquals(strlen($data), $length);
|
||||
}
|
||||
}
|
||||
|
||||
function test_different()
|
||||
{
|
||||
$num_iterations = 100;
|
||||
$data_length = 20;
|
||||
|
||||
$data = Auth_OpenID_CryptUtil::getBytes($num_iterations);
|
||||
for ($i = 0; $i < $num_iterations; $i++) {
|
||||
$last = $data;
|
||||
$data = Auth_OpenID_CryptUtil::getBytes($data_length);
|
||||
$this->assertFalse($data == $last);
|
||||
}
|
||||
}
|
||||
|
||||
function test_cryptrand()
|
||||
{
|
||||
// It's possible, but HIGHLY unlikely that a correct
|
||||
// implementation will fail by returning the same number twice
|
||||
|
||||
$s = Auth_OpenID_CryptUtil::getBytes(32);
|
||||
$t = Auth_OpenID_CryptUtil::getBytes(32);
|
||||
$this->assertEquals(strlen($s), 32);
|
||||
$this->assertEquals(strlen($t), 32);
|
||||
$this->assertFalse($s == $t);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue