1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\TestSuite; |
4
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration; |
6
|
|
|
use \SimpleSAML\Module\monitor\TestCase as TestCase; |
7
|
|
|
use \SimpleSAML\Module\monitor\TestData as TestData; |
8
|
|
|
use \SimpleSAML\Utils as Utils; |
9
|
|
|
|
10
|
|
|
final class Configuration extends \SimpleSAML\Module\monitor\TestSuiteFactory |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @param string|null |
14
|
|
|
*/ |
15
|
|
|
private $metadataCert = null; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param string|null; |
19
|
|
|
*/ |
20
|
|
|
private $serverName = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param integer|null; |
24
|
|
|
*/ |
25
|
|
|
private $serverPort = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param TestConfiguration $configuration |
29
|
|
|
*/ |
30
|
|
|
public function __construct($configuration) |
31
|
|
|
{ |
32
|
|
|
$globalConfig = $configuration->getGlobalConfig(); |
33
|
|
|
$this->metadataCert = $globalConfig->getString('metadata.sign.certificate', null); |
34
|
|
|
$this->serverName = Utils\HTTP::getSelfHost(); |
35
|
|
|
$this->serverPort = Utils\HTTP::getServerPort(); |
36
|
|
|
|
37
|
|
|
parent::__construct($configuration); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
protected function invokeTestSuite() |
44
|
|
|
{ |
45
|
|
|
// Check Service Communications Certificate |
46
|
|
|
if (Utils\HTTP::isHTTPS()) { |
47
|
|
|
$input = array( |
48
|
|
|
'category' => 'Service Communications Certificate', |
49
|
|
|
'hostname' => $this->serverName, |
50
|
|
|
'port' => $this->serverPort |
51
|
|
|
); |
52
|
|
|
$testData = new TestData($input); |
53
|
|
|
|
54
|
|
|
$test = new TestCase\Cert\Remote($this, $testData); |
55
|
|
|
$this->addTest($test); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
// Check metadata signing certificate when available |
59
|
|
|
if (is_string($this->metadataCert)) { |
60
|
|
|
$input = array( |
61
|
|
|
'certFile' => Utils\Config::getCertPath($this->metadataCert), |
62
|
|
|
'category' => 'Metadata Signing Certificate' |
63
|
|
|
); |
64
|
|
|
$testData = new TestData($input); |
65
|
|
|
|
66
|
|
|
$test = new TestCase\Cert\File($this, $testData); |
67
|
|
|
$this->addTest($test); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$tests = $this->getTests(); |
71
|
|
|
foreach ($tests as $test) |
72
|
|
|
{ |
73
|
|
|
$this->addMessages($test->getMessages()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$this->calculateState(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|