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

PageViewProxyDisabledTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A queryProxy() 0 6 1
A cannotAccessPageWhenProxyIsDisabled() 0 11 1
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