summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-10-05 23:04:19 +0200
committerAndrey Andreev <narf@devilix.net>2014-10-05 23:04:19 +0200
commit4a485a73d64a8bebc7625aabc5fdc361d5e7dc56 (patch)
treecb18690c4de1c6ca008227260f9dd0cd2b9279d2 /tests/codeigniter/libraries
parent39ec29585b7cdca7edc1a0757c913a13a2ee4f85 (diff)
parentd444d445ed0458a352ecb9ff79ffd158677ee805 (diff)
Merge branch 'develop' into feature/session
Diffstat (limited to 'tests/codeigniter/libraries')
-rw-r--r--tests/codeigniter/libraries/Encrypt_test.php34
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php9
2 files changed, 9 insertions, 34 deletions
diff --git a/tests/codeigniter/libraries/Encrypt_test.php b/tests/codeigniter/libraries/Encrypt_test.php
index a08db8ed0..ced763301 100644
--- a/tests/codeigniter/libraries/Encrypt_test.php
+++ b/tests/codeigniter/libraries/Encrypt_test.php
@@ -1,15 +1,21 @@
<?php
-
+/**
+ * @requires extension mcrypt
+ */
class Encrypt_test extends CI_TestCase {
public function set_up()
{
+ if ( ! extension_loaded('mcrypt'))
+ {
+ return;
+ }
+
$this->encrypt = new Mock_Libraries_Encrypt();
$this->ci_instance_var('encrypt', $this->encrypt);
$this->ci_set_config('encryption_key', "Encryptin'glike@boss!");
$this->msg = 'My secret message';
- $this->mcrypt = extension_loaded('mcrypt');
}
// --------------------------------------------------------------------
@@ -40,12 +46,6 @@ class Encrypt_test extends CI_TestCase {
public function test_default_cipher()
{
- if ( ! $this->mcrypt)
- {
- $this->markTestSkipped('MCrypt not available');
- return;
- }
-
$this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
}
@@ -53,12 +53,6 @@ class Encrypt_test extends CI_TestCase {
public function test_set_cipher()
{
- if ( ! $this->mcrypt)
- {
- $this->markTestSkipped('MCrypt not available');
- return;
- }
-
$this->encrypt->set_cipher(MCRYPT_BLOWFISH);
$this->assertEquals('blowfish', $this->encrypt->get_cipher());
}
@@ -67,12 +61,6 @@ class Encrypt_test extends CI_TestCase {
public function test_default_mode()
{
- if ( ! $this->mcrypt)
- {
- $this->markTestSkipped('MCrypt not available');
- return;
- }
-
$this->assertEquals('cbc', $this->encrypt->get_mode());
}
@@ -80,12 +68,6 @@ class Encrypt_test extends CI_TestCase {
public function test_set_mode()
{
- if ( ! $this->mcrypt)
- {
- $this->markTestSkipped('MCrypt not available');
- return;
- }
-
$this->encrypt->set_mode(MCRYPT_MODE_CFB);
$this->assertEquals('cfb', $this->encrypt->get_mode());
}
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index 759d7cdac..f457fe325 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -141,7 +141,6 @@ class Encryption_test extends CI_TestCase {
$this->assertTrue(is_array($this->encryption->__get_params($params)));
- $params['iv'] = NULL;
$params['base64'] = TRUE;
$params['hmac_digest'] = 'sha512';
@@ -150,7 +149,6 @@ class Encryption_test extends CI_TestCase {
'cipher' => 'aes-128',
'mode' => 'cbc',
'key' => str_repeat("\x0", 16),
- 'iv' => str_repeat("\x0", 16),
'raw_data' => TRUE,
'hmac_key' => str_repeat("\x0", 16),
'hmac_digest' => 'sha256'
@@ -216,22 +214,17 @@ class Encryption_test extends CI_TestCase {
$this->assertFalse($this->encryption->encrypt($message, array('foo')));
$this->assertFalse($this->encryption->decrypt($message, array('foo')));
- // Custom IV (we'll check it), no HMAC, binary output
+ // No HMAC, binary output
$params = array(
'cipher' => 'tripledes',
'mode' => 'cfb',
'key' => str_repeat("\x1", 16),
- 'iv' => str_repeat("\x2", 8),
'base64' => FALSE,
'hmac' => FALSE
);
$ciphertext = $this->encryption->encrypt($message, $params);
- $this->assertEquals(0, strncmp($params['iv'], $ciphertext, 8));
- // IV should be found in the cipher-text, no matter if it was supplied or not
- $this->assertEquals($message, $this->encryption->decrypt($ciphertext, $params));
- unset($params['iv']);
$this->assertEquals($message, $this->encryption->decrypt($ciphertext, $params));
}