123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace HttpSignatures\tests;
- use 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 HttpSignatures\SignatureParseException
- */
- public function testParseThrowsTypedException()
- {
- $parser = new SignatureParametersParser('nope');
- $parser->parse();
- }
- /**
- * @expectedException HttpSignatures\SignatureParseException
- */
- public function testParseExceptionForMissingComponents()
- {
- $parser = new SignatureParametersParser(
- 'keyId="example",algorithm="hmac-sha1",headers="(request-target) date"'
- );
- $parser->parse();
- }
- }
|