AnonSec Shell
Server IP : 46.105.57.169  /  Your IP : 216.73.216.144
Web Server : Apache
System : Linux webd003.cluster120.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : maitricfuz ( 93378)
PHP Version : 8.4.10
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/maitricfuz/www/maitric/libraries/vendor/php-tuf/php-tuf/tests/Client/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/maitricfuz/www/maitric/libraries/vendor/php-tuf/php-tuf/tests/Client/VerifiedDownloadTest.php
<?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());
        }
    }
}

Anon7 - 2022
AnonSec Team