3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Utils_SignerTest
16 class CRM_Utils_SignerTest
extends CiviUnitTestCase
{
18 public function setUp() {
22 public function testSignValidate() {
47 'irrelevant' => 'totally-irrelevant',
109 'validateParams' => [
122 'validateParams' => [
130 foreach ($cases as $caseId => $case) {
131 $signer = new CRM_Utils_Signer('secret', ['a', 'b', 'c']);
132 $signature = $signer->sign($case['signParams']);
134 $this->assertTrue(!empty($signature) && is_string($signature));
136 // same as $signer but physically separate
137 $validator = new CRM_Utils_Signer('secret', ['a', 'b', 'c']);
138 $isValid = $validator->validate($signature, $case['validateParams']);
140 if ($isValid !== $case['isValid']) {
141 $this->fail("Case ${caseId}: Mismatch: " . var_export($case, TRUE));
143 $this->assertTrue(TRUE, 'Validation yielded expected result');