|
6 | 6 | use Clue\React\Socks\Client; |
7 | 7 | use Clue\React\Socks\Server; |
8 | 8 | use React\EventLoop\Loop; |
| 9 | +use React\Promise\Promise; |
9 | 10 | use React\Socket\Connector; |
10 | 11 | use React\Socket\SecureConnector; |
11 | 12 | use React\Socket\SocketServer; |
@@ -440,28 +441,44 @@ public function testSecureConnectorOkay() |
440 | 441 | $this->assertResolveStream($ssl->connect('www.google.com:443')); |
441 | 442 | } |
442 | 443 |
|
443 | | - /** @group internet */ |
444 | | - public function testSecureConnectorToBadSslWithVerifyFails() |
| 444 | + public function testSecureConnectionToTlsServerWithSelfSignedCertificateFailsWithVerifyPeer() |
445 | 445 | { |
446 | 446 | if (!function_exists('stream_socket_enable_crypto')) { |
447 | 447 | $this->markTestSkipped('Required function does not exist in your environment (HHVM?)'); |
448 | 448 | } |
449 | 449 |
|
| 450 | + $socket = new SocketServer('tls://127.0.0.1:0', array( |
| 451 | + 'tls' => array( |
| 452 | + 'local_cert' => __DIR__ . '/../examples/localhost.pem', |
| 453 | + ) |
| 454 | + )); |
| 455 | + $socket->on('connection', $this->expectCallableNever()); |
| 456 | + |
450 | 457 | $ssl = new SecureConnector($this->client, null, array('verify_peer' => true)); |
451 | 458 |
|
452 | | - $this->assertRejectPromise($ssl->connect('self-signed.badssl.com:443')); |
| 459 | + $this->assertRejectPromise($ssl->connect($socket->getAddress())); |
453 | 460 | } |
454 | 461 |
|
455 | | - /** @group internet */ |
456 | | - public function testSecureConnectorToBadSslWithoutVerifyWorks() |
| 462 | + public function testSecureConnectionToTlsServerWithSelfSignedCertificateWorksWithoutVerifyPeer() |
457 | 463 | { |
458 | 464 | if (defined('HHVM_VERSION')) { |
459 | 465 | $this->markTestSkipped('Not supported on HHVM'); |
460 | 466 | } |
461 | 467 |
|
| 468 | + $socket = new SocketServer('tls://127.0.0.1:0', array( |
| 469 | + 'tls' => array( |
| 470 | + 'local_cert' => __DIR__ . '/../examples/localhost.pem', |
| 471 | + ) |
| 472 | + )); |
| 473 | + $socket->on('connection', $this->expectCallableOnce()); |
| 474 | + $promise = new Promise(function ($resolve) use ($socket) { |
| 475 | + $socket->on('connection', $resolve); |
| 476 | + }); |
| 477 | + |
462 | 478 | $ssl = new SecureConnector($this->client, null, array('verify_peer' => false)); |
463 | 479 |
|
464 | | - $this->assertResolveStream($ssl->connect('self-signed.badssl.com:443')); |
| 480 | + $this->assertResolveStream($ssl->connect($socket->getAddress())); |
| 481 | + $this->assertResolveStream($promise); |
465 | 482 | } |
466 | 483 |
|
467 | 484 | /** @group internet */ |
|
0 commit comments