__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Tuf\Tests\Client;
use GuzzleHttp\Psr7\Utils;
use Prophecy\PhpUnit\ProphecyTrait;
use Tuf\Exception\Attack\InvalidHashException;
use Tuf\Exception\NotFoundException;
use Tuf\Tests\ClientTestBase;
/**
* Tests transparent download of verified targets.
*/
class VerifiedDownloadTest extends ClientTestBase
{
use ProphecyTrait;
/**
* @testWith ["consistent"]
* ["inconsistent"]
*
* @covers \Tuf\Client\Updater::download
*/
public function testVerifiedDownload(string $fixtureVariant): void
{
$fixture = 'Simple/' . $fixtureVariant;
$this->loadClientAndServerFilesFromFixture($fixture);
$updater = $this->getUpdater();
$testFilePath = static::getFixturePath($fixture, 'server/targets/testtarget.txt', false);
$testFileContents = file_get_contents($testFilePath);
$this->assertSame($testFileContents, $updater->download('testtarget.txt')->wait()->getContents());
// If the file fetcher returns a file stream, the updater should NOT try
// to read the contents of the stream into memory.
$stream = $this->prophesize('\Psr\Http\Message\StreamInterface');
$stream->getMetadata('uri')->willReturn($testFilePath);
$stream->getContents()->shouldNotBeCalled();
$stream->rewind()->shouldNotBeCalled();
$stream->getSize()->willReturn(strlen($testFileContents));
$updater->download('testtarget.txt');
// If the target isn't known, we should get an exception.
try {
$updater->download('void.txt');
$this->fail('Expected a NotFoundException to be thrown, but it was not.');
} catch (NotFoundException $e) {
$this->assertSame('Target not found: void.txt', $e->getMessage());
}
$stream = Utils::streamFor('invalid data');
$this->serverFiles['testtarget.txt'] = $stream;
try {
$updater->download('testtarget.txt')->wait();
$this->fail('Expected InvalidHashException to be thrown, but it was not.');
} catch (InvalidHashException $e) {
$this->assertSame("Invalid sha256 hash for testtarget.txt", $e->getMessage());
$this->assertSame($stream, $e->getStream());
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ConsistentFixturesUpdaterTest.php | File | 5.79 KB | 0664 |
|
| HashedBinsTest.php | File | 822 B | 0664 |
|
| InconsistentFixturesUpdaterTest.php | File | 4.3 KB | 0664 |
|
| InvalidRefreshTest.php | File | 1.27 KB | 0664 |
|
| RoleDownloadLimitTest.php | File | 1.46 KB | 0664 |
|
| RollbackAttackTest.php | File | 1.82 KB | 0664 |
|
| SnapshotHashesTest.php | File | 1.3 KB | 0664 |
|
| TestLoader.php | File | 1.95 KB | 0664 |
|
| UnchangedTimestampTest.php | File | 972 B | 0664 |
|
| UpdaterTest.php | File | 40.51 KB | 0664 |
|
| VerifiedDownloadTest.php | File | 2.23 KB | 0664 |
|