@@ -82,6 +82,47 @@ function it_does_not_load_cookie_if_domain_does_not_match(RequestInterface $requ
8282 }, function () {});
8383 }
8484
85+ function it_does_not_load_cookie_on_hackish_domains (RequestInterface $ request , UriInterface $ uri , Promise $ promise )
86+ {
87+ $ hackishDomains = [
88+ 'hacktest.com ' ,
89+ 'test.com.hacked.org ' ,
90+ ];
91+ $ cookie = new Cookie ('name ' , 'value ' , 86400 , 'test.com ' );
92+ $ this ->cookieJar ->addCookie ($ cookie );
93+
94+ foreach ($ hackishDomains as $ domain ) {
95+ $ request ->getUri ()->willReturn ($ uri );
96+ $ uri ->getHost ()->willReturn ($ domain );
97+
98+ $ request ->withAddedHeader ('Cookie ' , 'name=value ' )->shouldNotBeCalled ();
99+
100+ $ this ->handleRequest ($ request , function (RequestInterface $ requestReceived ) use ($ request , $ promise ) {
101+ if (Argument::is ($ requestReceived )->scoreArgument ($ request ->getWrappedObject ())) {
102+ return $ promise ->getWrappedObject ();
103+ }
104+ }, function () {});
105+ }
106+ }
107+
108+ function it_loads_cookie_on_subdomains (RequestInterface $ request , UriInterface $ uri , Promise $ promise )
109+ {
110+ $ cookie = new Cookie ('name ' , 'value ' , 86400 , 'test.com ' );
111+ $ this ->cookieJar ->addCookie ($ cookie );
112+
113+ $ request ->getUri ()->willReturn ($ uri );
114+ $ uri ->getHost ()->willReturn ('www.test.com ' );
115+ $ uri ->getPath ()->willReturn ('/ ' );
116+
117+ $ request ->withAddedHeader ('Cookie ' , 'name=value ' )->willReturn ($ request );
118+
119+ $ this ->handleRequest ($ request , function (RequestInterface $ requestReceived ) use ($ request , $ promise ) {
120+ if (Argument::is ($ requestReceived )->scoreArgument ($ request ->getWrappedObject ())) {
121+ return $ promise ->getWrappedObject ();
122+ }
123+ }, function () {});
124+ }
125+
85126 function it_does_not_load_cookie_if_path_does_not_match (RequestInterface $ request , UriInterface $ uri , Promise $ promise )
86127 {
87128 $ cookie = new Cookie ('name ' , 'value ' , 86400 , 'test.com ' , '/sub ' );
0 commit comments