CSPLoggerControllerTest::testIndex()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
namespace Sockam\CSPLoggerBundle\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class CSPLoggerControllerTest extends WebTestCase
8
{
9
    public function testIndex()
10
    {
11
        $method = 'POST';
12
        $uri = '/csp/log';
13
        $parameters = [];
14
        $files = [];
15
        $server = [
16
            'CONTENT_TYPE' => 'application/json',
17
        ];
18
        $content = <<<'JSON'
19
    {
20
  "csp-report": {
21
    "document-uri": "http://example.org/page.html",
22
    "referrer": "http://evil.example.com/",
23
    "blocked-uri": "http://evil.example.com/evil.js",
24
    "violated-directive": "script-src 'self' https://apis.google.com",
25
    "original-policy": "script-src 'self' https://apis.google.com; report-uri http://example.org/my_amazing_csp_report_parser"
26
  }
27
}
28
JSON;
29
        $client = static::createClient();
30
        $client->request($method, $uri, $parameters, $files, $server, $content);
31
        $response = $client->getResponse();
32
        $this->assertTrue($response->isSuccessful(), 'Accepting a valid log test failed');
33
    }
34
}
35