From 348bd9d3987c42b9204519b22b7238e8dc19e514 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sun, 17 Jul 2011 23:12:50 +0000 Subject: TSecurityManager: remove additional right padding added by mcrypt_decrypt TSecurityManagerTest: loop through different string length to take account of mcrypt's block cipher padding TAPCCacheTest: fixed static member usage THttpRequestTest: fixed testRequestWithUrlMapping test --- tests/unit/Security/TSecurityManagerTest.php | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'tests/unit/Security/TSecurityManagerTest.php') diff --git a/tests/unit/Security/TSecurityManagerTest.php b/tests/unit/Security/TSecurityManagerTest.php index 731547c9..2daf6ede 100644 --- a/tests/unit/Security/TSecurityManagerTest.php +++ b/tests/unit/Security/TSecurityManagerTest.php @@ -83,17 +83,26 @@ class TSecurityManagerTest extends PHPUnit_Framework_TestCase { public function testEncryptDecrypt() { $sec=new TSecurityManager (); $sec->init (null); - $sec->setEncryptionKey ('aKey'); - try { - $encrypted = $sec->encrypt('a text'); - } catch (TNotSupportedException $e) { - self::markTestSkipped('mcrypt extension not loaded'); - return; + // loop through different string size + $testText = md5('a text (not) full of entrophy'); + for($i=1; $isetEncryptionKey ('aKey'); + $plainText = substr($testText, 0, $i); + try { + $encrypted = $sec->encrypt($plainText); + } catch (TNotSupportedException $e) { + self::markTestSkipped('mcrypt extension not loaded'); + return; + } + $decrypted = $sec->decrypt($encrypted); + + self::assertEquals($plainText,$decrypted); + + // try change key + $sec->setEncryptionKey ('anotherKey'); + self::assertNotEquals($plainText, $sec->decrypt($encrypted)); } - self::assertEquals('a text', $sec->decrypt($encrypted)); - // try change key - $sec->setEncryptionKey ('anotherKey'); - self::assertNotEquals('a text', $sec->decrypt($encrypted)); } -- cgit v1.2.3