Added to the Mibew API the ability to use empty string as a signature

This commit is contained in:
Dmitriy Simushev 2012-08-03 11:05:47 +00:00
parent 555898e446
commit 31b6d96fc9
2 changed files with 2 additions and 16 deletions

View File

@ -260,20 +260,6 @@ class MibewAPITest extends PHPUnit_Framework_TestCase {
); );
} }
// Wrong package. Signature element is empty.
$wrong_package = array('signature' => '');
// Try to catch MibewAPIException with MibewAPIException::EMPTY_SIGNATURE code
try {
$api->checkPackage($wrong_package, $trusted_signatures);
$this->fail("Exception must be thrown");
} catch (MibewAPIException $e) {
$this->assertEquals(
MibewAPIException::EMPTY_SIGNATURE,
$e->getCode()
);
}
// Wrong package. Signature is wrong. // Wrong package. Signature is wrong.
$wrong_package = array('signature' => 'wrong_signature'); $wrong_package = array('signature' => 'wrong_signature');

View File

@ -67,7 +67,7 @@ Class MibewAPI {
*/ */
public function checkPackage($package, $trusted_signatures) { public function checkPackage($package, $trusted_signatures) {
// Check signature // Check signature
if (empty($package['signature'])) { if (! isset($package['signature'])) {
throw new MibewAPIException( throw new MibewAPIException(
"Package signature is empty", "Package signature is empty",
MibewAPIException::EMPTY_SIGNATURE MibewAPIException::EMPTY_SIGNATURE
@ -298,7 +298,7 @@ Class MibewAPI {
MibewAPIException::RESULT_FUNCTION_ALREADY_EXISTS MibewAPIException::RESULT_FUNCTION_ALREADY_EXISTS
); );
} }
// Furst 'result' function found // First 'result' function found
$result_function = $function; $result_function = $function;
} }
} }