-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMetaRefreshTest.php
More file actions
108 lines (88 loc) · 2.96 KB
/
MetaRefreshTest.php
File metadata and controls
108 lines (88 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
declare(strict_types=1);
namespace SimpleSAML\Test\Module\metarefresh\Controller;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Configuration;
use SimpleSAML\Module\metarefresh\Controller;
use SimpleSAML\Utils;
/**
* Set of tests for the controllers in the "metarefresh" module.
*
* @package SimpleSAML\Test
*/
final class MetaRefreshTest extends TestCase
{
/** @var \SimpleSAML\Configuration */
protected $authsources;
/** @var \SimpleSAML\Configuration */
protected $config;
/** @var \SimpleSAML\Configuration */
protected $module_config;
/** @var \SimpleSAML\Utils\Auth */
protected $authUtils;
/**
* Set up for each test.
*/
protected function setUp(): void
{
parent::setUp();
$this->config = Configuration::loadFromArray(
[
'baseurlpath' => 'https://example.org/simplesaml',
'module.enable' => ['metarefresh' => true],
],
'[ARRAY]',
'simplesaml',
);
$this->module_config = Configuration::loadFromArray(
[
'sets' => [
'example' => [
'cron' => ['hourly'],
'sources' => [
[
'src' => 'https://nexus.microsoftonline-p.com/federationmetadata/saml20/federationmetadata.xml',
],
],
'outputFormat' => 'flatfile',
'outputDir' => sys_get_temp_dir(),
],
],
],
'[ARRAY]',
'simplesaml',
);
$this->authsources = Configuration::loadFromArray(
[
'admin' => ['core:AdminPassword'],
],
'[ARRAY]',
'simplesaml',
);
$this->authUtils = new class () extends Utils\Auth {
public function requireAdmin(): void
{
// stub
}
};
Configuration::setPreLoadedConfig($this->config, 'config.php');
Configuration::setPreLoadedConfig($this->module_config, 'module_metarefresh.php');
}
/**
*/
public function testMetaRefresh(): void
{
$_SERVER['REQUEST_URI'] = '/module.php/metarefresh/';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
Configuration::setPreLoadedConfig($this->authsources, 'authsources.php');
$c = new Controller\MetaRefresh($this->config);
$c->setAuthUtils($this->authUtils);
$c->setModuleConfig($this->module_config);
$response = $c->main();
$this->assertTrue($response->isSuccessful());
$contents = $response->getContents();
$this->assertStringContainsString('[metarefresh]: Executing set [example]', $contents);
$this->assertStringContainsString('In set [example] loading source', $contents);
}
}