Skip to content

Commit

Permalink
Replace deprecated Guzzle PSR7 calls (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
NFarrington authored Apr 3, 2023
1 parent f870056 commit 1510e60
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion features/bootstrap/Aws/Test/Integ/MultipartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MultipartContext implements Context, SnippetAcceptingContext
*/
public function iHaveASeekableReadStream()
{
$this->stream = Psr7\stream_for(Psr7\try_fopen(self::$tempFile, 'r'));
$this->stream = Psr7\Utils::streamFor(Psr7\Utils::tryFopen(self::$tempFile, 'r'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions features/bootstrap/Aws/Test/Integ/S3Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function iSendThePreSignedRequest()
public function iChangeTheBodyOfThePreSignedRequestToBe($body)
{
$this->presignedRequest = $this->presignedRequest
->withBody(Psr7\stream_for($body));
->withBody(Psr7\Utils::streamFor($body));
}

/**
Expand All @@ -157,7 +157,7 @@ public function iChangeTheBodyOfThePreSignedRequestToBe($body)
public function iHaveAnClientAndIHaveAFile()
{
$this->s3Client = self::getSdk()->createS3();
$this->stream = Psr7\stream_for(Psr7\try_fopen(self::$tempFile, 'r'));
$this->stream = Psr7\Utils::streamFor(Psr7\Utils::tryFopen(self::$tempFile, 'r'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion features/bootstrap/Aws/Test/PerformanceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function iUploadTheFile()
public function thenDownloadTheFile()
{
$this->addMockResults($this->s3Client, [new Result([
'Body' => Psr7\stream_for(Psr7\try_fopen($this->tempFilePath, 'rb')),
'Body' => Psr7\Utils::streamFor(Psr7\Utils::tryFopen($this->tempFilePath, 'rb')),
])]);

$this->s3Client->getObject([
Expand Down
4 changes: 2 additions & 2 deletions src/Signature/SignatureV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function signRequest(
RequestInterface $request,
CredentialsInterface $credentials
) {
$params = Psr7\parse_query($request->getBody());
$params = Psr7\Query::parse($request->getBody());
$params['Timestamp'] = gmdate('c');
$params['SignatureVersion'] = '2';
$params['SignatureMethod'] = 'HmacSHA256';
Expand All @@ -40,7 +40,7 @@ public function signRequest(
)
);

return $request->withBody(Psr7\stream_for(http_build_query($params)));
return $request->withBody(Psr7\Utils::streamFor(http_build_query($params)));
}

public function presign(
Expand Down
4 changes: 2 additions & 2 deletions tests/Signature/SignatureV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testSignsRequestsWithSecurityToken()
. "Host: foo.com\r\n"
. "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
. "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));
$this->assertEquals($expected, Psr7\Message::toString($result));
}

public function testCanSignBodyWithStructureShapes()
Expand All @@ -52,7 +52,7 @@ public function testCanSignBodyWithStructureShapes()
. "Host: foo.com\r\n"
. "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
. "Test=123&Other=456&Nested.1.Name=foo&Nested.1.Value=bar&Timestamp=Fri%2C+09+Sep+2011+23%3A36%3A00+GMT&SignatureVersion=2&SignatureMethod=HmacSHA256&AWSAccessKeyId=AKIDEXAMPLE&SecurityToken=foo&Signature=MbXBpe7leHe6O49B0CU86h%2By0GKFfQ9rBVCNvQWQlB0%3D";
$this->assertEquals($expected, Psr7\str($result));
$this->assertEquals($expected, Psr7\Message::toString($result));
}

/**
Expand Down

0 comments on commit 1510e60

Please sign in to comment.