File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public function supports(Request $request): ?bool
5151 if (null !== $ this ->logger ) {
5252 if ('https ' === $ request ->headers ->get ('X-Forwarded-Proto ' )) {
5353 $ this ->logger ->info ('Redirecting to HTTPS. ("X-Forwarded-Proto" header is set to "https" - did you set "trusted_proxies" correctly?) ' );
54- } elseif (str_contains ($ request ->headers ->get ('Forwarded ' ), 'proto=https ' )) {
54+ } elseif (str_contains ($ request ->headers ->get ('Forwarded ' , '' ), 'proto=https ' )) {
5555 $ this ->logger ->info ('Redirecting to HTTPS. ("Forwarded" header is set to "proto=https" - did you set "trusted_proxies" correctly?) ' );
5656 } else {
5757 $ this ->logger ->info ('Redirecting to HTTPS. ' );
Original file line number Diff line number Diff line change 1212namespace Symfony \Component \Security \Http \Tests \Firewall ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Psr \Log \NullLogger ;
16+ use Symfony \Component \HttpFoundation \HeaderBag ;
1517use Symfony \Component \HttpFoundation \Request ;
1618use Symfony \Component \HttpFoundation \Response ;
1719use Symfony \Component \HttpKernel \Event \RequestEvent ;
@@ -153,4 +155,29 @@ public function testHandleWithSecuredRequestAndHttpChannel()
153155
154156 $ this ->assertSame ($ response , $ event ->getResponse ());
155157 }
158+
159+ public function testSupportsWithoutHeaders ()
160+ {
161+ $ request = $ this ->createMock (Request::class);
162+ $ request
163+ ->expects ($ this ->any ())
164+ ->method ('isSecure ' )
165+ ->willReturn (false )
166+ ;
167+ $ request ->headers = new HeaderBag ();
168+
169+ $ accessMap = $ this ->createMock (AccessMapInterface::class);
170+ $ accessMap
171+ ->expects ($ this ->any ())
172+ ->method ('getPatterns ' )
173+ ->with ($ this ->equalTo ($ request ))
174+ ->willReturn ([[], 'https ' ])
175+ ;
176+
177+ $ entryPoint = $ this ->createMock (AuthenticationEntryPointInterface::class);
178+
179+ $ listener = new ChannelListener ($ accessMap , $ entryPoint , new NullLogger ());
180+
181+ $ this ->assertTrue ($ listener ->supports ($ request ));
182+ }
156183}
You can’t perform that action at this time.
0 commit comments