Skip to content

Commit 90677ba

Browse files
authored
Merge pull request #66 from clue-labs/no-internet
Optionally exclude tests that rely on working internet connection
2 parents 14e1c72 + 5df816b commit 90677ba

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,13 @@ To run the test suite, go to the project root and run:
797797
$ php vendor/bin/phpunit
798798
```
799799

800+
The test suite contains a number of tests that rely on a working internet
801+
connection, alternatively you can also run it like this:
802+
803+
```bash
804+
$ php vendor/bin/phpunit --exclude-group internet
805+
```
806+
800807
## License
801808

802809
MIT, see LICENSE

tests/FunctionalTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use Clue\React\Socks\Client;
44
use Clue\React\Socks\Server;
55
use Clue\React\Block;
6-
use React\Promise\PromiseInterface;
76
use React\Socket\TimeoutConnector;
87
use React\Socket\SecureConnector;
98
use React\Socket\TcpConnector;
@@ -34,11 +33,13 @@ public function setUp()
3433
$this->client = new Client('127.0.0.1:' . $this->port, $this->connector);
3534
}
3635

36+
/** @group internet */
3737
public function testConnection()
3838
{
3939
$this->assertResolveStream($this->client->connect('www.google.com:80'));
4040
}
4141

42+
/** @group internet */
4243
public function testConnectionInvalid()
4344
{
4445
$this->assertRejectPromise($this->client->connect('www.google.com.invalid:80'));
@@ -53,13 +54,15 @@ public function testConnectionWithIpViaSocks4()
5354
$this->assertResolveStream($this->client->connect('127.0.0.1:' . $this->port));
5455
}
5556

57+
/** @group internet */
5658
public function testConnectionWithHostnameViaSocks4Fails()
5759
{
5860
$this->client = new Client('socks4://127.0.0.1:' . $this->port, $this->connector);
5961

6062
$this->assertRejectPromise($this->client->connect('www.google.com:80'));
6163
}
6264

65+
/** @group internet */
6366
public function testConnectionWithInvalidPortFails()
6467
{
6568
$this->assertRejectPromise($this->client->connect('www.google.com:100000'));
@@ -72,6 +75,7 @@ public function testConnectionWithIpv6ViaSocks4Fails()
7275
$this->assertRejectPromise($this->client->connect('[::1]:80'));
7376
}
7477

78+
/** @group internet */
7579
public function testConnectionSocks4a()
7680
{
7781
$this->server->setProtocolVersion('4a');
@@ -80,6 +84,7 @@ public function testConnectionSocks4a()
8084
$this->assertResolveStream($this->client->connect('www.google.com:80'));
8185
}
8286

87+
/** @group internet */
8388
public function testConnectionSocks5()
8489
{
8590
$this->server->setProtocolVersion(5);
@@ -88,6 +93,7 @@ public function testConnectionSocks5()
8893
$this->assertResolveStream($this->client->connect('www.google.com:80'));
8994
}
9095

96+
/** @group internet */
9197
public function testConnectionAuthenticationFromUri()
9298
{
9399
$this->server->setAuthArray(array('name' => 'pass'));
@@ -97,6 +103,7 @@ public function testConnectionAuthenticationFromUri()
97103
$this->assertResolveStream($this->client->connect('www.google.com:80'));
98104
}
99105

106+
/** @group internet */
100107
public function testConnectionAuthenticationCallback()
101108
{
102109
$called = 0;
@@ -116,6 +123,7 @@ public function testConnectionAuthenticationCallback()
116123
$this->assertEquals(1, $called);
117124
}
118125

126+
/** @group internet */
119127
public function testConnectionAuthenticationCallbackWillNotBeInvokedIfClientsSendsNoAuth()
120128
{
121129
$called = 0;
@@ -131,6 +139,7 @@ public function testConnectionAuthenticationCallbackWillNotBeInvokedIfClientsSen
131139
$this->assertEquals(0, $called);
132140
}
133141

142+
/** @group internet */
134143
public function testConnectionAuthenticationFromUriEncoded()
135144
{
136145
$this->server->setAuthArray(array('name' => 'p@ss:w0rd'));
@@ -140,6 +149,7 @@ public function testConnectionAuthenticationFromUriEncoded()
140149
$this->assertResolveStream($this->client->connect('www.google.com:80'));
141150
}
142151

152+
/** @group internet */
143153
public function testConnectionAuthenticationFromUriWithOnlyUserAndNoPassword()
144154
{
145155
$this->server->setAuthArray(array('empty' => ''));
@@ -149,6 +159,7 @@ public function testConnectionAuthenticationFromUriWithOnlyUserAndNoPassword()
149159
$this->assertResolveStream($this->client->connect('www.google.com:80'));
150160
}
151161

162+
/** @group internet */
152163
public function testConnectionAuthenticationEmptyPassword()
153164
{
154165
$this->server->setAuthArray(array('user' => ''));
@@ -157,6 +168,7 @@ public function testConnectionAuthenticationEmptyPassword()
157168
$this->assertResolveStream($this->client->connect('www.google.com:80'));
158169
}
159170

171+
/** @group internet */
160172
public function testConnectionAuthenticationUnused()
161173
{
162174
$this->client = new Client('name:pass@127.0.0.1:' . $this->port, $this->connector);
@@ -198,16 +210,19 @@ public function testConnectionInvalidAuthenticationMismatch()
198210
$this->assertRejectPromise($this->client->connect('www.google.com:80'), '', SOCKET_EACCES);
199211
}
200212

213+
/** @group internet */
201214
public function testConnectorOkay()
202215
{
203216
$this->assertResolveStream($this->client->connect('www.google.com:80'));
204217
}
205218

219+
/** @group internet */
206220
public function testConnectorInvalidDomain()
207221
{
208222
$this->assertRejectPromise($this->client->connect('www.google.commm:80'));
209223
}
210224

225+
/** @group internet */
211226
public function testConnectorCancelConnection()
212227
{
213228
$promise = $this->client->connect('www.google.com:80');
@@ -216,6 +231,7 @@ public function testConnectorCancelConnection()
216231
$this->assertRejectPromise($promise);
217232
}
218233

234+
/** @group internet */
219235
public function testConnectorInvalidUnboundPortTimeout()
220236
{
221237
// time out the connection attempt in 0.1s (as expected)
@@ -224,6 +240,7 @@ public function testConnectorInvalidUnboundPortTimeout()
224240
$this->assertRejectPromise($tcp->connect('www.google.com:8080'));
225241
}
226242

243+
/** @group internet */
227244
public function testSecureConnectorOkay()
228245
{
229246
if (!function_exists('stream_socket_enable_crypto')) {
@@ -235,6 +252,7 @@ public function testSecureConnectorOkay()
235252
$this->assertResolveStream($ssl->connect('www.google.com:443'));
236253
}
237254

255+
/** @group internet */
238256
public function testSecureConnectorToBadSslWithVerifyFails()
239257
{
240258
if (!function_exists('stream_socket_enable_crypto')) {
@@ -246,6 +264,7 @@ public function testSecureConnectorToBadSslWithVerifyFails()
246264
$this->assertRejectPromise($ssl->connect('self-signed.badssl.com:443'));
247265
}
248266

267+
/** @group internet */
249268
public function testSecureConnectorToBadSslWithoutVerifyWorks()
250269
{
251270
if (!function_exists('stream_socket_enable_crypto')) {
@@ -257,6 +276,7 @@ public function testSecureConnectorToBadSslWithoutVerifyWorks()
257276
$this->assertResolveStream($ssl->connect('self-signed.badssl.com:443'));
258277
}
259278

279+
/** @group internet */
260280
public function testSecureConnectorInvalidPlaintextIsNotSsl()
261281
{
262282
if (!function_exists('stream_socket_enable_crypto')) {
@@ -268,6 +288,7 @@ public function testSecureConnectorInvalidPlaintextIsNotSsl()
268288
$this->assertRejectPromise($ssl->connect('www.google.com:80'));
269289
}
270290

291+
/** @group internet */
271292
public function testSecureConnectorInvalidUnboundPortTimeout()
272293
{
273294
$ssl = new SecureConnector($this->client, $this->loop);

0 commit comments

Comments
 (0)