@@ -65,10 +65,10 @@ public static function getExcludeData(): array
6565    /** 
6666     * @dataProvider getExcludeData 
6767     */ 
68-     public  function  testExclude (string  $ ipAddr$ subnetsbool  $ mustThrow
68+     public  function  testExcludeByIp (string  $ ipAddr$ subnetsbool  $ mustThrow
6969    {
7070        $ content'foo ' ;
71-         $ urlsprintf ('http://%s/ ' , 0  <  substr_count ($ ipAddr': '  ) ?  sprintf ( ' [%s] ' ,  $ ipAddr ) :  $ ipAddr 
71+         $ urlsprintf ('http://%s/ ' , strtr ($ ipAddr'.: '  ,  ' -- ' ) );
7272
7373        if  ($ mustThrow
7474            $ this expectException (TransportException::class);
@@ -85,6 +85,29 @@ public function testExclude(string $ipAddr, $subnets, bool $mustThrow)
8585        }
8686    }
8787
88+     /** 
89+      * @dataProvider getExcludeData 
90+      */ 
91+     public  function  testExcludeByHost (string  $ ipAddr$ subnetsbool  $ mustThrow
92+     {
93+         $ content'foo ' ;
94+         $ urlsprintf ('http://%s/ ' , str_contains ($ ipAddr': ' ) ? sprintf ('[%s] ' , $ ipAddr$ ipAddr
95+ 
96+         if  ($ mustThrow
97+             $ this expectException (TransportException::class);
98+             $ this expectExceptionMessage (sprintf ('Host "%s" is blocked for "%s". ' , $ ipAddr$ url
99+         }
100+ 
101+         $ previousHttpClient$ this getHttpClientMock ($ url$ ipAddr$ content
102+         $ clientnew  NoPrivateNetworkHttpClient ($ previousHttpClient$ subnets
103+         $ response$ clientrequest ('GET ' , $ url
104+ 
105+         if  (!$ mustThrow
106+             $ this assertEquals ($ content$ responsegetContent ());
107+             $ this assertEquals (200 , $ responsegetStatusCode ());
108+         }
109+     }
110+ 
88111    public  function  testCustomOnProgressCallback ()
89112    {
90113        $ ipAddr'104.26.14.6 ' ;
0 commit comments