blob: 21ac85f03a0bd896ecade151c3c78a4548be4ff2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<?php
class Encrypt_test extends CI_TestCase {
public function set_up()
{
$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');
}
// --------------------------------------------------------------------
public function test_encode()
{
$this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg));
}
// --------------------------------------------------------------------
public function test_decode()
{
$encoded_msg = $this->encrypt->encode($this->msg);
$this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg));
}
// --------------------------------------------------------------------
public function test_optional_key()
{
$key = 'Ohai!ù0129°03182%HD1892P0';
$encoded_msg = $this->encrypt->encode($this->msg, $key);
$this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key));
}
// --------------------------------------------------------------------
public function test_default_cipher()
{
if ( ! $this->mcrypt)
{
$this->markTestSkipped('MCrypt not available');
return;
}
$this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
}
// --------------------------------------------------------------------
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());
}
// --------------------------------------------------------------------
public function test_default_mode()
{
if ( ! $this->mcrypt)
{
$this->markTestSkipped('MCrypt not available');
return;
}
$this->assertEquals('cbc', $this->encrypt->get_mode());
}
// --------------------------------------------------------------------
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());
}
}
|