Passed
Pull Request — master (#103)
by Alexander
03:37
created

PageViewProxyDisabledTest::queryProxy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Kitodo\Dlf\Tests\Functional\Api;
4
5
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
6
use TYPO3\CMS\Core\Utility\GeneralUtility;
7
8
class PageViewProxyDisabledTest extends FunctionalTestCase
9
{
10
    protected $disableJsonWrappedResponse = true;
11
12
    protected function queryProxy(array $query, string $method = 'GET')
13
    {
14
        $query['eID'] = 'tx_dlf_pageview_proxy';
15
16
        return $this->httpClient->request($method, '', [
17
            'query' => $query,
18
        ]);
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function cannotAccessPageWhenProxyIsDisabled(): void
25
    {
26
        $targetUrl = 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt';
27
        $uHash = GeneralUtility::hmac($targetUrl, 'PageViewProxy');
28
29
        $response = $this->queryProxy([
30
            'url' => $targetUrl,
31
            'uHash' => $uHash,
32
        ]);
33
34
        $this->assertEquals(404, $response->getStatusCode());
35
    }
36
}
37