|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests; |
|
8
|
|
|
|
|
9
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Router; |
|
10
|
|
|
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; |
|
11
|
|
|
use Psr\Log\LoggerInterface; |
|
12
|
|
|
|
|
13
|
|
|
class RouterPortHostURITest extends RouterBaseTest |
|
14
|
|
|
{ |
|
15
|
|
View Code Duplication |
public function matchProvider(): array |
|
16
|
|
|
{ |
|
17
|
|
|
return [ |
|
18
|
|
|
[SimplifiedRequest::fromUrl('http://example.com'), 'fifth_sa'], |
|
19
|
|
|
[SimplifiedRequest::fromUrl('https://example.com'), 'fourth_sa'], |
|
20
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/'), 'fifth_sa'], |
|
21
|
|
|
[SimplifiedRequest::fromUrl('https://example.com/'), 'fourth_sa'], |
|
22
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//'), 'fifth_sa'], |
|
23
|
|
|
[SimplifiedRequest::fromUrl('https://example.com//'), 'fourth_sa'], |
|
24
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:8080/'), 'default_sa'], |
|
25
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_siteaccess/'), 'fifth_sa'], |
|
26
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_siteaccess'), 'fifth_sa'], |
|
27
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_sa'), 'fifth_sa'], |
|
28
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_salt'), 'fifth_sa'], |
|
29
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa.foo'), 'fifth_sa'], |
|
30
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test'), 'fifth_sa'], |
|
31
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/'), 'fifth_sa'], |
|
32
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'fifth_sa'], |
|
33
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'fifth_sa'], |
|
34
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'fifth_sa'], |
|
35
|
|
|
|
|
36
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'fifth_sa'], |
|
37
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'fifth_sa'], |
|
38
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa//'), 'fifth_sa'], |
|
39
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa///test'), 'fifth_sa'], |
|
40
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/foo'), 'fifth_sa'], |
|
41
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/foo/bar'), 'fifth_sa'], |
|
42
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/first_sa/'), 'fourth_sa'], |
|
43
|
|
|
[SimplifiedRequest::fromUrl('http://third_siteaccess/first_sa/'), 'fifth_sa'], |
|
44
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/'), 'fifth_sa'], |
|
45
|
|
|
[SimplifiedRequest::fromUrl('https://first_sa/'), 'fourth_sa'], |
|
46
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:81/'), 'third_sa'], |
|
47
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/'), 'fifth_sa'], |
|
48
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/'), 'fourth_sa'], |
|
49
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/'), 'first_sa'], |
|
50
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/foo/'), 'fifth_sa'], |
|
51
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/foo/'), 'fourth_sa'], |
|
52
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/foo/'), 'first_sa'], |
|
53
|
|
|
|
|
54
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'fifth_sa'], |
|
55
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'fifth_sa'], |
|
56
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa?param1=foo'), 'fifth_sa'], |
|
57
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/foo/'), 'fifth_sa'], |
|
58
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/second_sa/'), 'fourth_sa'], |
|
59
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:83/second_sa/'), 'first_sa'], |
|
60
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/second_sa/'), 'fourth_sa'], |
|
61
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/second_sa/'), 'first_sa'], |
|
62
|
|
|
|
|
63
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:123/second_sa'), 'first_sa'], |
|
64
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:123/second_sa/'), 'first_sa'], |
|
65
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa?param1=foo'), 'second_sa'], |
|
66
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa/foo/'), 'second_sa'], |
|
67
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa'), 'second_sa'], |
|
68
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa/'), 'second_sa'], |
|
69
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa?param1=foo'), 'second_sa'], |
|
70
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:123/second_sa/foo/'), 'second_sa'], |
|
71
|
|
|
|
|
72
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:81/'), 'third_sa'], |
|
73
|
|
|
[SimplifiedRequest::fromUrl('https://example.com:81/'), 'third_sa'], |
|
74
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:81/foo'), 'third_sa'], |
|
75
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:81/foo/bar'), 'third_sa'], |
|
76
|
|
|
|
|
77
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/'), 'fourth_sa'], |
|
78
|
|
|
[SimplifiedRequest::fromUrl('https://example.com:82/'), 'fourth_sa'], |
|
79
|
|
|
[SimplifiedRequest::fromUrl('https://example.com:82/foo'), 'fourth_sa'], |
|
80
|
|
|
]; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
View Code Duplication |
protected function createRouter(): Router |
|
84
|
|
|
{ |
|
85
|
|
|
return new Router( |
|
86
|
|
|
$this->matcherBuilder, |
|
87
|
|
|
$this->createMock(LoggerInterface::class), |
|
88
|
|
|
'default_sa', |
|
89
|
|
|
[ |
|
90
|
|
|
'Map\\Port' => [ |
|
91
|
|
|
80 => 'fifth_sa', |
|
92
|
|
|
81 => 'third_sa', |
|
93
|
|
|
82 => 'fourth_sa', |
|
94
|
|
|
83 => 'first_sa', |
|
95
|
|
|
85 => 'first_sa', |
|
96
|
|
|
443 => 'fourth_sa', |
|
97
|
|
|
], |
|
98
|
|
|
'Map\\Host' => [ |
|
99
|
|
|
'first_sa' => 'first_sa', |
|
100
|
|
|
'first_siteaccess' => 'first_sa', |
|
101
|
|
|
'third_siteaccess' => 'third_sa', |
|
102
|
|
|
], |
|
103
|
|
|
'Map\\URI' => [ |
|
104
|
|
|
'first_sa' => 'first_sa', |
|
105
|
|
|
'second_sa' => 'second_sa', |
|
106
|
|
|
], |
|
107
|
|
|
], |
|
108
|
|
|
$this->siteAccessProvider |
|
109
|
|
|
); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\SiteAccessSetting[] |
|
114
|
|
|
*/ |
|
115
|
|
View Code Duplication |
public function getSiteAccessProviderSettings(): array |
|
116
|
|
|
{ |
|
117
|
|
|
return [ |
|
118
|
|
|
new SiteAccessSetting('first_sa', true), |
|
119
|
|
|
new SiteAccessSetting('second_sa', true), |
|
120
|
|
|
new SiteAccessSetting('third_sa', true), |
|
121
|
|
|
new SiteAccessSetting('fourth_sa', true), |
|
122
|
|
|
new SiteAccessSetting('fifth_sa', true), |
|
123
|
|
|
]; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|