Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use local squid docker instance for proxy testing
- Loading branch information
1 parent
e002c05
commit 605810e
Showing
5 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
/** | ||
* This configures the access to a proxy server for HTTP related proxy tests. | ||
*/ | ||
$conf['host'] = '127.0.0.1'; | ||
$conf['port'] = 3128; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
<?php | ||
|
||
require_once (__DIR__ . '/httpclient_mock.php'); | ||
require_once(__DIR__ . '/httpclient_mock.php'); | ||
|
||
class httpclient_http_proxy_test extends DokuWikiTest | ||
{ | ||
protected $url = 'http://httpbingo.org/user-agent'; | ||
protected $host; | ||
protected $port; | ||
|
||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$configuration = DOKU_UNITTEST . "proxy.conf.php"; | ||
if (file_exists($configuration)) { | ||
/** @var $conf array */ | ||
include $configuration; | ||
$this->host = $conf['host']; | ||
$this->port = $conf['port']; | ||
} | ||
|
||
if (!$this->host || !$this->port) { | ||
$this->markTestSkipped("Skipped proxy tests. Missing configuration"); | ||
} | ||
} | ||
|
||
class httpclient_http_proxy_test extends DokuWikiTest { | ||
protected $url = 'http://eu.httpbin.org/user-agent'; | ||
|
||
/** | ||
* @group internet | ||
*/ | ||
function test_simpleget(){ | ||
function testSimpleGet() | ||
{ | ||
$http = new HTTPMockClient(); | ||
// proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org> | ||
$http->proxy_host = 'proxy.andrwe.org'; | ||
$http->proxy_port = 8080; | ||
$http->proxy_host = $this->host; | ||
$http->proxy_port = $this->port; | ||
|
||
$data = $http->get($this->url); | ||
$this->assertFalse($data === false, $http->errorInfo($this->url)); | ||
$this->assertTrue(strpos($data,'DokuWiki') !== false, 'response content'); | ||
$this->assertStringContainsString('DokuWiki', $data, 'response content'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,17 @@ | ||
<?php | ||
require_once dirname(__FILE__).'/httpclient_http_proxy.test.php'; | ||
require_once dirname(__FILE__) . '/httpclient_http_proxy.test.php'; | ||
|
||
class httpclient_https_proxy_test extends httpclient_http_proxy_test { | ||
protected $url = 'https://eu.httpbin.org/user-agent'; | ||
class httpclient_https_proxy_test extends httpclient_http_proxy_test | ||
{ | ||
protected $url = 'http://httpbingo.org/user-agent'; | ||
|
||
public function setUp() : void { | ||
public function setUp(): void | ||
{ | ||
// skip tests when this PHP has no SSL support | ||
$transports = stream_get_transports(); | ||
if(!in_array('ssl',$transports)){ | ||
if (!in_array('ssl', $transports)) { | ||
$this->markTestSkipped('No SSL support available.'); | ||
} | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* @group internet | ||
*/ | ||
function test_connectfail(){ | ||
$http = new HTTPMockClient(); | ||
// proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org> | ||
$http->proxy_host = 'proxy.andrwe.org'; | ||
$http->proxy_port = 8080; | ||
|
||
// the proxy accepts connections to defined URLs only - the connect call should fail | ||
$data = $http->get('https://www.google.com'); | ||
$this->assertFalse($data); | ||
$this->assertEquals(-150, $http->status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters