38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use GuzzleHttp\Psr7\Uri;
|
||
|
|
use Uwil\ArcadiaGenesisPhpClient\Lib\HttpMethod;
|
||
|
|
use Uwil\ArcadiaGenesisPhpClient\Utils\Utils;
|
||
|
|
|
||
|
|
describe('Signature calculation', function (): void {
|
||
|
|
|
||
|
|
it('can calculate signature on get method', function (): void {
|
||
|
|
// Given
|
||
|
|
$host = 'sub.example.net';
|
||
|
|
$secret = 'MYSUPERSECRET';
|
||
|
|
$data = [
|
||
|
|
'c_cols' => 'NOM_FIC',
|
||
|
|
'table' => 'RU_PERSONNE_SIRH',
|
||
|
|
];
|
||
|
|
$queryString = http_build_query($data, '', '&', \PHP_QUERY_RFC3986);
|
||
|
|
$method = HttpMethod::GET;
|
||
|
|
$uri = new Uri("https://{$host}/get?{$queryString}");
|
||
|
|
$timestamp = new \DateTimeImmutable('2026-01-01 00:00:00', new \DateTimeZone('CEST'));
|
||
|
|
|
||
|
|
// When
|
||
|
|
|
||
|
|
$signature = Utils::calculateSignature(
|
||
|
|
$method,
|
||
|
|
$uri,
|
||
|
|
'',
|
||
|
|
$secret,
|
||
|
|
$timestamp
|
||
|
|
);
|
||
|
|
|
||
|
|
// Then
|
||
|
|
expect($signature)->toBe('IUwJIBCsmV4n5ahm09uaWQFwFMomjV08KtTDvVjFeTc=');
|
||
|
|
});
|
||
|
|
});
|