diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-07-31 11:07:32 -0700 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-07-31 11:07:32 -0700 |
commit | 96e3411f2e5895f9aa3eff5db58f0ed3e6183471 (patch) | |
tree | b55b5905c1a10e97519bf7768f48fcdb2e7e2503 /_test | |
parent | 07ff0babae240ba072a3bc8b83a989c4305c24cd (diff) | |
parent | 7b650cef79bb603087a8ef43b22a1f7c3d86b7ef (diff) | |
download | rpg-96e3411f2e5895f9aa3eff5db58f0ed3e6183471.tar.gz rpg-96e3411f2e5895f9aa3eff5db58f0ed3e6183471.tar.bz2 |
Merge pull request #242 from splitbrain/aes_prng
Add AES encryption and better random numbers FS#2685
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/auth_encryption.test.php | 12 | ||||
-rw-r--r-- | _test/tests/inc/auth_random.test.php | 20 |
2 files changed, 32 insertions, 0 deletions
diff --git a/_test/tests/inc/auth_encryption.test.php b/_test/tests/inc/auth_encryption.test.php new file mode 100644 index 000000000..041eba00e --- /dev/null +++ b/_test/tests/inc/auth_encryption.test.php @@ -0,0 +1,12 @@ +<?php + +/** + * Tests the auth_decrypt and auth_encrypt-functions + */ +class auth_encryption_test extends DokuWikiTest { + function testDeEncrypt() { + $data = "OnA28asdfäakgß*+!\"+*"; + $secret = "oeaf1öasdöflk§"; + $this->assertEquals($data, auth_decrypt(auth_encrypt($data, $secret), $secret)); + } +} diff --git a/_test/tests/inc/auth_random.test.php b/_test/tests/inc/auth_random.test.php new file mode 100644 index 000000000..f380eba53 --- /dev/null +++ b/_test/tests/inc/auth_random.test.php @@ -0,0 +1,20 @@ +<?php + +/** + * Tests the random generator functions + */ +class auth_random_test extends DokuWikiTest { + function testRandomRange() { + $rand = auth_random(300, 2000); + $this->assertTrue($rand <= 2000, 'The generated number was above the limit'); + $this->assertTrue($rand >= 300, 'The generate number was too low'); + } + + function testLargeRandoms() { + $min = (1 << 30); + $max = $min + (1 << 33) + 17; + $rand = auth_random($min, $max); + $this->assertTrue($rand >= $min, 'The generated number was too low'); + $this->assertTrue($rand <= $max, 'The generated number was too high'); + } +} |