forked from aws/aws-sdk-php
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
namespace Aws\Tests\S3\Integration; | ||
|
||
use Aws\S3\S3Client; | ||
use Aws\S3\Model\ClearBucket; | ||
|
||
/** | ||
* @group integration | ||
*/ | ||
class Sigv4Test extends \Aws\Tests\IntegrationTestCase | ||
{ | ||
/** @var S3Client */ | ||
protected $client; | ||
|
||
/** @var string */ | ||
protected $bucket; | ||
|
||
public static function setUpBeforeClass() | ||
{ | ||
$client = self::getServiceBuilder()->get('s3', array('signature' => 'v4')); | ||
$bucket = self::getResourcePrefix() . '-s3-test'; | ||
$client->createBucket(array('Bucket' => $bucket)); | ||
self::log("Waiting for the bucket to exist"); | ||
$client->waitUntil('bucket_exists', array('Bucket' => $bucket)); | ||
sleep(5); | ||
} | ||
|
||
public static function tearDownAfterClass() | ||
{ | ||
$client = self::getServiceBuilder()->get('s3', array('signature' => 'v4')); | ||
$bucket = self::getResourcePrefix() . '-s3-test'; | ||
self::log("Clearing the contents of the {$bucket} bucket"); | ||
$clear = new ClearBucket($client, $bucket); | ||
$clear->clear(); | ||
self::log("Deleting the {$bucket} bucket"); | ||
$client->deleteBucket(array('Bucket' => $bucket)); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
$this->bucket = self::getResourcePrefix() . '-s3-test'; | ||
$this->client = $this->getServiceBuilder()->get('s3', array('signature' => 'v4')); | ||
} | ||
|
||
public function testSignsEmptyRequests() | ||
{ | ||
$this->client->headBucket(array('Bucket' => $this->bucket)); | ||
} | ||
|
||
public function testSignsEmptyPayloadCorrectly() | ||
{ | ||
$this->client->putObject(array( | ||
'Bucket' => $this->bucket, | ||
'Key' => 'test', | ||
'Body' => '' | ||
)); | ||
$this->client->deleteObject(array( | ||
'Bucket' => $this->bucket, | ||
'Key' => 'test' | ||
)); | ||
} | ||
|
||
public function testSignsPayload() | ||
{ | ||
$this->client->putObject(array( | ||
'Bucket' => $this->bucket, | ||
'Key' => 'test2', | ||
'Body' => 'testing...1234' | ||
)); | ||
$this->client->deleteObject(array( | ||
'Bucket' => $this->bucket, | ||
'Key' => 'test2' | ||
)); | ||
} | ||
} |