OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
zzaws-ses
/
vendor
/
aws
/
aws-sdk-php
/
tests
/
S3
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
π
..
-
08/14/2024 08:01:07 AM
rwxr-xr-x
π
AmbiguousSuccessParserTest.php
3.68 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
ApplyChecksumMiddlewareTest.php
7.42 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
BatchDeleteTest.php
6.73 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
BucketEndpointArnMiddlewareTest.php
21.78 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
BucketEndpointMiddlewareTest.php
6.02 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
Crypto
-
08/14/2024 08:01:07 AM
rwxr-xr-x
π
Exception
-
08/14/2024 08:01:07 AM
rwxr-xr-x
π
GetBucketLocationParserTest.php
1.34 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
MultipartCopyTest.php
4.94 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
MultipartUploaderTest.php
12.52 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
ObjectCopierTest.php
15.15 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
ObjectUploaderTest.php
11.32 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
PermanentRedirectMiddlewareTest.php
982 bytes
08/14/2024 07:59:11 AM
rw-r--r--
π
PostObjectTest.php
3.52 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
PostObjectV4Test.php
11.12 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
PutObjectUrlMiddlewareTest.php
2 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
RegionalEndpoint
-
08/14/2024 08:01:08 AM
rwxr-xr-x
π
RetryableMalformedResponseParserTest.php
934 bytes
08/14/2024 07:59:11 AM
rw-r--r--
π
S3ClientTest.php
92.05 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
S3EndpointMiddlewareTest.php
30.05 KB
08/14/2024 07:59:11 AM
rw-r--r--
π
S3MultiRegionClientTest.php
24.99 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
S3UriParserTest.php
7.45 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
SSECMiddlewareTest.php
2.91 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
StreamWrapperPathStyleTest.php
30.16 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
StreamWrapperTest.php
36.33 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
StreamWrapperV2ExistenceTest.php
32.63 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
TransferTest.php
14.24 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
UseArnRegion
-
08/14/2024 08:01:08 AM
rwxr-xr-x
π
ValidateResponseChecksumParserTest.php
5.45 KB
08/14/2024 07:59:12 AM
rw-r--r--
π
fixtures
-
08/14/2024 08:08:07 AM
rwxr-xr-x
π
sig_hack.php
226 bytes
08/14/2024 07:59:12 AM
rw-r--r--
π
test_cases
-
08/14/2024 08:01:08 AM
rwxr-xr-x
Editing: ObjectCopierTest.php
Close
<?php namespace Aws\Test\S3; use Aws\Command; use Aws\CommandInterface; use Aws\Middleware; use Aws\Result; use Aws\S3\MultipartUploader; use Aws\S3\ObjectCopier; use Aws\S3\S3Client; use Aws\Test\UsesServiceTrait; use GuzzleHttp\Promise; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; class ObjectCopierTest extends TestCase { use UsesServiceTrait; /** * @dataProvider getCopyTestCases */ public function testDoesCorrectOperation( array $mockedResults, array $options ) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('S3'); $this->addMockResults($client, $mockedResults); $result = (new ObjectCopier( $client, ['Bucket' => 'source-bucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $options ))->copy(); $this->assertSame('https://bucket.s3.amazonaws.com/key', $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } /** * @dataProvider getCopyTestCasesWithPathStyle */ public function testDoesCorrectOperationWithPathStyle( array $mockedResults, array $options ) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('S3', [ 'use_path_style_endpoint' => true ]); $this->addMockResults($client, $mockedResults); $result = (new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $options ))->copy(); $this->assertSame('https://s3.amazonaws.com/bucket/key', $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } /** * @dataProvider getCopyTestCases * @param array $mockedResults * @param array $options */ public function testDoesCorrectOperationWithAccessPointArn( array $mockedResults, array $options ) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('S3', [ 'region' => 'us-west-2' ]); $client->getHandlerList()->appendSign(Middleware::tap( function (CommandInterface $cmd, RequestInterface $req) { switch($cmd->getName()) { case 'UploadPartCopy': case 'CopyObject': $this->assertEquals( 'mydest-123456789012.s3-accesspoint.us-west-2.amazonaws.com', $req->getUri()->getHost() ); $this->assertEquals('/destKey', $req->getUri()->getPath()); $this->assertEquals( 'arn:aws:s3:us-west-2:123456789012:accesspoint:mydest', $cmd['Bucket'] ); $this->assertEquals( 'arn:aws:s3:us-west-2:123456789012:accesspoint:mysource/object/sourceKey', $cmd['CopySource'] ); $this->assertEquals( 'arn:aws:s3:us-west-2:123456789012:accesspoint:mysource/object/sourceKey', $req->getHeader('x-amz-copy-source')[0] ); break; case 'CreateMultipartUpload': case 'CompleteMultipartUpload': $this->assertEquals( 'mydest-123456789012.s3-accesspoint.us-west-2.amazonaws.com', $req->getUri()->getHost() ); $this->assertEquals('/destKey', $req->getUri()->getPath()); $this->assertEquals( 'arn:aws:s3:us-west-2:123456789012:accesspoint:mydest', $cmd['Bucket'] ); break; case 'HeadObject': $this->assertEquals( 'mysource-123456789012.s3-accesspoint.us-west-2.amazonaws.com', $req->getUri()->getHost() ); $this->assertEquals('/sourceKey', $req->getUri()->getPath()); break; default: $this->fail('Unexpected command encountered.'); } return Promise\Create::promiseFor(new Result([])); } )); $this->addMockResults($client, $mockedResults); (new ObjectCopier( $client, ['Bucket' => 'arn:aws:s3:us-west-2:123456789012:accesspoint:mysource', 'Key' => 'sourceKey'], ['Bucket' => 'arn:aws:s3:us-west-2:123456789012:accesspoint:mydest', 'Key' => 'destKey'], 'private', $options ))->copy(); $this->assertTrue($this->mockQueueEmpty()); } /** * @dataProvider getCopyTestCases */ public function testDoesCorrectOperationAsynchronously( array $mockedResults, array $options ) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('S3'); $this->addMockResults($client, $mockedResults); $promise = (new ObjectCopier( $client, ['Bucket' => 'source-bucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $options ))->promise(); $this->assertFalse($this->mockQueueEmpty()); $result = $promise->wait(); $this->assertSame('https://bucket.s3.amazonaws.com/key', $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } /** * @dataProvider getCopyTestCasesWithPathStyle */ public function testDoesCorrectOperationAsynchronouslyWithPathStyle( array $mockedResults, array $options ) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('S3', [ 'use_path_style_endpoint' => true ]); $this->addMockResults($client, $mockedResults); $promise = (new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $options ))->promise(); $this->assertFalse($this->mockQueueEmpty()); $result = $promise->wait(); $this->assertSame('https://s3.amazonaws.com/bucket/key', $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } private function getSmallPutObjectMockResult() { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $putObject = new Result(); return [$smallHeadObject, $putObject]; } private function getMultipartMockResults($key = 'key') { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $partCount = ceil($smallHeadObject['ContentLength'] / MultipartUploader::PART_MIN_SIZE); $initiate = new Result(['UploadId' => 'foo']); $putPart = new Result(['ETag' => 'bar']); $complete = new Result(['Location' => 'https://bucket.s3.amazonaws.com/'.$key]); return array_merge( [$smallHeadObject, $initiate], array_fill(0, $partCount, $putPart), [$complete] ); } public function getCopyTestCases() { return [ [ $this->getSmallPutObjectMockResult(), [] ], [ $this->getMultipartMockResults(), ['mup_threshold' => MultipartUploader::PART_MIN_SIZE] ], ]; } private function getPathStyleMultipartMockResults() { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $partCount = ceil($smallHeadObject['ContentLength'] / MultipartUploader::PART_MIN_SIZE); $initiate = new Result(['UploadId' => 'foo']); $putPart = new Result(['ETag' => 'bar']); $complete = new Result(['Location' => 'https://s3.amazonaws.com/bucket/key']); return array_merge( [$smallHeadObject, $initiate], array_fill(0, $partCount, $putPart), [$complete] ); } public function getCopyTestCasesWithPathStyle() { return [ [ $this->getSmallPutObjectMockResult(), [] ], [ $this->getPathStyleMultipartMockResults(), ['mup_threshold' => MultipartUploader::PART_MIN_SIZE] ], ]; } public function testCanCopyVersions() { $client = $this->getMockBuilder(S3Client::class) ->disableOriginalConstructor() ->setMethods(['getCommand', 'executeAsync']) ->getMock(); $headObjectCommand = new Command('HeadObject'); $headCommandParams = [ 'Bucket' => 'bucket', 'Key' => 'key', 'VersionId' => 'V+ID', ]; $copyObjectCommand = new Command('CopyObject'); $copyCommandParams = [ 'Bucket' => 'newBucket', 'Key' => 'newKey', 'ACL' => 'private', 'MetadataDirective' => 'COPY', 'CopySource' => '/bucket/key?versionId=V+ID', ]; $client->expects($this->exactly(2)) ->method('getCommand') ->will($this->returnValueMap([ ['HeadObject', $headCommandParams, $headObjectCommand], ['CopyObject', $copyCommandParams, $copyObjectCommand], ])); $client->expects($this->exactly(2)) ->method('executeAsync') ->will($this->returnValueMap([ [ $headObjectCommand, Promise\Create::promiseFor(new Result(['ContentLength' => 1024 * 1024 * 6])) ], [$copyObjectCommand, Promise\Create::promiseFor(new Result)], ])); (new ObjectCopier( $client, ['Bucket' => 'bucket', 'Key' => 'key', 'VersionId' => 'V+ID'], ['Bucket' => 'newBucket', 'Key' => 'newKey'], 'private' ))->copy(); } public function testS3ObjectCopierCopyObjectParams() { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('s3'); $copyOptions = [ 'params' => ['RequestPayer' => 'test'], 'before_lookup' => function($command) { $this->assertSame('test', $command['RequestPayer']); }, 'before_upload' => function($command) { $this->assertSame('test', $command['RequestPayer']); }, ]; $url = 'https://bucket.s3.amazonaws.com/key'; $this->addMockResults( $client, $this->getSmallPutObjectMockResult() ); $uploader = new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $copyOptions); $this->assertFalse($this->mockQueueEmpty()); $result = $uploader->copy(); $this->assertSame($url, $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } public function testS3ObjectCopierMultipartParams() { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('s3'); $copyOptions = [ 'mup_threshold' => MultipartUploader::PART_MIN_SIZE, 'params' => ['RequestPayer' => 'test'], 'before_lookup' => function($command) { $this->assertSame('test', $command['RequestPayer']); }, 'before_initiate' => function($command) { $this->assertSame('test', $command['RequestPayer']); }, 'before_upload' => function($command) { $this->assertSame('test', $command['RequestPayer']); }, 'before_complete' => function($command) { $this->assertSame('test', $command['RequestPayer']); } ]; $url = 'https://bucket.s3.amazonaws.com/key'; $this->addMockResults( $client, $this->getMultipartMockResults() ); $uploader = new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => 'sourceKey'], ['Bucket' => 'bucket', 'Key' => 'key'], 'private', $copyOptions); $this->assertFalse($this->mockQueueEmpty()); $result = $uploader->copy(); $this->assertSame($url, $result['ObjectURL']); $this->assertTrue($this->mockQueueEmpty()); } public function testS3ObjectCopierDoesTransformUnicodeKeyToEncodedURL() { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('s3'); $chinese = "δΈζ"; $url = 'https://bucket.s3.amazonaws.com/' . rawurlencode($chinese); $this->addMockResults( $client, $this->getSmallPutObjectMockResult() ); $uploader = new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => $chinese], ['Bucket' => 'bucket', 'Key' => $chinese], 'private' ); $this->assertFalse($this->mockQueueEmpty()); $result = $uploader->copy(); $this->assertSame($url, $result['ObjectURL']); } public function MultipartCopierProvider(){ return [ ["δΈζ", "ζδ»Άε€Ή/ζδ»Ά"], ["ζδ»Άε€Ή/ζδ»Ά", "δΈζ"], ["first-folder/second-folder/key", "first-folder/second-folder/key"], ]; } /** * @dataProvider MultipartCopierProvider */ public function testS3ObjectMultipartCopier($input, $expectedOutput) { /** @var \Aws\S3\S3Client $client */ $client = $this->getTestClient('s3'); $this->addMockResults( $client, $this->getMultipartMockResults($expectedOutput) ); $uploader = new ObjectCopier( $client, ['Bucket' => 'sourceBucket', 'Key' => $input], ['Bucket' => 'bucket', 'Key' => $input], 'private', ['mup_threshold' => MultipartUploader::PART_MIN_SIZE] ); $this->assertFalse($this->mockQueueEmpty()); $result = $uploader->copy(); $this->assertSame( "https://bucket.s3.amazonaws.com/{$expectedOutput}", $result['ObjectURL'] ); $this->assertTrue($this->mockQueueEmpty()); } }