1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\TestSuite\Configuration; |
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\Module\monitor\TestResult as TestResult; |
9
|
|
|
use \SimpleSAML\Module\monitor\State as State; |
10
|
|
|
use \SimpleSAML\Utils as Utils; |
11
|
|
|
|
12
|
|
|
final class Database extends \SimpleSAML\Module\monitor\TestSuiteFactory |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* var string|null |
16
|
|
|
*/ |
17
|
|
|
private $store = null; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* var array |
21
|
|
|
*/ |
22
|
|
|
private $metadataSources = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* var array |
26
|
|
|
*/ |
27
|
|
|
private $dependentModules = ['consent']; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param TestConfiguration $configuration |
31
|
|
|
*/ |
32
|
|
|
public function __construct($configuration) |
33
|
|
|
{ |
34
|
|
|
$globalConfig = $configuration->getGlobalConfig(); |
35
|
|
|
$this->store = $globalConfig->getString('store.type', 'phpsession'); |
36
|
|
|
$this->metadataSources = $globalConfig->getArray('metadata.sources', array()); |
37
|
|
|
|
38
|
|
|
$this->setCategory('Configuration'); |
39
|
|
|
parent::__construct($configuration); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function invokeTest() |
46
|
|
|
{ |
47
|
|
|
if ($this->store === 'sql') { |
48
|
|
|
// We use a database for session-storage |
49
|
|
|
} else if (in_array(array('type' => 'pdo'), $this->metadataSources, true)) { |
50
|
|
|
// We use a database for metadata-storage |
51
|
|
|
} else { |
52
|
|
|
$dependent = false; |
53
|
|
|
foreach ($module as $this->dependentModules) { |
54
|
|
|
if (\SimpleSAML\Module::isModuleEnabled($module)) { |
|
|
|
|
55
|
|
|
$dependent = true; |
56
|
|
|
break 1; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
if ($dependent === false) { |
60
|
|
|
$testResult = new TestResult('Configuration', ''); |
61
|
|
|
$testResult->setState(State::SKIPPED); |
62
|
|
|
$this->setTestResult($testResult); |
63
|
|
|
return; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
// We are using the database-configuration in some way, so start testing it! |
68
|
|
|
$testResult = new TestResult('Configuration', ''); |
69
|
|
|
$testResult->setState(State::OK); |
70
|
|
|
$this->setTestResult($testResult); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|