Skip to content

Commit

Permalink
No need for an AbstractSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed May 8, 2015
1 parent 12d1058 commit 5524cb6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 42 deletions.
16 changes: 0 additions & 16 deletions src/Signature/AbstractSignature.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Signature/S3Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Default Amazon S3 signature implementation
* @link http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
*/
class S3Signature extends AbstractSignature
class S3Signature implements SignatureInterface
{
/** @var array Query string values that must be signed */
private $signableQueryString = [
Expand Down
10 changes: 9 additions & 1 deletion src/Signature/SignatureV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Implementation of Signature Version 2
* @link http://aws.amazon.com/articles/1928
*/
class SignatureV2 extends AbstractSignature
class SignatureV2 implements SignatureInterface
{
public function signRequest(
RequestInterface $request,
Expand Down Expand Up @@ -43,6 +43,14 @@ public function signRequest(
return $request->withBody(Psr7\stream_for(http_build_query($params)));
}

public function createPresignedUrl(
RequestInterface $request,
CredentialsInterface $credentials,
$expires
) {
throw new \BadMethodCallException(__METHOD__ . ' not implemented');
}

private function getCanonicalizedParameterString(array $params)
{
unset($params['Signature']);
Expand Down
2 changes: 1 addition & 1 deletion src/Signature/SignatureV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Signature Version 4
* @link http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
*/
class SignatureV4 extends AbstractSignature
class SignatureV4 implements SignatureInterface
{
const ISO8601_BASIC = 'Ymd\THis\Z';

Expand Down
23 changes: 0 additions & 23 deletions tests/Signature/AbstractSignatureTest.php

This file was deleted.

11 changes: 11 additions & 0 deletions tests/Signature/SignatureV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ public function testSignsRequestsWithSecurityToken()
. "Test=123&Other=456&Timestamp=Fri%2C+09+Sep+2011+23%3A36%3A00+GMT&SignatureVersion=2&SignatureMethod=HmacSHA256&AWSAccessKeyId=AKIDEXAMPLE&SecurityToken=foo&Signature=NzQ9b5Kx6qlKj2UIK6QHIrmq5ypogh9PhBHVXKA4RU4%3D";
$this->assertEquals($expected, Psr7\str($result));
}

/**
* @expectedException \BadMethodCallException
*/
public function testThrowsWhenNotImplemented()
{
$mock = $sig = new SignatureV2();
$request = new Request('GET', 'http://foo.com');
$credentials = new Credentials('foo', 'bar');
$mock->createPresignedUrl($request, $credentials, '+10 minutes');
}
}

0 comments on commit 5524cb6

Please sign in to comment.