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: WaiterTest.php
Close
<?php namespace Aws\Test; use Aws\Api\ApiProvider; use Aws\CommandInterface; use Aws\DynamoDb\DynamoDbClient; use Aws\Exception\AwsException; use Aws\Result; use Aws\Waiter; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Promise; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\RejectedPromise; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * @covers Aws\Waiter */ class WaiterTest extends TestCase { use UsesServiceTrait; public function testErrorOnBadConfig() { $this->expectException(\InvalidArgumentException::class); $provider = ApiProvider::defaultProvider(); $client = new DynamoDbClient([ 'region' => 'foo', 'version' => 'latest', 'api_provider' => function ($type, $service, $version) use ($provider) { return $type === 'waiter' ? ['waiters' => ['TableExists' => []]] : $provider($type, $service, $version); } ]); $client->waitUntil( 'TableExists', ['TableName' => 'Meh'] ); } public function testErrorOnBadBeforeCallback() { $this->expectException(\InvalidArgumentException::class); $client = $this->getTestClient('DynamoDb'); $client->waitUntil( 'TableExists', [ 'TableName' => 'Meh', '@waiter' => ['before' => '%'] ] ); } /** @doesNotPerformAssertions */ public function testContinueWaitingOnHandlerError() { $retries = 10; $client = new DynamoDbClient([ 'version' => 'latest', 'region' => 'us-west-2', 'retries' => 0, 'http_handler' => function ( RequestInterface $request, array $options ) use (&$retries) { if (0 === --$retries) { return new FulfilledPromise(new Response(200, [], Psr7\Utils::streamFor('{"Table":{"TableStatus":"ACTIVE"}}') )); } return new RejectedPromise([ 'connection_error' => true, 'exception' => $this->getMockBuilder(ConnectException::class) ->disableOriginalConstructor() ->getMock(), 'response' => null, ]); }, ]); $client->waitUntil('TableExists', [ 'TableName' => 'table', ]); } /** @doesNotPerformAssertions */ public function testCanCancel() { $client = $this->getTestClient('DynamoDb'); $this->addMockResults($client, [new Result([])]); $client->getWaiter('TableExists', [ 'TableName' => 'Meh', '@http' => ['debug' => true] ])->promise()->cancel(); sleep(1); } public function testCanWait() { $iteration = $waitTime = 0; $statusQueue = ['CREATING', 'CREATING', 'CREATING', 'ACTIVE']; $handler = static function (Request $request, array $options) use ( $statusQueue, &$waitTime, &$iteration ) { $waitTime += $options['delay']; $promise = new Promise\Promise(); $promise->resolve(new Response(200, [], Psr7\Utils::streamFor(sprintf( '{"Table":{"TableStatus":"%s"}}', $statusQueue[$iteration] )) )); $iteration++; return $promise; }; $client = $this->getTestClient('DynamoDb', [ 'http_handler' => $handler, ]); $client->waitUntil( 'TableExists', [ 'TableName' => 'Meh', '@waiter' => [ 'initDelay' => 3, 'delay' => 1 ] ] ); $this->assertSame(4, $iteration, 'Did not execute enough requests.'); $this->assertSame(6000, $waitTime, 'Did not delay long enough.'); } /** * @dataProvider getWaiterWorkflowTestCases */ public function testWaiterWorkflow($results, $expectedException) { // Prepare a client $client = $this->getTestClient('DynamoDb', [ 'api_provider' => $this->getApiProvider() ]); $this->addMockResults($client, $results); // Execute the waiter and verify the number of requests. $actualAttempt = 0; try { $client->waitUntil('TableExists', [ 'TableName' => 'WhoCares', '@waiter' => [ 'before' => function (CommandInterface $cmd, $attempt) use (&$actualAttempt) { $actualAttempt = $attempt; } ] ]); $actualException = null; } catch (\Exception $e) { $actualException = $e->getMessage(); } $this->assertCount($actualAttempt, $results); $this->assertEquals($expectedException, $actualException); } public function getWaiterWorkflowTestCases() { return [ [ [ $this->createMockAwsException('ResourceNotFoundException'), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'ACTIVE']]), ], null ], [ [ new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'DELETING']]), ], 'The TableExists waiter entered a failure state.' ], [ [ new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), ], 'The TableExists waiter failed after attempt #5.' ], [ [ $this->createMockAwsException(null, null, 'foo'), ], 'The TableExists waiter entered a failure state. Reason: foo' ], ]; } private function getApiProvider() { return function ($type) { if ($type == 'api') { return [ 'operations' => ['DescribeTable' => ['input' => []]], 'metadata' => [ 'endpointPrefix' => 'foo', 'protocol' => 'json', 'jsonVersion' => '1.1', 'signatureVersion' => 'v4' ], ]; } return ['waiters' => [ 'TableExists' => [ 'delay' => function ($attempt) { return $attempt; }, 'maxAttempts' => 5, 'operation' => 'DescribeTable', 'acceptors' => [ [ 'state' => 'success', 'matcher' => 'path', 'argument' => 'Table.TableStatus', 'expected' => 'ACTIVE', ], [ 'state' => 'retry', 'matcher' => 'error', 'expected' => 'ResourceNotFoundException', ], [ 'state' => 'failed', 'matcher' => 'path', 'argument' => 'Table.TableStatus', 'expected' => 'DELETING', ], ], ] ]]; }; } /** * @dataProvider getMatchersTestCases */ public function testMatchers($matcher, $result, $acceptor, $expected) { $waiter = new \ReflectionClass(Waiter::class); $matcher = $waiter->getMethod($matcher); $matcher->setAccessible(true); $waiter = $waiter->newInstanceWithoutConstructor(); $this->assertEquals($expected, $matcher->invoke($waiter, $result, $acceptor)); } public function getMatchersTestCases() { return [ [ 'matchesPath', null, [], false ], [ 'matchesPath', $this->getMockResult(['a' => ['b' => 'c']]), ['argument' => 'a.b', 'expected' => 'c'], true ], [ 'matchesPath', $this->getMockResult(['a' => ['b' => 'c']]), ['argument' => 'a', 'expected' => 'z'], false ], [ 'matchesPathAll', null, [], false ], [ 'matchesPathAll', $this->getMockResult([ 'a' => [ ['b' => 'c'], ['b' => 'c'], ['b' => 'c'] ] ]), ['argument' => 'a[].b', 'expected' => 'c'], true ], [ 'matchesPathAll', $this->getMockResult(['a' => [ ['b' => 'c'], ['b' => 'z'], ['b' => 'c'] ]]), ['argument' => 'a[].b', 'expected' => 'c'], false ], [ 'matchesPathAny', null, [], false ], [ 'matchesPathAny', $this->getMockResult([ 'a' => [ ['b' => 'c'], ['b' => 'd'], ['b' => 'e'] ] ]), ['argument' => 'a[].b', 'expected' => 'c'], true ], [ 'matchesPathAny', $this->getMockResult([ 'a' => [ ['b' => 'x'], ['b' => 'y'], ['b' => 'z'] ] ]), ['argument' => 'a[].b', 'expected' => 'c'], false ], [ 'matchesStatus', null, [], false ], [ 'matchesStatus', $this->getMockResult(), ['expected' => 200], true ], [ 'matchesStatus', $this->getMockResult(), ['expected' => 400], false ], [ 'matchesError', null, [], false ], [ 'matchesError', $this->getMockResult('InvalidData'), ['expected' => 'InvalidData'], true ], [ 'matchesError', $this->getMockResult('InvalidData'), ['expected' => 'Foo'], false ], ]; } private function getMockResult($data = []) { if (is_string($data)) { return new AwsException('ERROR', $this->getMockBuilder(CommandInterface::class)->getMock(), [ 'code' => $data, 'result' => new Result(['@metadata' => ['statusCode' => 200]]) ] ); } return new Result($data + ['@metadata' => ['statusCode' => 200]]); } }