Passed
Push — monitor-3.0.x ( 70a148...ec4223 )
by Tim
02:15
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));
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected ')' on line 29 at column 40
Loading history...
30
        Assert::keyExists($authSourceData, 'keytab');
31
        $keytab = $authSourceData['keytab'];
32
33
        $this->handle = new KRB5NegotiateAuth($keytab);
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