99use PHPUnit \Framework \MockObject \Stub ;
1010use PHPUnit \Framework \TestCase ;
1111use Symfony \Component \Cache \Adapter \ArrayAdapter ;
12+ use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
1213use Symfony \Component \Routing \RouterInterface ;
1314
1415class OpenIdConfigurationProviderManagerTest extends TestCase
@@ -77,9 +78,14 @@ public function testGetProviderThrowsOnInvalidKey(): void
7778
7879 public function testGetProviderWithRedirectRoute (): void
7980 {
80- $ this ->stubRouter
81+ // Expect the exact arguments so dropping the route parameters (or the
82+ // route itself) when building the redirect URI fails the test.
83+ $ mockRouter = $ this ->createMock (RouterInterface::class);
84+ $ mockRouter ->expects ($ this ->once ())
8185 ->method ('generate ' )
82- ->willReturn ('https://app.com/callback ' );
86+ ->with ('my_route ' , ['param ' => 'value ' ], UrlGeneratorInterface::ABSOLUTE_URL )
87+ ->willReturn ('https://app.example.org/callback ' );
88+ $ this ->stubRouter = $ mockRouter ;
8389
8490 $ manager = $ this ->createManager ([
8591 'test ' => $ this ->getBaseProviderConfig () + [
@@ -96,7 +102,7 @@ public function testGetProviderWithRedirectRouteNoParameters(): void
96102 {
97103 $ this ->stubRouter
98104 ->method ('generate ' )
99- ->willReturn ('https://app.com /callback ' );
105+ ->willReturn ('https://app.example.org /callback ' );
100106
101107 $ manager = $ this ->createManager ([
102108 'test ' => $ this ->getBaseProviderConfig () + [
@@ -112,7 +118,7 @@ public function testGetProviderWithLeeway(): void
112118 {
113119 $ manager = $ this ->createManager ([
114120 'test ' => $ this ->getBaseProviderConfig () + [
115- 'redirect_uri ' => 'https://app.com /callback ' ,
121+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
116122 'leeway ' => 30 ,
117123 ],
118124 ]);
@@ -125,7 +131,7 @@ public function testGetProviderWithCacheDuration(): void
125131 {
126132 $ manager = $ this ->createManager ([
127133 'test ' => $ this ->getBaseProviderConfig () + [
128- 'redirect_uri ' => 'https://app.com /callback ' ,
134+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
129135 'cache_duration ' => 3600 ,
130136 ],
131137 ]);
@@ -138,7 +144,7 @@ public function testGetProviderWithAllowHttp(): void
138144 {
139145 $ manager = $ this ->createManager ([
140146 'test ' => $ this ->getBaseProviderConfig () + [
141- 'redirect_uri ' => 'https://app.com /callback ' ,
147+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
142148 'allow_http ' => true ,
143149 ],
144150 ]);
@@ -166,7 +172,7 @@ public function testGetProviderForwardsHttpClientOptions(): void
166172 {
167173 $ manager = $ this ->createManager ([
168174 'test ' => $ this ->getBaseProviderConfig () + [
169- 'redirect_uri ' => 'https://app.com /callback ' ,
175+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
170176 'http_client_options ' => [
171177 'timeout ' => 1.5 ,
172178 'proxy ' => 'http://proxy:8080 ' ,
@@ -189,7 +195,7 @@ public function testGetProviderWithoutHttpClientOptionsLeavesGuzzleDefaults(): v
189195 {
190196 $ manager = $ this ->createManager ([
191197 'test ' => $ this ->getBaseProviderConfig () + [
192- 'redirect_uri ' => 'https://app.com /callback ' ,
198+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
193199 ],
194200 ]);
195201
@@ -205,7 +211,7 @@ public function testGetProviderCachesInstance(): void
205211 {
206212 $ manager = $ this ->createManager ([
207213 'test ' => $ this ->getBaseProviderConfig () + [
208- 'redirect_uri ' => 'https://app.com /callback ' ,
214+ 'redirect_uri ' => 'https://app.example.org /callback ' ,
209215 ],
210216 ]);
211217
0 commit comments