Test case for proxy authentication when request is HTTPS

This commit is contained in:
Richard van den Berg 2015-12-12 11:13:41 +01:00
parent ac50b609ac
commit 077f157adf

View file

@ -19,6 +19,24 @@
App::uses('HttpSocket', 'Network/Http');
App::uses('BasicAuthentication', 'Network/Http');
/**
* class TestHttpSocket
*
* @package Cake.Test.Case.Network.Http
*/
class TestHttpSocket extends HttpSocket {
/**
* testSetProxy method
*
* @return void
*/
public function testSetProxy($proxy = null) {
$this->_proxy=$proxy;
$this->_setProxy();
}
}
/**
* BasicMethodTest class
*
@ -60,4 +78,26 @@ class BasicAuthenticationTest extends CakeTestCase {
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']);
}
/**
* testProxyAuthenticationSsl method
*
* @return void
*/
public function testProxyAuthenticationSsl() {
$http = new TestHttpSocket();
$http->request['uri']['scheme'] = 'https';
$proxy = array(
'host' => 'localhost',
'port' => 3128,
'method' => 'Basic',
'user' => 'mark',
'pass' => 'secret'
);
$http->testSetProxy($proxy);
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->config['proxyauth']);
$this->assertFalse(isset($http->request['header']['Proxy-Authorization']));
}
}