mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 08:43:17 +00:00
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Unit\HttpSignatures;
|
||
|
|
||
|
use App\Util\HttpSignatures\SignatureParametersParser;
|
||
|
|
||
|
class SignatureParametersParserTest extends \PHPUnit\Framework\TestCase
|
||
|
{
|
||
|
public function testParseReturnsExpectedAssociativeArray()
|
||
|
{
|
||
|
$parser = new SignatureParametersParser(
|
||
|
'keyId="example",algorithm="hmac-sha1",headers="(request-target) date",signature="b64"'
|
||
|
);
|
||
|
$this->assertEquals(
|
||
|
[
|
||
|
'keyId' => 'example',
|
||
|
'algorithm' => 'hmac-sha1',
|
||
|
'headers' => '(request-target) date',
|
||
|
'signature' => 'b64',
|
||
|
],
|
||
|
$parser->parse()
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @expectedException App\Util\HttpSignatures\SignatureParseException
|
||
|
*/
|
||
|
public function testParseThrowsTypedException()
|
||
|
{
|
||
|
$parser = new SignatureParametersParser('nope');
|
||
|
$parser->parse();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @expectedException App\Util\HttpSignatures\SignatureParseException
|
||
|
*/
|
||
|
public function testParseExceptionForMissingComponents()
|
||
|
{
|
||
|
$parser = new SignatureParametersParser(
|
||
|
'keyId="example",algorithm="hmac-sha1",headers="(request-target) date"'
|
||
|
);
|
||
|
$parser->parse();
|
||
|
}
|
||
|
}
|