51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Auth;
|
|
|
|
use Uwil\ArcadiaApiPhpClient\Auth\RequestSignature;
|
|
|
|
describe('RequestSignature Test', function () {
|
|
it('can instanciate a valid request signature', function () {
|
|
// GIVEN
|
|
$value = 'some-signature-value';
|
|
$bodyHash = 'some-body-hash';
|
|
|
|
// WHEN
|
|
$requestSignature = new RequestSignature(
|
|
$value,
|
|
$bodyHash
|
|
);
|
|
|
|
// THEN
|
|
expect($requestSignature->value)->toBe($value);
|
|
expect($requestSignature->bodyHash)->toBe($bodyHash);
|
|
});
|
|
});
|
|
|
|
describe('RequestSignature validation rules', function () {
|
|
it('throws an exception if the signature value is empty', function () {
|
|
// GIVEN
|
|
$value = '';
|
|
$bodyHash = 'some-body-hash';
|
|
|
|
// THEN
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
// WHEN
|
|
new RequestSignature($value, $bodyHash);
|
|
});
|
|
|
|
it('throws an exception if the body hash is empty', function () {
|
|
// GIVEN
|
|
$value = 'some-signature-value';
|
|
$bodyHash = '';
|
|
|
|
// THEN
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
// WHEN
|
|
new RequestSignature($value, $bodyHash);
|
|
});
|
|
});
|