Passed
Branch master (4b23d6)
by Tim
04:40
created

TestConfigurationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 34
dl 0
loc 53
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testTestConfiguration() 0 49 1
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\Test;
4
5
use SimpleSAML\Configuration;
6
use SimpleSAML\Module\Monitor\DependencyInjection;
7
use SimpleSAML\Module\Monitor\TestConfiguration;
8
9
/**
10
 * Tests for TestConfiguration
11
 */
12
class TestConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase
13
{
14
    private const FRAMEWORK = '../../../vendor/simplesamlphp/simplesamlphp-test-framework';
15
16
    public function testTestConfiguration(): void
17
    {
18
        $serverVars = new DependencyInjection(['SERVER_NAME' => 'localhost']);
19
        $requestVars = new DependencyInjection(['output' => 'travis']);
20
21
        $globalConfig_input = [
22
            'enable.saml20-idp' => true,
23
            'enable.shib13-idp' => true,
24
            'enable.adfs-idp' => true,
25
            'enable.wsfed-sp' => true,
26
            'metadata.sources' => [
27
                [
28
                    'type' => 'xml',
29
                    'file' => self::FRAMEWORK . '/metadata/xml/valid-metadata-selfsigned.xml',
30
                ],
31
            ],
32
        ];
33
        $authSourceConfig_input = [
34
            'test' => 'travis'
35
        ];
36
        $moduleConfig_input = [
37
            'test' => 'travis'
38
        ];
39
40
        $globalConfig = Configuration::loadFromArray($globalConfig_input);
41
        $authSourceConfig = Configuration::loadFromArray($authSourceConfig_input);
42
        $moduleConfig = Configuration::loadFromArray($moduleConfig_input);
43
44
        Configuration::setPreLoadedConfig($globalConfig, 'config.php');
45
        Configuration::setPreLoadedConfig($moduleConfig, 'module_monitor.php');
46
        Configuration::setPreLoadedConfig($authSourceConfig, 'authsources.php');
47
48
        $testConf = new TestConfiguration($serverVars, $requestVars, $globalConfig, $authSourceConfig, $moduleConfig);
49
50
        $this->assertEquals($serverVars, $testConf->getServerVars());
51
        $this->assertEquals($requestVars, $testConf->getRequestVars());
52
53
        $this->assertEquals($globalConfig, $testConf->getGlobalConfig());
54
        $this->assertEquals($authSourceConfig, $testConf->getAuthSourceConfig());
55
        $this->assertEquals($moduleConfig, $testConf->getModuleConfig());
56
57
        $metadataConfig = $testConf->getMetadataConfig();
58
        $this->assertArrayHasKey(
59
            'https://idp.example.org/saml2/idp/metadata.php',
60
            $metadataConfig['saml20-idp-remote']
61
        );
62
63
        $this->assertNotEmpty($testConf->getAvailableApacheModules());
64
        $this->assertNotEmpty($testConf->getAvailablePhpModules());
65
    }
66
}
67