Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — dev-extbase-fluid (#756)
by
unknown
03:39
created

PageViewProxyTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 42
c 1
b 0
f 0
dl 0
loc 118
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A canQueryOptions() 0 8 1
A canAccessPageWithUrlHash() 0 12 1
A sendsUserAgentToTarget() 0 12 1
A cannotAccessUrlWithInvalidUrlHash() 0 8 1
A cannotAccessFileUrl() 0 7 1
A queryProxy() 0 6 1
A getDlfConfiguration() 0 4 1
A cannotSendPostRequest() 0 11 1
A cannotAccessUrlWithoutUrlHash() 0 7 1
1
<?php
2
3
namespace Kitodo\Dlf\Tests\Functional\Api;
4
5
use GuzzleHttp\Client as HttpClient;
6
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
7
use TYPO3\CMS\Core\Utility\GeneralUtility;
8
9
class PageViewProxyTest extends FunctionalTestCase
10
{
11
    protected $disableJsonWrappedResponse = true;
12
13
    protected function getDlfConfiguration()
14
    {
15
        return array_merge(parent::getDlfConfiguration(), [
16
            'enableInternalProxy' => true,
17
        ]);
18
    }
19
20
    protected function queryProxy(array $query, string $method = 'GET')
21
    {
22
        $query['eID'] = 'tx_dlf_pageview_proxy';
23
24
        return $this->httpClient->request($method, '', [
25
            'query' => $query,
26
        ]);
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function cannotAccessFileUrl(): void
33
    {
34
        $response = $this->queryProxy([
35
            'url' => 'file:///etc/passwd',
36
        ]);
37
38
        $this->assertEquals(400, $response->getStatusCode());
39
    }
40
41
    /**
42
     * @test
43
     */
44
    public function cannotAccessUrlWithoutUrlHash(): void
45
    {
46
        $response = $this->queryProxy([
47
            'url' => 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt',
48
        ]);
49
50
        $this->assertEquals(401, $response->getStatusCode());
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function cannotAccessUrlWithInvalidUrlHash(): void
57
    {
58
        $response = $this->queryProxy([
59
            'url' => 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt',
60
            'uHash' => 'nottherealhash',
61
        ]);
62
63
        $this->assertEquals(401, $response->getStatusCode());
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function canAccessPageWithUrlHash(): void
70
    {
71
        $targetUrl = 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt';
72
        $uHash = GeneralUtility::hmac($targetUrl, 'PageViewProxy');
73
74
        $response = $this->queryProxy([
75
            'url' => $targetUrl,
76
            'uHash' => $uHash,
77
        ]);
78
79
        $this->assertEquals(200, $response->getStatusCode());
80
        $this->assertEquals('This is some plain text test file.' . "\n", (string) $response->getBody());
81
    }
82
83
    /**
84
     * @test
85
     */
86
    public function cannotSendPostRequest(): void
87
    {
88
        $targetUrl = 'http://web:8001/Tests/Fixtures/PageViewProxy/test.txt';
89
        $uHash = GeneralUtility::hmac($targetUrl, 'PageViewProxy');
90
91
        $response = $this->queryProxy([
92
            'url' => $targetUrl,
93
            'uHash' => $uHash,
94
        ], 'POST');
95
96
        $this->assertEquals(405, $response->getStatusCode());
97
    }
98
99
    /**
100
     * @test
101
     */
102
    public function sendsUserAgentToTarget(): void
103
    {
104
        $targetUrl = 'http://web:8001/Tests/Fixtures/PageViewProxy/echo_user_agent.php';
105
        $uHash = GeneralUtility::hmac($targetUrl, 'PageViewProxy');
106
107
        $response = $this->queryProxy([
108
            'url' => $targetUrl,
109
            'uHash' => $uHash,
110
        ]);
111
112
        $this->assertEquals(200, $response->getStatusCode());
113
        $this->assertEquals('Kitodo.Presentation Proxy', (string) $response->getBody());
114
    }
115
116
    /**
117
     * @test
118
     */
119
    public function canQueryOptions(): void
120
    {
121
        $response = $this->queryProxy([], 'OPTIONS');
122
123
        $this->assertGreaterThanOrEqual(200, $response->getStatusCode());
124
        $this->assertLessThan(300, $response->getStatusCode());
125
126
        $this->assertNotEmpty($response->getHeader('Access-Control-Allow-Methods'));
127
    }
128
}
129