Passed
Push — monitor-3.0.x ( ec4223...9ab29a )
by Tim
02:31
created

Negotiate::invokeTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\TestSuite\AuthSource;
4
5
use KRB5NegotiateAuth;
6
use SimpleSAML\Module\Monitor\TestConfiguration;
7
use SimpleSAML\Module\Monitor\TestCase;
8
use SimpleSAML\Module\Monitor\TestData;
9
use Webmozart\Assert\Assert;
10
11
final class Negotiate extends \SimpleSAML\Module\Monitor\TestSuiteFactory
12
{
13
    /** @var string|null */
14
    private $authorization;
15
16
    /** @var \KRB5NegotiateAuth */
17
    private $handle;
18
19
20
    /**
21
     * @param \SimpleSAML\Module\Monitor\TestConfiguration $configuration
22
     * @param \SimpleSAML\Module\Monitor\TestData $testData
23
     */
24
    public function __construct(TestConfiguration $configuration, TestData $testData)
25
    {
26
        $authSourceData = $testData->getInputItem('authSourceData');
27
        $serverVars = $configuration->getServerVars();
28
29
        Assert::isArray($authSourceData);
30
        Assert::keyExists($authSourceData, 'keytab');
31
        $keytab = $authSourceData['keytab'];
32
33
        $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

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