@@ -180,9 +180,8 @@ public function testConnectionSocksWithAuthenticationOverUnix()
180180
181181 $ path = sys_get_temp_dir () . '/test ' . mt_rand (1000 , 9999 ) . '.sock ' ;
182182 $ socket = new UnixServer ($ path , $ this ->loop );
183- $ this ->server = new Server ($ this ->loop );
183+ $ this ->server = new Server ($ this ->loop , null , array ( ' name ' => ' pass ' ) );
184184 $ this ->server ->listen ($ socket );
185- $ this ->server ->setAuthArray (array ('name ' => 'pass ' ));
186185
187186 $ this ->connector = new Connector ($ this ->loop );
188187 $ this ->client = new Client ('socks+unix://name:pass@ ' . $ path , $ this ->connector );
@@ -195,7 +194,11 @@ public function testConnectionSocksWithAuthenticationOverUnix()
195194 /** @group internet */
196195 public function testConnectionAuthenticationFromUri ()
197196 {
198- $ this ->server ->setAuthArray (array ('name ' => 'pass ' ));
197+ $ this ->server = new Server ($ this ->loop , null , array ('name ' => 'pass ' ));
198+
199+ $ socket = new React \Socket \Server (0 , $ this ->loop );
200+ $ this ->server ->listen ($ socket );
201+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
199202
200203 $ this ->client = new Client ('name:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
201204
@@ -207,7 +210,7 @@ public function testConnectionAuthenticationCallback()
207210 {
208211 $ called = 0 ;
209212 $ that = $ this ;
210- $ this ->server -> setAuth ( function ($ name , $ pass , $ remote ) use ($ that , &$ called ) {
213+ $ this ->server = new Server ( $ this -> loop , null , function ($ name , $ pass , $ remote ) use ($ that , &$ called ) {
211214 ++$ called ;
212215 $ that ->assertEquals ('name ' , $ name );
213216 $ that ->assertEquals ('pass ' , $ pass );
@@ -216,6 +219,10 @@ public function testConnectionAuthenticationCallback()
216219 return true ;
217220 });
218221
222+ $ socket = new React \Socket \Server (0 , $ this ->loop );
223+ $ this ->server ->listen ($ socket );
224+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
225+
219226 $ this ->client = new Client ('name:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
220227
221228 $ this ->assertResolveStream ($ this ->client ->connect ('www.google.com:80 ' ));
@@ -226,12 +233,16 @@ public function testConnectionAuthenticationCallback()
226233 public function testConnectionAuthenticationCallbackWillNotBeInvokedIfClientsSendsNoAuth ()
227234 {
228235 $ called = 0 ;
229- $ this ->server -> setAuth ( function () use (&$ called ) {
236+ $ this ->server = new Server ( $ this -> loop , null , function () use (&$ called ) {
230237 ++$ called ;
231238
232239 return true ;
233240 });
234241
242+ $ socket = new React \Socket \Server (0 , $ this ->loop );
243+ $ this ->server ->listen ($ socket );
244+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
245+
235246 $ this ->client = new Client ('127.0.0.1: ' . $ this ->port , $ this ->connector );
236247
237248 $ this ->assertRejectPromise ($ this ->client ->connect ('www.google.com:80 ' ));
@@ -241,7 +252,11 @@ public function testConnectionAuthenticationCallbackWillNotBeInvokedIfClientsSen
241252 /** @group internet */
242253 public function testConnectionAuthenticationFromUriEncoded ()
243254 {
244- $ this ->server ->setAuthArray (array ('name ' => 'p@ss:w0rd ' ));
255+ $ this ->server = new Server ($ this ->loop , null , array ('name ' => 'p@ss:w0rd ' ));
256+
257+ $ socket = new React \Socket \Server (0 , $ this ->loop );
258+ $ this ->server ->listen ($ socket );
259+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
245260
246261 $ this ->client = new Client (rawurlencode ('name ' ) . ': ' . rawurlencode ('p@ss:w0rd ' ) . '@127.0.0.1: ' . $ this ->port , $ this ->connector );
247262
@@ -251,7 +266,11 @@ public function testConnectionAuthenticationFromUriEncoded()
251266 /** @group internet */
252267 public function testConnectionAuthenticationFromUriWithOnlyUserAndNoPassword ()
253268 {
254- $ this ->server ->setAuthArray (array ('empty ' => '' ));
269+ $ this ->server = new Server ($ this ->loop , null , array ('empty ' => '' ));
270+
271+ $ socket = new React \Socket \Server (0 , $ this ->loop );
272+ $ this ->server ->listen ($ socket );
273+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
255274
256275 $ this ->client = new Client ('empty@127.0.0.1: ' . $ this ->port , $ this ->connector );
257276
@@ -261,7 +280,12 @@ public function testConnectionAuthenticationFromUriWithOnlyUserAndNoPassword()
261280 /** @group internet */
262281 public function testConnectionAuthenticationEmptyPassword ()
263282 {
264- $ this ->server ->setAuthArray (array ('user ' => '' ));
283+ $ this ->server = new Server ($ this ->loop , null , array ('user ' => '' ));
284+
285+ $ socket = new React \Socket \Server (0 , $ this ->loop );
286+ $ this ->server ->listen ($ socket );
287+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
288+
265289 $ this ->client = new Client ('user@127.0.0.1: ' . $ this ->port , $ this ->connector );
266290
267291 $ this ->assertResolveStream ($ this ->client ->connect ('www.google.com:80 ' ));
@@ -277,7 +301,11 @@ public function testConnectionAuthenticationUnused()
277301
278302 public function testConnectionInvalidNoAuthenticationOverLegacySocks4 ()
279303 {
280- $ this ->server ->setAuthArray (array ('name ' => 'pass ' ));
304+ $ this ->server = new Server ($ this ->loop , null , array ('name ' => 'pass ' ));
305+
306+ $ socket = new React \Socket \Server (0 , $ this ->loop );
307+ $ this ->server ->listen ($ socket );
308+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
281309
282310 $ this ->client = new Client ('socks4://127.0.0.1: ' . $ this ->port , $ this ->connector );
283311
@@ -286,7 +314,11 @@ public function testConnectionInvalidNoAuthenticationOverLegacySocks4()
286314
287315 public function testConnectionInvalidNoAuthentication ()
288316 {
289- $ this ->server ->setAuthArray (array ('name ' => 'pass ' ));
317+ $ this ->server = new Server ($ this ->loop , null , array ('name ' => 'pass ' ));
318+
319+ $ socket = new React \Socket \Server (0 , $ this ->loop );
320+ $ this ->server ->listen ($ socket );
321+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
290322
291323 $ this ->client = new Client ('socks5://127.0.0.1: ' . $ this ->port , $ this ->connector );
292324
@@ -295,7 +327,11 @@ public function testConnectionInvalidNoAuthentication()
295327
296328 public function testConnectionInvalidAuthenticationMismatch ()
297329 {
298- $ this ->server ->setAuthArray (array ('name ' => 'pass ' ));
330+ $ this ->server = new Server ($ this ->loop , null , array ('name ' => 'pass ' ));
331+
332+ $ socket = new React \Socket \Server (0 , $ this ->loop );
333+ $ this ->server ->listen ($ socket );
334+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
299335
300336 $ this ->client = new Client ('user:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
301337
@@ -304,32 +340,44 @@ public function testConnectionInvalidAuthenticationMismatch()
304340
305341 public function testConnectionInvalidAuthenticatorReturnsFalse ()
306342 {
307- $ this ->server -> setAuth ( function () {
343+ $ this ->server = new Server ( $ this -> loop , null , function () {
308344 return false ;
309345 });
310346
347+ $ socket = new React \Socket \Server (0 , $ this ->loop );
348+ $ this ->server ->listen ($ socket );
349+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
350+
311351 $ this ->client = new Client ('user:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
312352
313353 $ this ->assertRejectPromise ($ this ->client ->connect ('www.google.com:80 ' ), null , SOCKET_EACCES );
314354 }
315355
316356 public function testConnectionInvalidAuthenticatorReturnsPromiseFulfilledWithFalse ()
317357 {
318- $ this ->server -> setAuth ( function () {
358+ $ this ->server = new Server ( $ this -> loop , null , function () {
319359 return \React \Promise \resolve (false );
320360 });
321361
362+ $ socket = new React \Socket \Server (0 , $ this ->loop );
363+ $ this ->server ->listen ($ socket );
364+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
365+
322366 $ this ->client = new Client ('user:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
323367
324368 $ this ->assertRejectPromise ($ this ->client ->connect ('www.google.com:80 ' ), null , SOCKET_EACCES );
325369 }
326370
327371 public function testConnectionInvalidAuthenticatorReturnsPromiseRejected ()
328372 {
329- $ this ->server -> setAuth ( function () {
373+ $ this ->server = new Server ( $ this -> loop , null , function () {
330374 return \React \Promise \reject ();
331375 });
332376
377+ $ socket = new React \Socket \Server (0 , $ this ->loop );
378+ $ this ->server ->listen ($ socket );
379+ $ this ->port = parse_url ($ socket ->getAddress (), PHP_URL_PORT );
380+
333381 $ this ->client = new Client ('user:pass@127.0.0.1: ' . $ this ->port , $ this ->connector );
334382
335383 $ this ->assertRejectPromise ($ this ->client ->connect ('www.google.com:80 ' ), null , SOCKET_EACCES );
0 commit comments