Passed
Branch master (4b23d6)
by Tim
04:40
created

Negotiate::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\TestSuite\AuthSource;
4
5
use SimpleSAML\Module\Monitor\TestConfiguration;
6
use SimpleSAML\Module\Monitor\TestCase;
7
use SimpleSAML\Module\Monitor\TestData;
8
9
final class Negotiate extends \SimpleSAML\Module\Monitor\TestSuiteFactory
10
{
11
    /** @var string|null */
12
    private $authorization;
13
14
    /** @var \KRB5NegotiateAuth */
15
    private $handle;
16
17
18
    /**
19
     * @param \SimpleSAML\Module\Monitor\TestConfiguration $configuration
20
     * @param \SimpleSAML\Module\Monitor\TestData $testData
21
     */
22
    public function __construct(TestConfiguration $configuration, TestData $testData)
23
    {
24
        $authSourceData = $testData->getInputItem('authSourceData');
25
        $serverVars = $configuration->getServerVars();
26
27
        assert(is_array($authSourceData));
28
29
        $keytab = isset($authSourceData['keytab']) ? $authSourceData['keytab'] : null;
30
        $this->handle = new \KRB5NegotiateAuth($keytab);
0 ignored issues
show
Bug introduced by
The call to KRB5NegotiateAuth::__construct() has too few arguments starting with spn. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $this->handle = /** @scrutinizer ignore-call */ new \KRB5NegotiateAuth($keytab);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
31
        $this->authorization = $serverVars->get('HTTP_AUTHORIZATION');
32
        $this->setCategory('SPNEGO authentication source');
33
34
        parent::__construct($configuration);
35
    }
36
37
38
    /**
39
     * @return void
40
     */
41
    public function invokeTest(): void
42
    {
43
        $input = [
44
            'handle' => $this->handle,
45
            'authorization' => $this->authorization
46
        ];
47
        $testData = new TestData($input);
48
49
        $test = new TestCase\AuthSource\Negotiate($testData);
50
        $this->addTestResult($test->getTestResult());
51
        $this->setTestResult($test->getTestResult());
52
    }
53
}
54