CSPLoggerControllerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
c 1
b 1
f 0
lcom 1
cbo 2
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testIndex() 0 25 1
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