Skip to content

Commit 077f157

Browse files
committed
Test case for proxy authentication when request is HTTPS
1 parent ac50b60 commit 077f157

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@
1919
App::uses('HttpSocket', 'Network/Http');
2020
App::uses('BasicAuthentication', 'Network/Http');
2121

22+
/**
23+
* class TestHttpSocket
24+
*
25+
* @package Cake.Test.Case.Network.Http
26+
*/
27+
class TestHttpSocket extends HttpSocket {
28+
29+
/**
30+
* testSetProxy method
31+
*
32+
* @return void
33+
*/
34+
public function testSetProxy($proxy = null) {
35+
$this->_proxy=$proxy;
36+
$this->_setProxy();
37+
}
38+
}
39+
2240
/**
2341
* BasicMethodTest class
2442
*
@@ -60,4 +78,26 @@ public function testProxyAuthentication() {
6078
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']);
6179
}
6280

81+
/**
82+
* testProxyAuthenticationSsl method
83+
*
84+
* @return void
85+
*/
86+
public function testProxyAuthenticationSsl() {
87+
$http = new TestHttpSocket();
88+
$http->request['uri']['scheme'] = 'https';
89+
$proxy = array(
90+
'host' => 'localhost',
91+
'port' => 3128,
92+
'method' => 'Basic',
93+
'user' => 'mark',
94+
'pass' => 'secret'
95+
);
96+
97+
$http->testSetProxy($proxy);
98+
99+
$this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->config['proxyauth']);
100+
$this->assertFalse(isset($http->request['header']['Proxy-Authorization']));
101+
}
102+
63103
}

0 commit comments

Comments
 (0)