OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
zzXpress
/
vendor
/
aws
/
aws-sdk-php
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
AbstractConfigurationProviderTest.php
3.42 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Api
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Arn
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Auth
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
AwsClientTest.php
29.67 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Build
-
11/13/2024 02:24:22 PM
rwxr-xr-x
📄
ClientResolverTest.php
55.74 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
ClientSideMonitoring
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📁
CloudFront
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
CloudSearchDomain
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
CloudTrail
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
CloudWatchLogs
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
CognitoIdentity
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
CognitoSync
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
CommandPoolTest.php
5.8 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
CommandTest.php
3.28 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
ConfigurationResolverTest.php
12.35 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Credentials
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Crypto
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
DefaultsMode
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
DocDb
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
DoctrineCacheAdapterTest.php
1.23 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
DynamoDb
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Ec2
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
ElasticLoadBalancingV2
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Endpoint
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
EndpointDiscovery
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
EndpointParameterMiddlewareTest.php
9.21 KB
05/19/2025 10:07:23 AM
rw-r--r--
📁
EndpointV2
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
EventBridge
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Exception
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
FunctionsTest.php
14.33 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Glacier
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Handler
-
11/13/2024 02:24:45 PM
rwxr-xr-x
📄
HandlerListTest.php
7.16 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
HasMonitoringEventsTraitTest.php
895 bytes
05/19/2025 10:07:24 AM
rw-r--r--
📄
HashingStreamTest.php
1.41 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
HistoryTest.php
4.2 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
IdempotencyTokenMiddlewareTest.php
2.76 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Identity
-
11/13/2024 02:24:46 PM
rwxr-xr-x
📄
InputValidationMiddlewareTest.php
5.62 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Integ
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
JsonCompilerTest.php
730 bytes
05/19/2025 10:07:23 AM
rw-r--r--
📁
Lambda
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📁
LexModelsV2
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
LruArrayCacheTest.php
1.59 KB
05/19/2025 10:07:23 AM
rw-r--r--
📁
MachineLearning
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
MiddlewareTest.php
16.08 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
MockHandlerTest.php
3.79 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
MultiRegionClientTest.php
5.41 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Multipart
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📁
Neptune
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📄
PerformanceContext.php
8.2 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
PhpHashTest.php
1.33 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Polly
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📄
PresignUrlMiddlewareTest.php
3.95 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
Psr16CacheAdapterTest.php
1.84 KB
05/19/2025 10:07:23 AM
rw-r--r--
📄
PsrCacheAdapterTest.php
2.64 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
QueryCompatibleInputMiddlewareTest.php
9.1 KB
05/19/2025 10:07:23 AM
rw-r--r--
📁
Rds
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
RequestCompression
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
ResultPaginatorTest.php
16.21 KB
05/19/2025 10:07:23 AM
rw-r--r--
📄
ResultTest.php
1.38 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Retry
-
05/19/2025 10:07:23 AM
rwxr-xr-x
📄
RetryMiddlewareTest.php
24.57 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
RetryMiddlewareV2Test.php
40.33 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Route53
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
S3
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
S3Control
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Script
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
SdkTest.php
2.37 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Ses
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Signature
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Sqs
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📁
Ssm
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
StreamRequestPayloadMiddlewareTest.php
10.1 KB
05/19/2025 10:07:23 AM
rw-r--r--
📁
Sts
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
TestServiceTrait.php
3.78 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
Token
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
TraceMiddlewareTest.php
16.16 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
UsesServiceTrait.php
4.37 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
WaiterTest.php
12.63 KB
05/19/2025 10:07:24 AM
rw-r--r--
📄
WrappedHttpHandlerTest.php
13.8 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
bootstrap
-
05/19/2025 10:07:24 AM
rwxr-xr-x
📄
bootstrap.php
1.53 KB
05/19/2025 10:07:24 AM
rw-r--r--
📁
fixtures
-
11/13/2024 03:03:50 PM
rwxr-xr-x
📁
static
-
11/13/2024 02:07:43 PM
rwxr-xr-x
Editing: WrappedHttpHandlerTest.php
Close
<?php namespace Aws\Test; use Aws\Api\ErrorParser\JsonRpcErrorParser; use Aws\Api\ErrorParser\RestJsonErrorParser; use Aws\Api\ErrorParser\XmlErrorParser; use Aws\Api\Service; use Aws\AwsClient; use Aws\Command; use Aws\CommandInterface; use Aws\Exception\AwsException; use Aws\Result; use Aws\WrappedHttpHandler; use GuzzleHttp\Promise\RejectedPromise; use Psr\Http\Message\RequestInterface; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * @covers Aws\WrappedHttpHandler */ class WrappedHttpHandlerTest extends TestCase { use TestServiceTrait; public function testParsesResponses() { $called = false; $cmd = new Command('foo'); $req = new Request('GET', 'http://foo.com'); $res = new Response(200, ['Foo' => 'Bar']); $result = new Result(); $handler = function (RequestInterface $request, array $options) use (&$called, $res, $req) { $this->assertSame($request, $req); $called = true; return $res; }; $parser = function (CommandInterface $command, ResponseInterface $response) use ($res, $cmd, $result) { $this->assertSame($res, $response); $this->assertSame($cmd, $command); return $result; }; $errorParser = [$this, 'fail']; $wrapped = new WrappedHttpHandler($handler, $parser, $errorParser); $promise = $wrapped($cmd, $req); $this->assertTrue($called); $this->assertInstanceOf('GuzzleHttp\Promise\PromiseInterface', $promise); $this->assertSame($result, $promise->wait()); $this->assertEquals([ 'statusCode' => 200, 'effectiveUri' => (string) $req->getUri(), 'headers' => ['foo' => 'Bar'], 'transferStats' => [], ], $result['@metadata']); } public function testEnsuresErrorHasExceptionKey() { $this->expectExceptionMessage("The HTTP handler was rejected without an \"exception\" key value pair."); $this->expectException(\RuntimeException::class); $cmd = new Command('foo'); $req = new Request('GET', 'http://foo.com'); $handler = function () { return new RejectedPromise([]); }; $parser = $errorParser = [$this, 'fail']; $wrapped = new WrappedHttpHandler($handler, $parser, $errorParser); $wrapped($cmd, $req)->wait(); } public function testCanRejectWithoutResponse() { $e = new \Exception('a'); $cmd = new Command('foo'); $req = new Request('GET', 'http://foo.com'); $handler = function () use ($e) { return new RejectedPromise(['exception' => $e]); }; $parser = $errorParser = [$this, 'fail']; $wrapped = new WrappedHttpHandler($handler, $parser, $errorParser); try { $wrapped($cmd, $req)->wait(); $this->fail(); } catch (AwsException $e) { $this->assertSame($req, $e->getRequest()); $this->assertSame($cmd, $e->getCommand()); $this->assertNull($e->getResponse()); $this->assertNull($e->getResult()); } } /** * @dataProvider responseAndParserProvider * * @param Response $res * @param $errorParser * @param $expectedCode * @param $expectedId * @param $expectedArray */ public function testCanRejectWithAndParseResponse( Response $res, Service $service, $errorParser, $expectedCode, $expectedId, $expectedArray ) { $client = $this->generateTestClient($service, []); $cmd = $client->getCommand('TestOperation', []); $e = new \Exception('a'); $req = new Request('GET', 'http://foo.com'); $handler = function () use ($e, $req, $res) { return new RejectedPromise(['exception' => $e, 'response' => $res]); }; $parser = [$this, 'fail']; $wrapped = new WrappedHttpHandler($handler, $parser, $errorParser); try { $wrapped($cmd, $req)->wait(); $this->fail(); } catch (AwsException $e) { $this->assertSame($cmd, $e->getCommand()); $this->assertSame($res, $e->getResponse()); $this->assertSame($req, $e->getRequest()); $this->assertNull($e->getResult()); $this->assertEquals($expectedCode, $e->getAwsErrorCode()); $this->assertEquals($expectedId, $e->getAwsRequestId()); $this->assertEquals($expectedArray, $e->toArray()); } } public function responseAndParserProvider() { $services = [ 'ec2' => $this->generateTestService('ec2'), 'json' => $this->generateTestService('json'), 'query' => $this->generateTestService('query'), 'rest-json' => $this->generateTestService('rest-json'), 'rest-xml' => $this->generateTestService('rest-xml'), ]; return [ [ new Response( 400, ['X-Amzn-RequestId' => '123'], json_encode(['__type' => 'foo#bar']) ), $services['json'], new JsonRpcErrorParser($services['json']), 'bar', '123', [], ], [ new Response( 400, [ 'X-Amzn-RequestId' => '123', ], json_encode(['message' => 'sorry!']) ), $services['rest-json'], new RestJsonErrorParser($services['rest-json']), null, '123', [], ], [ new Response( 400, [], '<?xml version="1.0" encoding="UTF-8"?><Error><Code>InternalError</Code><RequestId>656c76696e6727732072657175657374</RequestId></Error>' ), $services['rest-xml'], new XmlErrorParser($services['rest-xml']), 'InternalError', '656c76696e6727732072657175657374', [], ], [ new Response( 400, ['X-Amzn-RequestId' => '123'], openssl_random_pseudo_bytes(1024) ), $services['query'], new XmlErrorParser($services['query']), null, null, [], ], // Rest-json with modeled exception from header error type [ new Response( 400, [ 'X-Amzn-RequestId' => '123', 'X-Amzn-ErrorType' => 'TestException' ], json_encode([ 'TestString' => 'foo-string', 'TestInt' => 456, 'NotModeled' => 'bar' ]) ), $services['rest-json'], new RestJsonErrorParser($services['rest-json']), 'TestException', '123', [ 'TestString' => 'foo-string', 'TestInt' => 456, 'TestHeaderMember' => '', 'TestHeaders' => [], 'TestStatus' => 400 ], ], // Rest-json with modeled exception from body error code [ new Response( 400, [ 'X-Amzn-RequestId' => '123' ], json_encode([ 'TestString' => 'foo-string', 'TestInt' => 456, 'NotModeled' => 'bar', 'code' => 'TestException' ]) ), $services['rest-json'], new RestJsonErrorParser($services['rest-json']), 'TestException', '123', [ 'TestString' => 'foo-string', 'TestInt' => 456, 'TestHeaderMember' => '', 'TestHeaders' => [], 'TestStatus' => 400 ], ], // Ec2 with modeled exception [ new Response( 400, [], '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<Response>' . ' <Errors>' . ' <Error>' . ' <Code>TestException</Code>' . ' <Message>Error Message</Message>' . ' <TestString>SomeString</TestString>' . ' <TestInt>456</TestInt>' . ' </Error>' . ' </Errors>' . ' <RequestId>xyz</RequestId>' . '</Response>' ), $services['ec2'], new XmlErrorParser($services['ec2']), 'TestException', 'xyz', [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaderMember' => '', 'TestHeaders' => [], 'TestStatus' => 400, ], ], // Query with modeled exception [ new Response( 400, [], '<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">' . ' <Error>' . ' <Type>ErrorType</Type>' . ' <Code>TestException</Code>' . ' <Message>Error Message</Message>' . ' <TestString>SomeString</TestString>' . ' <TestInt>456</TestInt>' . ' </Error>' . ' <RequestId>xyz</RequestId>' . '</ErrorResponse>' ), $services['query'], new XmlErrorParser($services['query']), 'TestException', 'xyz', [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaderMember' => '', 'TestHeaders' => [], 'TestStatus' => 400, ], ], // Rest-xml with modeled exception [ new Response( 400, [], '<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">' . ' <Error>' . ' <Type>ErrorType</Type>' . ' <Code>TestException</Code>' . ' <Message>Error Message</Message>' . ' <TestString>SomeString</TestString>' . ' <TestInt>456</TestInt>' . ' </Error>' . ' <RequestId>xyz</RequestId>' . '</ErrorResponse>' ), $services['rest-xml'], new XmlErrorParser($services['rest-xml']), 'TestException', 'xyz', [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaderMember' => '', 'TestHeaders' => [], 'TestStatus' => 400, ], ], ]; } public function testCanRejectWithException() { $e = new \Exception('a'); $cmd = new Command('foo'); $req = new Request('GET', 'http://foo.com'); $handler = function () use ($e) { throw $e; }; $parser = [$this, 'fail']; $errorParser = [$this, 'fail']; $wrapped = new WrappedHttpHandler($handler, $parser, $errorParser); try { $wrapped($cmd, $req)->wait(); $this->fail(); } catch (\Exception $e2) { $this->assertSame($e, $e2); } } public function testDoesNotPassOnTransferStatsCallbackToHandlerByDefault() { $handler = function ($request, array $options) { $this->assertArrayNotHasKey('http_stats_receiver', $options); return new Response; }; $parser = function () { return new Result; }; $wrapped = new WrappedHttpHandler($handler, $parser, [$this, 'fail']); $wrapped(new Command('a'), new Request('GET', 'http://foo.com')) ->wait(); } public function testPassesOnTransferStatsCallbackToHandlerWhenRequested() { $handler = function ($request, array $options) { $this->assertArrayHasKey('http_stats_receiver', $options); $this->assertIsCallable($options['http_stats_receiver']); return new Response; }; $parser = function () { return new Result; }; $wrapped = new WrappedHttpHandler( $handler, $parser, [$this, 'fail'], AwsException::class, $collectStats = true ); $wrapped(new Command('a'), new Request('GET', 'http://foo.com')) ->wait(); } }