OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
Xpress
/
vendor
/
aws
/
aws-sdk-php
/
tests
/
Api
/
Parser
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:17 AM
rwxr-xr-x
📄
ComplianceTest.php
5.2 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
Crc32ValidatingParserTest.php
1.84 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
DecodingEventStreamIteratorTest.php
4.42 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
EventParsingIteratorTest.php
12.77 KB
05/19/2025 10:07:17 AM
rw-r--r--
📁
Exception
-
05/19/2025 10:07:17 AM
rwxr-xr-x
📄
JsonParserTest.php
7.32 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
JsonRpcParserTest.php
7.77 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
NonSeekableStreamDecodingEventStreamIteratorTest.php
2.49 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
ParserTestServiceTrait.php
5.38 KB
05/19/2025 10:07:17 AM
rw-r--r--
📄
XmlParserTest.php
7.14 KB
05/19/2025 10:07:17 AM
rw-r--r--
Editing: DecodingEventStreamIteratorTest.php
Close
<?php namespace Aws\Test\Api\Parser; use Aws\Api\Parser\DecodingEventStreamIterator; use Aws\Api\Parser\Exception\ParserException; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Stream; use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * @covers Aws\Api\Parser\DecodingEventStreamIterator */ class DecodingEventStreamIteratorTest extends TestCase { public function complianceTests() { $cases = []; $dataFilesIterator = \Aws\recursive_dir_iterator( realpath(__DIR__ . '/../test_cases/eventstream/encoded/') ); foreach ($dataFilesIterator as $file) { if (is_dir($file)) { continue; } $case = [ Psr7\Utils::streamFor( file_get_contents($file) ), Psr7\Utils::streamFor( file_get_contents( str_replace('encoded', 'decoded', $file) ) ), stripos($file, 'negative') !== false ]; $cases []= $case; } return $cases; } /** * @dataProvider complianceTests */ public function testPassesComplianceTest( Stream $encodedData, Stream $decodedData, $isNegative ) { try { $events = new DecodingEventStreamIterator($encodedData); $firstEvent = null; foreach ($events as $key => $event) { if (!$firstEvent) { $firstEvent = $event; } } if ($isNegative) { $this->fail('Successfully parsed event from corrupt source.'); } $events->rewind(); $this->assertTrue($events->valid()); $this->assertSame(0, $events->key()); $firstEvent['payload'] = (string) $firstEvent['payload']; $current = $events->current(); $current['payload'] = (string) $current['payload']; $this->assertEquals($firstEvent, $current); $decodedEvent = json_decode((string) $decodedData, true); $this->assertSame( base64_decode( $decodedEvent['payload'] ), $firstEvent['payload'] ); $headerCount = count( $firstEvent['headers'] ); foreach ($decodedEvent['headers'] as $header) { $this->assertArrayHasKey( $header['name'], $firstEvent['headers'] ); switch ($header['type']) { case 6: case 7: $this->assertSame( base64_decode($header['value']), $firstEvent['headers'][$header['name']] ); break; case 8: $s = $firstEvent['headers'][$header['name']]->format('U'); $ms = $firstEvent['headers'][$header['name']]->format('u') / 1000; $this->assertSame( $header['value'], ($s * 1000) + $ms ); break; case 9: $value = str_replace('-', '', $firstEvent['headers'][$header['name']]); $this->assertSame( base64_decode($header['value']), pack('H*', $value) ); break; default: $this->assertSame( $header['value'], $firstEvent['headers'][$header['name']] ); } $headerCount--; } $this->assertSame(0, $headerCount); } catch (ParserException $e) { if (!$isNegative) { $this->fail('Unsuccessful parse of event from valid source.'); } $this->assertStringContainsStringIgnoringCase( (string) $decodedData, $e->getMessage(), '' ); } } }