flashwave
93ec139171
- Aiwass -> RPCii - Swapped the meaning of "Procedure" and "Action" - IRpcActionHandler is now RpcHandler, abstract class no longer exists like Index - Anything suffixed by Trait is now suffixed by Common - All I prefixes on interfaces are gone - A PHP StreamWrapper implementation of HttpRequest added as a fallback for when cURL isnt installed - HttpRpcServer now hosts on /_rpcii instead of /_aiwass - Packagist package is now flashii/rpcii instead of flashwave/aiwass That's probably all of it but I probably forgor.
27 lines
999 B
PHP
27 lines
999 B
PHP
<?php
|
|
// HmacVerificationTest.php
|
|
// Created: 2024-08-13
|
|
// Updated: 2024-11-13
|
|
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use RPCii\HmacVerificationProvider;
|
|
|
|
#[CoversClass(HmacVerificationProvider::class)]
|
|
final class HmacVerificationTest extends TestCase {
|
|
public function testActionEnforce(): void {
|
|
$provider = new HmacVerificationProvider(fn() => 'meow');
|
|
$procedure = 'test';
|
|
$params = 'meow=cool&the=bean';
|
|
|
|
$queryToken = $provider->sign(false, $procedure, $params);
|
|
$this->assertTrue($provider->verify($queryToken, false, $procedure, $params));
|
|
$this->assertFalse($provider->verify($queryToken, true, $procedure, $params));
|
|
|
|
$actionToken = $provider->sign(true, $procedure, $params);
|
|
$this->assertTrue($provider->verify($actionToken, true, $procedure, $params));
|
|
$this->assertFalse($provider->verify($actionToken, false, $procedure, $params));
|
|
}
|
|
}
|