From 51df27a9ecc0b70c63fbdd241a062931e442dd92 Mon Sep 17 00:00:00 2001 From: Jeremy Lindblom Date: Mon, 11 May 2015 16:32:35 -0700 Subject: [PATCH] Fixes a bug in the EC2 CopySnapshotListener so it works with temporary credentials. --- src/Aws/Ec2/CopySnapshotListener.php | 7 +++---- tests/Aws/Tests/Ec2/CopySnapshotListenerTest.php | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Aws/Ec2/CopySnapshotListener.php b/src/Aws/Ec2/CopySnapshotListener.php index c5df864fd8..d1e2ace155 100644 --- a/src/Aws/Ec2/CopySnapshotListener.php +++ b/src/Aws/Ec2/CopySnapshotListener.php @@ -59,10 +59,9 @@ private function createPresignedUrl( ) { // Create a temporary client used to generate the presigned URL $newClient = Ec2Client::factory(array( - 'region' => $command['SourceRegion'], - 'signature' => 'v4', - 'key' => $client->getCredentials()->getAccessKeyId(), - 'secret' => $client->getCredentials()->getSecretKey() + 'region' => $command['SourceRegion'], + 'signature' => 'v4', + 'credentials' => $client->getCredentials(), )); $preCommand = $newClient->getCommand( diff --git a/tests/Aws/Tests/Ec2/CopySnapshotListenerTest.php b/tests/Aws/Tests/Ec2/CopySnapshotListenerTest.php index 79832f9521..eb8ac4133c 100644 --- a/tests/Aws/Tests/Ec2/CopySnapshotListenerTest.php +++ b/tests/Aws/Tests/Ec2/CopySnapshotListenerTest.php @@ -1,6 +1,7 @@ getServiceBuilder()->get('ec2'); - $client->setRegion('us-east-1'); + $client = $this->getServiceBuilder()->get('ec2', array( + 'credentials' => new Credentials('foo', 'bar', 'baz', strtotime('+1 hour')), + 'region' => 'us-east-1' + )); + $command = $client->getCommand('CopySnapshot', array( 'SourceRegion' => 'eu-west-1', 'SourceSnapshotId' => 'foo' @@ -20,6 +24,7 @@ public function testAddsPresignedUrlBeforeSending() $this->assertContains('DestinationRegion=us-east-1', $r); $this->assertContains('SourceRegion%3Deu-west-1', $r); $this->assertContains('PresignedUrl=https%3A%2F%2Fec2.eu-west-1.amazonaws.com', $r); + $this->assertContains('X-Amz-Security-Token%3Dbaz', $r); } public function testIgnoresOtherOperations()