Skip to content
Snippets Groups Projects
Commit 4d587201 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move CryptoTest to SimpleSAML\Test\Utils\CryptoTest.

parent dd9facac
No related branches found
No related tags found
No related merge requests found
<?php <?php
namespace SimpleSAML\Test\Utils;
/** /**
* Tests for SimpleSAML\Utils\Crypto. * Tests for SimpleSAML\Utils\Crypto.
*/ */
class CryptoTest extends PHPUnit_Framework_TestCase class CryptoTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* Test invalid input provided to the aesDecrypt() method. * Test invalid input provided to the aesDecrypt() method.
* *
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
*
* @covers SimpleSAML\Utils\Crypto::_aesDecrypt
*/ */
public function testAesDecryptBadInput() public function testAesDecryptBadInput()
{ {
$m = new ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt'); $m = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt');
$m->setAccessible(true); $m->setAccessible(true);
$m->invokeArgs(null, array(array(), 'SECRET')); $m->invokeArgs(null, array(array(), 'SECRET'));
...@@ -24,11 +28,13 @@ class CryptoTest extends PHPUnit_Framework_TestCase ...@@ -24,11 +28,13 @@ class CryptoTest extends PHPUnit_Framework_TestCase
/** /**
* Test invalid input provided to the aesEncrypt() method. * Test invalid input provided to the aesEncrypt() method.
* *
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
*
* @covers SimpleSAML\Utils\Crypto::_aesEncrypt
*/ */
public function testAesEncryptBadInput() public function testAesEncryptBadInput()
{ {
$m = new ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesEncrypt'); $m = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesEncrypt');
$m->setAccessible(true); $m->setAccessible(true);
$m->invokeArgs(null, array(array(), 'SECRET')); $m->invokeArgs(null, array(array(), 'SECRET'));
...@@ -38,6 +44,8 @@ class CryptoTest extends PHPUnit_Framework_TestCase ...@@ -38,6 +44,8 @@ class CryptoTest extends PHPUnit_Framework_TestCase
/** /**
* Test that aesDecrypt() works properly, being able to decrypt some previously known (and correct) * Test that aesDecrypt() works properly, being able to decrypt some previously known (and correct)
* ciphertext. * ciphertext.
*
* @covers SimpleSAML\Utils\Crypto::_aesDecrypt
*/ */
public function testAesDecrypt() public function testAesDecrypt()
{ {
...@@ -46,7 +54,7 @@ class CryptoTest extends PHPUnit_Framework_TestCase ...@@ -46,7 +54,7 @@ class CryptoTest extends PHPUnit_Framework_TestCase
} }
$secret = 'SUPER_SECRET_SALT'; $secret = 'SUPER_SECRET_SALT';
$m = new ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt'); $m = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt');
$m->setAccessible(true); $m->setAccessible(true);
$plaintext = 'SUPER_SECRET_TEXT'; $plaintext = 'SUPER_SECRET_TEXT';
...@@ -57,6 +65,9 @@ class CryptoTest extends PHPUnit_Framework_TestCase ...@@ -57,6 +65,9 @@ class CryptoTest extends PHPUnit_Framework_TestCase
/** /**
* Test that aesEncrypt() produces ciphertexts that aesDecrypt() can decrypt. * Test that aesEncrypt() produces ciphertexts that aesDecrypt() can decrypt.
*
* @covers SimpleSAML\Utils\Crypto::_aesDecrypt
* @covers SimpleSAML\Utils\Crypto::_aesEncrypt
*/ */
public function testAesEncrypt() public function testAesEncrypt()
{ {
...@@ -65,8 +76,8 @@ class CryptoTest extends PHPUnit_Framework_TestCase ...@@ -65,8 +76,8 @@ class CryptoTest extends PHPUnit_Framework_TestCase
} }
$secret = 'SUPER_SECRET_SALT'; $secret = 'SUPER_SECRET_SALT';
$e = new ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesEncrypt'); $e = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesEncrypt');
$d = new ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt'); $d = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt');
$e->setAccessible(true); $e->setAccessible(true);
$d->setAccessible(true); $d->setAccessible(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment