1 | <?php |
||
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 | $serverVars = $configuration->getServerVars(); |
||
34 | |||
35 | $this->metadataCert = $globalConfig->getString('metadata.sign.certificate', null); |
||
36 | $this->serverName = $serverVars->get('SERVER_NAME'); |
||
37 | $this->serverPort = $serverVars->get('SERVER_PORT'); |
||
38 | |||
39 | parent::__construct($configuration); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return void |
||
44 | */ |
||
45 | protected function invokeTestSuite() |
||
46 | { |
||
47 | // Check network connection to full public URL |
||
48 | $input = [ |
||
49 | 'connectString' = 'ssl://'.$hostname.':'.$port, |
||
|
|||
50 | 'context' = stream_context_create([ |
||
51 | "ssl" => [ |
||
52 | "capture_peer_cert" => true, |
||
53 | "verify_peer" => false, |
||
54 | "verify_peer_name" => false |
||
55 | ] |
||
56 | ]), |
||
57 | ]; |
||
58 | |||
59 | $connTest = new TestCase\Network\ConnectUri($this, new TestData($input)); |
||
60 | $connTestResult = $connTest->getTestResult(); |
||
61 | |||
62 | $this->addTest($connTest); |
||
63 | |||
64 | if ($connTestResult->getState() === State::OK) { |
||
65 | // Check Service Communications Certificate |
||
66 | $certData = $connTestResult->getOutput('certData'); |
||
67 | |||
68 | if (Utils\HTTP::isHTTPS() && $certData !== null) { |
||
69 | $input = [ |
||
70 | 'category' => 'Service Communications Certificate', |
||
71 | 'certData' => $certData, |
||
72 | ]; |
||
73 | |||
74 | $certTest = new TestCase\Cert\Data($this, new TestData($input)); |
||
75 | $this->addTest($certTest); |
||
76 | } |
||
77 | } |
||
78 | |||
79 | // Check metadata signing certificate when available |
||
80 | if (is_string($this->metadataCert)) { |
||
81 | $input = array( |
||
100 |