summaryrefslogtreecommitdiff
path: root/tests/unit/Security/TSecurityManagerTest.php
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-07-17 23:12:50 +0000
committerctrlaltca@gmail.com <>2011-07-17 23:12:50 +0000
commit348bd9d3987c42b9204519b22b7238e8dc19e514 (patch)
tree5609d43a68b0a523ad2919788ca0070df7e4ec89 /tests/unit/Security/TSecurityManagerTest.php
parent920f78939adcdb62f5e6ac9368928bd3a0fa41fc (diff)
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
Diffstat (limited to 'tests/unit/Security/TSecurityManagerTest.php')
-rw-r--r--tests/unit/Security/TSecurityManagerTest.php29
1 files changed, 19 insertions, 10 deletions
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; $i<strlen($testText); $i++)
+ {
+ $sec->setEncryptionKey ('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));
}