Skip to content

Commit

Permalink
Provide all iterations via the data provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 2, 2016
1 parent ee65430 commit 7ec0a84
Showing 1 changed file with 46 additions and 40 deletions.
86 changes: 46 additions & 40 deletions framework/Pgp/test/Horde/Pgp/Backend/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,55 +298,50 @@ public function encryptProvider()
* @dataProvider encryptSymmetricProvider
* @depends testDecryptSymmetric
*/
public function testEncryptSymmetric($data, $pass)
public function testEncryptSymmetric($compress, $cipher, $data, $pass)
{
$ciphers = array(
'3DES', 'CAST5', 'AES128', 'AES192', 'AES256', 'Twofish'
$result = $this->_pgp->encryptSymmetric(
$data,
$pass,
array(
'cipher' => $cipher,
'compress' => $compress
)
);
$compress = array(
'NONE', 'ZIP', 'ZLIB'

$this->assertInstanceOf(
'Horde_Pgp_Element_Message',
$result
);

foreach ($compress as $c1) {
foreach ($ciphers as $c2) {
$result = $this->_pgp->encryptSymmetric(
$data,
$pass,
array(
'cipher' => $c2,
'compress' => $c1
)
);

$this->assertInstanceOf(
'Horde_Pgp_Element_Message',
$result
);

$this->assertEquals(
1 + count($pass),
count($result->message->packets)
);

foreach ($pass as $val) {
$result2 = $this->_pgp->decryptSymmetric(
$result,
$val
);
$result2_sigs = $result2->message->signatures();

$this->assertEquals(
$data,
$result2_sigs[0][0]->data
);
}
}
$this->assertEquals(
1 + count($pass),
count($result->message->packets)
);

foreach ($pass as $val) {
$result2 = $this->_pgp->decryptSymmetric(
$result,
$val
);
$result2_sigs = $result2->message->signatures();

$this->assertEquals(
$data,
$result2_sigs[0][0]->data
);
}
}

public function encryptSymmetricProvider()
{
return array(
$ciphers = array(
'3DES', 'CAST5', 'AES128', 'AES192', 'AES256', 'Twofish'
);
$compress = array(
'NONE', 'ZIP', 'ZLIB'
);
$fixtures = array(
array(
$this->_getFixture('clear.txt'),
array(
Expand All @@ -361,6 +356,17 @@ public function encryptSymmetricProvider()
)
)
);

$data = array();
foreach ($compress as $c1) {
foreach ($ciphers as $c2) {
foreach ($fixtures as $f) {
$data[] = array($c1, $c2, $f[0], $f[1]);
}
}
}

return $data;
}

/**
Expand Down

0 comments on commit 7ec0a84

Please sign in to comment.