1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor; |
4
|
|
|
|
5
|
|
|
class Monitor |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var TestConfiguration |
9
|
|
|
*/ |
10
|
|
|
private $configuration; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
private $results = array(); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
private $state = array(); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param TestConfiguration $testConfiguration |
24
|
|
|
*/ |
25
|
|
|
public function __construct($testConfiguration) |
26
|
|
|
{ |
27
|
|
|
$this->setTestConfiguration($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 getTestConfiguration() |
46
|
|
|
{ |
47
|
|
|
assert($this->configuration instanceof TestConfiguration); |
48
|
|
|
return $this->configuration; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param TestConfiguration $testConfiguration |
53
|
|
|
*/ |
54
|
|
|
private function setTestConfiguration($testConfiguration) |
55
|
|
|
{ |
56
|
|
|
assert($testConfiguration instanceof TestConfiguration); |
57
|
|
|
$this->configuration = $testConfiguration; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
|
|
public function getResults() |
64
|
|
|
{ |
65
|
|
|
return $this->results; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return integer |
70
|
|
|
*/ |
71
|
|
|
public function getState() |
72
|
|
|
{ |
73
|
|
|
$filtered = array_diff($this->state, array(State::SKIPPED)); |
74
|
|
|
return empty($filtered) ? State::NOSTATE : min($filtered); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
private function invokeModuleCheck() |
81
|
|
|
{ |
82
|
|
|
$testsuite = new TestSuite\Modules($this->configuration); |
83
|
|
|
$this->results['modules'] = $testsuite->getArrayizeTestResults(); |
84
|
|
|
$this->state[] = $testsuite->calculateState(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
private function invokeConfigurationCheck() |
91
|
|
|
{ |
92
|
|
|
$testsuite = new TestSuite\Configuration($this->configuration); |
93
|
|
|
$this->results['configuration'] = $testsuite->getArrayizeTestResults(); |
94
|
|
|
$this->state[] = $testsuite->calculateState(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
private function invokeStoreCheck() |
101
|
|
|
{ |
102
|
|
|
$testsuite = new TestSuite\Store($this->configuration); |
103
|
|
|
$this->results['store'] = $testsuite->getArrayizeTestResults(); |
104
|
|
|
$this->state[] = $testsuite->calculateState(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
private function invokeAuthSourceCheck() |
111
|
|
|
{ |
112
|
|
|
$testsuite = new TestSuite\AuthSources($this->configuration); |
113
|
|
|
$testResult = $testsuite->getTestResult(); |
114
|
|
|
$this->state[] = $testsuite->calculateState(); |
115
|
|
|
$this->results['authsources'] = $testResult->getOutput(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return void |
120
|
|
|
*/ |
121
|
|
|
private function invokeMetadataCheck() |
122
|
|
|
{ |
123
|
|
|
$testsuite = new TestSuite\Metadata($this->configuration); |
124
|
|
|
$testResult = $testsuite->getTestResult(); |
125
|
|
|
$this->state[] = $testsuite->calculateState(); |
126
|
|
|
$this->results['metadata'] = $testResult->getOutput(); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|