1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor; |
4
|
|
|
|
5
|
|
|
class Monitor |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var TestConfiguration|null |
9
|
|
|
*/ |
10
|
|
|
private $configuration = null; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
private $results = array(); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
private $state = array(); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @return void |
|
|
|
|
24
|
|
|
*/ |
25
|
|
|
public function __construct() |
26
|
|
|
{ |
27
|
|
|
$this->configuration = new TestConfiguration(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function invokeTestSuites() |
34
|
|
|
{ |
35
|
|
|
$this->invokeModuleCheck(); |
36
|
|
|
$this->invokeConfigurationCheck(); |
37
|
|
|
$this->invokeStoreCheck(); |
38
|
|
|
$this->invokeAuthSourceCheck(); |
39
|
|
|
$this->invokeMetadataCheck(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return TestConfiguration |
|
|
|
|
44
|
|
|
*/ |
45
|
|
|
public function getConfiguration() |
46
|
|
|
{ |
47
|
|
|
return $this->configuration; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function getResults() |
54
|
|
|
{ |
55
|
|
|
return $this->results; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return integer |
60
|
|
|
*/ |
61
|
|
|
public function getState() |
62
|
|
|
{ |
63
|
|
|
$filtered = array_diff($this->state, array(State::SKIPPED)); |
64
|
|
|
return empty($filtered) ? State::NOSTATE : min($filtered); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
private function invokeModuleCheck() |
71
|
|
|
{ |
72
|
|
|
$testsuite = new TestSuite\Modules($this->configuration); |
73
|
|
|
$this->results['modules'] = $testsuite->getMessages(); |
74
|
|
|
$this->state[] = $testsuite->getState(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
private function invokeConfigurationCheck() |
81
|
|
|
{ |
82
|
|
|
$testsuite = new TestSuite\Configuration($this->configuration); |
|
|
|
|
83
|
|
|
$this->results['configuration'] = $testsuite->getMessages(); |
84
|
|
|
$this->state[] = $testsuite->getState(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
private function invokeStoreCheck() |
91
|
|
|
{ |
92
|
|
|
$testsuite = new TestSuite\Store($this->configuration); |
|
|
|
|
93
|
|
|
$this->results['store'] = $testsuite->getMessages(); |
94
|
|
|
$this->state[] = $testsuite->getState(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
private function invokeAuthSourceCheck() |
101
|
|
|
{ |
102
|
|
|
$testsuite = new TestSuite\AuthSources($this->configuration); |
|
|
|
|
103
|
|
|
$this->results['authsources'] = $testsuite->getMessages(); |
104
|
|
|
$this->state[] = $testsuite->getState(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
private function invokeMetadataCheck() |
111
|
|
|
{ |
112
|
|
|
$testsuite = new TestSuite\Metadata($this->configuration); |
|
|
|
|
113
|
|
|
$this->results['metadata'] = $testsuite->getMessages(); |
114
|
|
|
$this->state[] = $testsuite->getState(); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.