28 lines
991 B
PHP
28 lines
991 B
PHP
|
<?php
|
||
|
// HmacVerificationTest.php
|
||
|
// Created: 2024-08-13
|
||
|
// Updated: 2024-08-13
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||
|
use Aiwass\HmacVerificationProvider;
|
||
|
|
||
|
#[CoversClass(HmacVerificationProvider::class)]
|
||
|
final class HmacVerificationTest extends TestCase {
|
||
|
public function testProcedureEnforce(): void {
|
||
|
$provider = new HmacVerificationProvider(fn() => 'meow');
|
||
|
$action = 'test';
|
||
|
$params = 'meow=cool&the=bean';
|
||
|
|
||
|
$queryToken = $provider->sign(false, $action, $params);
|
||
|
$this->assertTrue($provider->verify($queryToken, false, $action, $params));
|
||
|
$this->assertFalse($provider->verify($queryToken, true, $action, $params));
|
||
|
|
||
|
$procedureToken = $provider->sign(true, $action, $params);
|
||
|
$this->assertTrue($provider->verify($procedureToken, true, $action, $params));
|
||
|
$this->assertFalse($provider->verify($procedureToken, false, $action, $params));
|
||
|
}
|
||
|
}
|